[antlr-interest] Literals in lexer

Arnar Birgisson arnarb at oddi.is
Sun Nov 16 10:30:32 PST 2003


Hello..

I have those rules in my lexer:

L_THIS : "this" ;
L_NAME : NameChar ( NameChar | '0'..'9' )* ;
protected NameChar : ( 'a'..'z' | etc. ) ;

Now, the input "thisfile" is taken as two tokens, (L_THIS,"this") and
(L_NAME,"file"). How do I correct this. The obvious way is to put
predicates in all the L_* rules I have.. but there must be a simpler
way.

I have read the documentation on literals in lexical anlyzers.. but I
can't figure out how to do this.

thanks..

Arnar


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list