[antlr-interest] [newbie] Lexer Question

Arnar Birgisson arnarb at oddi.is
Wed Oct 1 10:26:25 PDT 2003


ANTLR resolves this for you automatically by putting all string literals
in the parser and lexer definitions (such as "MOD" in this case) in to a
special table. When the parser matches a an IDENT on the input it checks
to see if it's in this table (called the literals table) and if it finds
it there, then it returns the correct token (MOD in this case).

You can turn off this literal table checking by putting
  testLiterals=false;
in your parser options section. You can then enable this checking
specifically for the IDENT rule with the opposite option, like this:

IDENT
	options {testLiterals=true;}
	:	('a'..'z') ...

ANTLR still gives you ambiguity warnings for this, which you can safely
ignore.

Arnar

> -----Original Message-----
> From: jagad [mailto:jagad at enciety.com] 
> Sent: 1. október 2003 17:02
> To: ANTLR Milis
> Subject: [antlr-interest] [newbie] Lexer Question
> 
> 
> Hi All,
> 
> I have lexer with conflicting declaration like this:
> 
> MOD    : "MOD"
> IDENT  : ('a'..'z' | 'A'..'Z') ('a'..'z' | 'A'..'Z' | '0'..'9')*
> 
> How to solve the conflicting between MOD and IDENT?
> 
> Thanks in Advanced and Best Regards
> 
> jagad
> 
> 
> 
>  
> 
> 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