[antlr-interest] RFC re/ Left factoring and Syntactic Predicate
Subhobroto Sinha
subhobrotosinha at rediffmail.com
Tue Jul 5 12:23:14 PDT 2005
The FLOAT vs INT issue is an often repeated topic, and as I am currently in the same trap, I wish to resolve it as much as possible (to benefit me as well as others)
Intutively defn. of an INT is : ('0' .. '9')+;
A FLOAT is : : INT '.' INT;
Let's write that again :
coefficient : INT | INT DOT INT;
Left Factoring :
coefficient : INT leftNumFactor;
leftNumFactor : DOT INT | /* epsilon */;
However, ANTLR barks at me in a rule in my TreeWalker :
csvCoeffs : (coefficient)+;
It says :
DSD.mail.g:40: warning:nondeterminism upon
DSD.mail.g:40: k==1:INT
DSD.mail.g:40: between alt 1 and exit branch of block
I am really in the dark here. I am sure I left factored right, so where is the problem ?
I might mention that the program is working just as I wanted, but I feel bad about any warnings ;)
The complete grammar is available at http://www.geocities.com/subhobrotosinha/dsdmail.txt
The version employing syntactic predicate is at http://www.geocities.com/subhobrotosinha/dsd.txt
On the other hand, an alternate version of mine, which employs syntactic predicate on FLOAT and INT seems to work too, but issues similar nondeterminism warnings in the TreeWalker ?
What am I doing wrong in the tree walker ?
Also, what are your views on left factoring vs. syntactic predicates ?
Regards
Subhobroto Sinha
http://www.geocities.com/subhobrotosinha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050705/1a8f0976/attachment.html
More information about the antlr-interest
mailing list