[antlr-interest] bug in 3.0b6: identifier/keyword or underscore problem?
Emond Papegaaij
e.papegaaij at student.utwente.nl
Mon Feb 26 05:20:29 PST 2007
On Monday 26 February 2007 13:13:13 Martin d'Anjou wrote:
> I've been strugling with this for several days. It looks like 3.0b6 can't
> tell an identifier from a keyword, or has a problem with underscores. Here
> is how I produce the problem:
>
> lexer grammar DUMMY_Lexer;
> options { filter=true; }
>
> INT : 'int' ;
> SEMI : ';' ;
> WS : ( ' '| '\t'| '\r' | '\n' )+ {$channel=HIDDEN;} ;
> IDENTIFIER : ('a'..'z'|'A'..'Z'|'_')+;
Why are you using the filter option? This option causes ANTLR to try the
tokens one-by-one. It continues at the next token if the current token does
not match. So on the input 'intt' it will match an INT token first, followed
by the IDENTIFIER 't'. When you remove the filter option, it should match a
single IDENTIFIER token.
Best regards,
Emond
More information about the antlr-interest
mailing list