[antlr-interest] Grammar ambiguity
Johannes Luber
jaluber at gmx.de
Mon Apr 16 11:05:29 PDT 2007
Hello,
I have been removing grammar ambiguities of my C# grammar, but I've
stumbled over one case where I have no idea how I can solve it.
The situation is basically:
input: token*;
token: real_literal;
real_literal:
DECIMAL_DIGIT+ '.' DECIMAL_DIGIT+ EXPONENT_PART? REAL_TYPE_SUFFIX?
;
ANTLR doesn't if there are two or more DECIMAL_DIGITs after '.', if
those belong to the same real_literal or if they start a second
real_literal (which has a DECIMAL_DIGIT as start token), as ANTLR can
generate an arbitrary number of tokens.
Hmm, writing about this gave me the idea that I could change the second
DECIMAL_DIGIT into another rule like FRACTIONAL_DECIMAL_DIGIT, but then
I'd get probably an non-determinism between FRACTIONAL_DECIMAL_DIGIT and
DECIMAL_DIGIT.
Any ideas?
Best regards,
Johannes Luber
More information about the antlr-interest
mailing list