[antlr-interest] Literals in lexer

Arnar Birgisson arnarb at oddi.is
Tue Nov 18 09:46:54 PST 2003


Hello

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

What do you mean about threathing "this" as a literal? "this" is
actually "þessi" in my programming language, so the auto-generated token
name chokes the C++ compiler. Besides, my lexing is made up of two
lexers, and neither of them are in the same file as the parser
definition (so there's no parser-lexer association).

The document says to use the "literals" option and there's a link to the
options page, but there is no "literals" option documented there.

testLiterals is set to true for the whole grammar.

Arnar


> 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/ 
> 
> 


 

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




More information about the antlr-interest mailing list