Conflict resolution with ReduceIf

Sep 10, 2013 at 4:38 PM
Edited Sep 10, 2013 at 4:42 PM
I have a conflict with this grammar
Entity.Rule = MakeStarRule(Entity, Member);
Member.Rule = Property | Operation;
Property.Rule = ID + Many_opt + ID + ToTerm(";");
Operation.Rule = ID + ID + ToTerm("(") + ToTerm(")");
Many_opt.Rule = Empty | ToTerm("*");

I saw a discussion
about ReduceIf which could help me but i don't understand how i can use it in my case.
Sep 11, 2013 at 6:45 AM
I think the problem is in Many_opt nonterminal; so you should add a ReduceIf stating that it should be reduced if there's semicolon ahead (before opening brace).
Sep 11, 2013 at 7:05 AM
Thank you roman,

I added this line Many_opt.AddHintToAll(ReduceIf(";", "(")) and all is ok.
But is it the right way ?
Sep 11, 2013 at 4:59 PM
yep, why not? Just test it on inputs that cover all possible cases and make sure the output tree is correct.