[antlr-interest] Changing a lexer rule to a parser rule
Damien Urruty
lepilache at hotmail.com
Tue Oct 12 07:27:23 PDT 2010
Hi everybody,
I am working on the Java 1.5 grammar provided by the antlr website. I need to change the rule FloatingPointLiteral to a parser rule. If I change just the name of the lexer rule to create a parser rule, I get some RecognitionExceptions. I don't get why my grammar is not able anymore to recognize floating point literals if I just change the lexer rule to a parser rule.
floatingPointLiteral : (Number)+ POINT (Number)* Exponent? FloatTypeSuffix? | POINT (Number)+ Exponent? FloatTypeSuffix? | (Number)+ Exponent FloatTypeSuffix? | (Number)+ FloatTypeSuffix ;
If the name of the rule is FloatingPointLiteral it works, but if it's floatingPointLiteral (parser rule), it doesn't work anymore.Could anyone explain me what the problem is ? I guess the parser can't recognize the tokens correctly, but it is strange because they are exactly the same ! In fact, I would like to create an object to store the literal, that is why I wanted to transform the lexer rule into a parser rule, to return my own object. Is this possible (by this way or another) ?Thanks in advance.
More information about the antlr-interest
mailing list