[antlr-interest] adding content at end of rulewithTokenRewriteStream

Jean Marc Vanel JeanMarc.Vanel at mathworks.fr
Fri Feb 23 08:22:41 PST 2007


....
> > name_or_pointer
> > @init {
> >     tokens = (TokenRewriteStream)input;
> > }
> >     	:	NAME (star='*')?
> > 		{ tokens.insertAfter( star.stop, " == after '*' ===" );
}
> > 	;
> 
> Maybe put the action inside the (...)? so that it only executes if
there
> is a star present?

[Jean-Marc Vanel] Sure that would prevent the NullPointerException.

But my goal here is to add something after the end of the rule
"name_or_pointer", independently of the presence or absence of '*' .

In all the examples and doc. for v. 3.0, I couldn't find a clue for a
reference to the last token matched by the current rule.

JMV


More information about the antlr-interest mailing list