[antlr-interest] Trouble with ANTLR 3 grammar

Terence Parr parrt at cs.usfca.edu
Sat Jul 1 12:02:26 PDT 2006


On Jul 1, 2006, at 5:26 AM, Emond Papegaaij wrote:
> The lexer does hit 'channel=99', but only after the token is  
> already emitted.
> Printing the channel inside the loop in Main shows '0'. For every  
> WS token
> mWS is called twice. It seems that on the first call the token is  
> emitted,
> and on the second call the channel is set. I can't explain why.

Ah!  I think that gives me the hint...remember that filter mode  
backtracks, looking for a match.  When it finds one, it rewinds and  
does the rule "with feeling".

Ter
> Here is some
> output with println statements added at the start of the method, at
> the 'channel=99' statement and at the 'emit' statement:
>
> inWS
> emit(11,1,9,0,9,9)
> inWS
> channel=99; line=1 char=9
> inWS
> emit(11,1,11,0,11,12)
> inWS
> channel=99; line=1 char=11
>
>
> Best regards,
> Emond Papegaaij



More information about the antlr-interest mailing list