Hi, I'm trying to write a grammar file for parsing expressions. The main part goes as following:
%left '-' '+'; expr: expr '+' expr | expr '-' expr // Other operators... | expr expr | const | id ; "expr expr" here is function application, former expr is the function and latter expression is an argument (as in Haskell). What I need is function application having maximum priority and left associativity. For some reason default behavior is the exact opposite: minimum priority and right associativity. So the first thing I've tried was declaring "%left APPLY;" and then adding "%prec APPLY" to the corresponding line. However, that changed nothing. I was able to sort the problem with priority out by introducing new non-terminal (just like priorities are handled in recursive parsers), but associativity is still a problem here. I don't understand what is wrong with %prec as documentation says it assigns precedence to rule. So can I be missing something fundamental about operator precedence in bison? Any other pointers how to get the desired behavior? -- Regards, Petr. _______________________________________________ help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison