[antlr-interest] inserting tokens (v2)

Jim Idle jimi at temporal-wave.com
Wed Jun 10 08:35:55 PDT 2009


ajk . wrote:
> Hi
>
> I am not sure if this is the right way to solve this particular issue 
> but what I have
> is a grammar where I would like to insert tokens inside the token stream
> e.g. finding ']' and '(' I would like to insert '.Invoke' in between 
> i.e. ].Invoke(
>
> Is this somehow possible by manipulating the lexer rules or is this a 
> bad practice
> and should be done on the parser rule level instead?
>
> Example:
>
> D[1]() ==> D[1].Invoke()    (where the string ".Invoke" is always the 
> same and is actually two tokens)
Look at the TokenRewriteStream (there are examples I think), which is 
meant for this.

Jim


More information about the antlr-interest mailing list