I don't see this as an ambiguity issue but rather a decision of whether 
your grammar uses reserved words or not.
I'm not an expert by any means but that doesn't mean I don't have an 
opinion just that you should take it with a grain of salt.

You can either handle this with a symbol table later in the process or 
rewrite the requestline to something like
requestline : ver EQUAL (SPECIAL_STRING | ver);

Joe


Achint Mehta wrote:
> Hi All,
>
> The section "Ambiguities and Non determinisms" of the book "The 
> definitive ANTLR guide" talks about the ambiguities in lexer rules, 
> but I am not sure how to resolve them.
>
> Consider a following grammar which assigns a value to an ID. The ID 
> can either be VERSION or COUNT while its value can be anything:
> -----------------------------------------------
> grammar sample_parser;
>
> requestline : ver EQUAL SPECIAL_STRING ;
>
> /* Tokens */
> ver:('VERSION'| 'V') {}
>       | ('COUNT' | 'C') {} ;
>
>    
> SPECIAL_STRING:(CHAR)+ ;
> WHITESPACE: ' ';
> NEWLINE: ('\r')? '\n';
> EQUAL: '=';
>
> fragment
> CHAR: (('a'..'z')|('A'..'Z'));
> -----------------------------------------------
>
> If the input is given as
> VERSION=FIRST
> Then it works, but if following input is given
> VERSION=VERSION
> Then I get an error (MissingTokenException after the "=").
>
> How can this ambiguity be resolved ?
>
> Thanks in advance.
>
> Regards,
> Achint
> ------------------------------------------------------------------------
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>   

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Reply via email to