Hey Adam, I have a couple ideas. First, you might try updating the precedence of ',' for just that one rule:
| rvalLoop ',' rval %prec '=' (though you might need to define a precedence-level higher than both ',' and '=' for that to work right). A second, more straightforward, idea is to shuffle around your grammar to focus on the idea of an atomic "rval group": body: recursive-expr // without rval=rval | rvalGroup '=' rvalGroup ; rvalGroup: rval | rvalGroup ',' rval ; -Chris On Tue, Dec 17, 2013 at 12:25 AM, Adam Smalin <[email protected]>wrote: > I still need help with this. I rewrote it maybe this will be more clear? > > I want to allow this > > var = var > var, var = var > var = var, var > > My rules are similar to the below > > body: > recursive-expr //rval = rval is here > | rval '=' rval ',' rvalLoop > | rval ',' rvalLoop '=' rval > > rvalLoop: > rval > | rvalLoop ',' rval > > The problem is '=' is higher precedence than ','. When I write "a=b,c" it > reduce when it sees ',' making a=b an rval and rval ',' rval is invalid so > my parser fails and "rval '=' rval ',' rvalLoop" is never used. The > conflict file shows > > rval '=' rval . ',' rvalLoop > Conflict between rule 352 and token ',' resolved as reduce (',' < '='). > > How do I say for this rule shift instead of reduce? I don't want to make > ',' higher than '=' because it would be wrong when looking into functions. > For example func(a,b=2,c) should have b=2 as an expression and not (a,b) = > (2,c). > _______________________________________________ > [email protected] https://lists.gnu.org/mailman/listinfo/help-bison > _______________________________________________ [email protected] https://lists.gnu.org/mailman/listinfo/help-bison
