[antlr-interest] Literals in lexer

Cristian Amitroaie cristian at amiq.ro
Tue Nov 18 05:10:51 PST 2003


How about treating "this" as a literal and adding
{testLiterals=true;} to L_NAME?


On Sunday 16 November 2003 20:30, Arnar Birgisson wrote:
> 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/


 

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




More information about the antlr-interest mailing list