[antlr-interest] Resolving ambiguity
Micheal J
open.zone at virgin.net
Fri May 4 11:30:22 PDT 2007
Use a symbol table. Works as long as declarations preceeds use in your
language.
Micheal
-----------------------
The best way to contact me is via the list/forum. My time is very limited.
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org
> [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Stefan
> Sent: 04 May 2007 16:27
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Resolving ambiguity
>
>
> 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