[antlr-interest] ambiguous grammar

beeh1973 <hastur4711 at bigfoot.com> hastur4711 at bigfoot.com
Sat Jan 18 13:49:19 PST 2003


hi,

in my language i have float literals like .1 and
expressions like $.1

i am using the following lexer rule to recognize numbers

NUMBER
 : '.'        { _ttype = DOT; }            // a single dot
   (((DIGIT)+ { _ttype = FLOAT} )          // a float number
   ((EXPONENT))?)?
 |
   // some more cases for integers and floats > 1
  ...

DOLLAR : '$' ;


in the parser i try to match $.1 with this rule:

component:
  DOLLAR^ DOT NUMBER
  ;

while parsing $.1 i get an error that FLOAT is unexpected at that 
point.

while i understand why this is happening; a call to nextToken simply
returns the next token which is a FLOAT no DOT, i do not understand 
how to
fix the grammar. can anybody help me with this?

thanks in advance,
        alphonse bendt



 

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



More information about the antlr-interest mailing list