[antlr-interest] [v3] Trouble with rewrite...

Terence Parr parrt at cs.usfca.edu
Sun Jun 3 19:43:03 PDT 2007


On Jun 3, 2007, at 6:18 PM, Mark Mandel wrote:

> Heya, I can't work out how to rewrite this tree..
>
> The rule looks like this:
>
> startTag
> 	:
> 	START_TAG_OPEN^ START_TAG_CLOSE
> 	tag* (endTag | EOF)
> 	;
>
> Basically, all I ever want is that structure, but without the EOF  
> taken.

Do you mean "how do I write this using the ->?"

startTag : START_TAG_OPEN^ START_TAG_CLOSE tag* (endTag | EOF)
		-> ^(START_TAG_OPEN START_TAG_CLOSE tag* (endTag | EOF))
		;

> Do I need to do a rewrite, depending on whether I am at endTag | EOF?
> Would that be right?

Not sure what you're asking.  Put a ! on the EOF in your example and  
it removes the EOF.

Ter


More information about the antlr-interest mailing list