yacc - Bison: Give left precedence to a rule? -
with bison have many %left's (+,*, etc) , few %right's (=, +=, etc). these tokens. have rule. its
| rval | attrdata rval
the problem is, attrdata rval returns rval attrdata 1+1 either (attrdata 1) +1 or attrdata (1+1). apply left rule attrdata doesnt work cause isnt token. tried %prec , error too.
i can fix writing | attrdata '(' rval ')'
dont want , rather have users write attrdata (1+1)
since of time they'll mean (attrdata 1)+1.
how give rule left precedence?
the thing similar have else, solved forcing braces no confusion (if cond { if cond } else )
you can set explicit precedences may you
if else example
%nonassoc lower_than_else %nonassoc else %% stmt : if expr stmt %prec lower_than_else ; | if expr stmt else stmt;
Comments
Post a Comment