[antlr-interest] how to resolve ambiguity considering identifiers vs mathematical constants
Gerard van de Glind
g.vandeglind at beinformed.nl
Tue May 27 04:37:54 PDT 2008
Hi,
I am writing a grammar (using antlr 3) that should be able to parse
identifiers and mathematical constants (they may be used in more complex
constructs). For example, the mathematical constant PI and E. Depending
on the context they can also be identifiers.
How can I best resolve this ambiguity?
Thanks in advance!
Gerard
Here is a simplified grammar:
expression
: MATH_CONSTANT | IDENTIFIER;
MATH_CONSTANT
: 'E' | 'PI';
IDENTIFIER
: ('a'..'z'|'A'..'Z')
('0'..'9'|'a'..'z'|'A'..'Z'|'_'|'.')*;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080527/7ef67585/attachment.html
More information about the antlr-interest
mailing list