[antlr-interest] Resolving ambiguity
Stefan
jan_ek at op.pl
Fri May 4 08:26:57 PDT 2007
Hello!
What is the approach to resolve semantical ambiguity in grammar in
ANTLRv3? Consider the grammar:
grammar My;
fragment
DIGIT : '0'..'9';
fragment
NONDIGIT: 'a'..'z' | 'A'..'Z' | '_';
IDENTIFIER
: NONDIGIT (DIGIT | NONDIGIT)*;
function_definition
: 'function' IDENTIFIER;
function_call
: IDENTIFIER;
variable_definition
: 'var' IDENTIFIER;
expression
: IDENTIFIER;
statement
:
(
function_definition
| function_call
| variable_definition
| expression
) ';';
program : statement+;
For input "something;" I want to select the appropriate rule depending
on the meaning of "something" - if it's a function or variable. How do I
do that?
Stefan Chrobot
More information about the antlr-interest
mailing list