Reputation: 13
I have a requirement wherein I have written the Lexer token as:
IF_LEXER_TOKEN: 'IF' (.)* 'END_IF'
ANY :(options {greedy=true;}: .)* ;
But if the input is given as:
IF a>b then a=b END_IF
IF c>d then c=d
In this case the expected behavior is that it should use the token IF_LEXER_TOKEN
for first line and ANY token for second line, but instead its considering the ANY token for both lines. Kindly help. Note:Due to some constraints I can't create a parser rule for the above scenario.
Upvotes: 1
Views: 39
Reputation: 170227
My answer would be: don't do what you're trying to do. Never use .*
or .+
at the end of a lexer rule: it consumes everything until EOF
.
I don't know exactly what you're trying to do, but it seems to me you're trying to get an answer to problem Y
1, while you ought to be explaining problem X
1.
1 https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem
Upvotes: 0