[antlr-interest] grammar ambiguity

mzukowski at yci.com mzukowski at yci.com
Wed Dec 18 13:50:00 PST 2002


First you look at the generated code and analyze the lookahead tests in
question.  Then you read the FAQ or email archives about linear approximate
lookahead.  Then go back to your lookahead tests and see if the ambiguity is
a result of linear approximation, it probably is.  Then fix it with a
syntactic predicate.

Monty

-----Original Message-----
From: seaswar <suresh_easwar at acml.com> [mailto:suresh_easwar at acml.com]
Sent: Wednesday, December 18, 2002 1:38 PM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] grammar ambiguity


How do I get rid of the ambiguities in the following.:

class FooParser extends Parser;
options {k = 4;}
id3DList: id3D (COMMA id3D)*;
id2DList: id2D (COMMA id2D)*;
id3D: id2D | ID DOT ID DOT ID
id2D: ID | ID DOT ID;

class FooLexer extends Lexer;
options {k = 2;}
ID: ( 'a'..'z' )+;
COMMA:',';
DOT:'.';

the warnings I get are:
test6.g:5: warning: nondeterminism upon
test6.g:5:         k==1:ID
test6.g:5:         k==2:DOT
test6.g:5:         k==3:ID
test6.g:5:         k==4:DOT
test6.g:5:         between alts 1 and 2 of block


Thanks
Suresh


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list