I am trying to use precedences in Bison. After several trials, a simplified version of the relevant part of my input file is (it is supposed to produce reversed Polish notation):
------------------------------------------------------------------------------------ %{ ... %} %left ADD %left MULT %right EXP %left UNARY %% ... Expr : Expr AddOp Expr %prec ADD { printf("+"); } | Expr MultOp Expr %prec MULT { printf("*"); } | Expr ExpOp Expr %prec EXP { printf("^"); } | 'a' { printf("a"); } | '(' Expr ')' | '-' Expr %prec UNARY { printf("~"); } ; AddOp : '+' | '-' ; MultOp : '*' | '/' ExpOp : '^' ; %% ... ------------------------------------------------------------------------------ Unfortunately precedences do not seem to work. On the other hand, if I replace operator nonterminals by (like Addop) their symbols ('+') and put specs like %left '+', it works (without any %prec). Any hints? -- tsf _______________________________________________ help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison