[antlr-interest] lexical nondeterminism
Mike Lischke
lists at lischke-online.de
Sun Mar 28 06:23:52 PST 2004
Hi,
I'm a newcomer with ANTLR, coming over from SableCC, and while I'm converting my SableCC grammars I found a warning, which I don't understand. Suppose I have two lexer rules like:
INTEGER_LITERAL: DECIMAL_NUMBER_LITERAL | HEX_NUMBER_LITERAL | OCTAL_NUMBER_LITERAL;
FLOATING_POINT_LITERAL:
(DIGIT)+ '.' (DIGIT)* (EXPONENT_PART)? (FLOAT_TYPE_SUFFIX)? |
'.' (DIGIT)+ (EXPONENT_PART)? (FLOAT_TYPE_SUFFIX)? |
(DIGIT)+ EXPONENT_PART (FLOAT_TYPE_SUFFIX)? |
(DIGIT)+ (EXPONENT_PART)? FLOAT_TYPE_SUFFIX;
With these simple rules I get the warning:
V:\Eclipse projects\ParserTest\Grammar\Test.g: warning:lexical nondeterminism between rules INTEGER_LITERAL and FLOATING_POINT_LITERAL upon
V:\Eclipse projects\ParserTest\Grammar\Test.g: k==1:'0'..'9'
V:\Eclipse projects\ParserTest\Grammar\Test.g: k==2:'0'..'9'
Given that rules are handled in a greedy manner I don't see where there is an ambiquity. There is no definition for a pure sequence of digits in the floating point literal so such an input should really only match the integer literal rule. Where is my mistake of understanding?
Thankful for any help,
Mike
--
www.soft-gems.net
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list