[antlr-interest] Disambiguating Lexemes Question

Bert Williams gilbert.williams at prosync.com
Tue Feb 6 06:57:13 PST 2007


Greetings:

 

I looked for an example of this for ½ a day, but still cannot get my
“expected” results.

 

I have a grammar with lexer components (not all are shown):

 

DIGIT : '0'..'9' ;

 

protected

ALPHA :     ('a'..'z'|'A'..'Z' ) ;

 

protected

COLL_ELEM

      :     ALPHA

      |     DIGIT

      ;

 

I used the “protected” keyword to eliminate ambiguity warnings during the
Antlr build process.  My test case is based on the “Calc” Java example.

 

When I run the lexer and print tokens, I get “ALPHA” as the token type for
input “a” rather than the expected “COLL_ELEM”. (There are other terminals
in the grammar composed of DIGIT | ALPHA as well).

 

Could someone provide a quick guide or point me to additional documentation?

 

I need to be able to identify the “highest order” lexeme if ANTLR supports
this capability.

 

Thanks and have a great day!

 

Bert Williams.

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070206/23436a8a/attachment-0001.html 


More information about the antlr-interest mailing list