unundes NonTerminal

Apr 10, 2012 at 4:01 PM

hello,

here is my problem.

When i use the following grammar

IdentifierTerminal id = new IdentifierTerminal("Id" );
NonTerminal variable = new NonTerminal("variable");
NonTerminal method = new NonTerminal("method");

variable.Rule = MakePlusRule(variable, ToTerm("."), id);
method.Rule = variable + ToTerm(".") + id + "()";

this.Root = method;

 

i can parse  a.b() and a.b.c()

but not with this one  :

 

IdentifierTerminal id = new IdentifierTerminal("Id" );
NonTerminal variable = new NonTerminal("variable");
NonTerminal unused = new NonTerminal("unused");
NonTerminal method = new NonTerminal("method");

variable.Rule = MakePlusRule(variable, ToTerm("."), id);
unused.Rule = variable;
method.Rule = unused + ToTerm(".") + id + "()";

this.Root = method;

 

 

thank you for  your help.

Guillaume

 

Coordinator
Apr 10, 2012 at 4:43 PM

I bet the second version shows a shift-reduce conflict shown in Grammar errors tab - this is the problem; the parser needs to decide to reduce "unused" rule when it sees variable followed by dot, and it is not enough information. Do not try to use the grammar until you resolve all conflicts!

Apr 16, 2012 at 9:16 AM

you are right, i have a conflit in the grammar.

thank you for your answer.