Grammar Ambiguity -- I don't see it
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Steve_Drach
Posted On:   Tuesday, August 13, 2002 04:39 PM

The following grammar gives ambiguity errors: class TestParser extends Parser; tokens { ID; TOKEN; LPAREN; RPAREN; COMMA; } top : ID LPAREN arg (COMMA arg)* RPAREN ; arg : (ID | TOKEN | subarg)+ ; subarg : LPAREN (arg | COMMA)+ RPAREN ; However it seems to generate the "right" code. So how do I fix it to not give errors without setting the ambiguity options? I think you can see what I want to do -- allow arbitrary data, including commas inside the inner parenthesis pairs.    More>>

The following grammar gives ambiguity errors:


			
class TestParser extends Parser;

tokens { ID; TOKEN; LPAREN; RPAREN; COMMA; }

top : ID LPAREN arg (COMMA arg)* RPAREN ;

arg : (ID | TOKEN | subarg)+ ;

subarg : LPAREN (arg | COMMA)+ RPAREN ;


However it seems to generate the "right" code. So
how do I fix it to not give errors without setting the
ambiguity options? I think you can see
what I want to do -- allow arbitrary data, including
commas inside the inner parenthesis pairs.

   <<Less
About | Sitemap | Contact