I am looking at the calc source here http://epaperpress.com/lexandyacc/
I see theses lines in calc.y
| expr \'+\' expr { $$ = opr(\'+\', 2,
You can do it in 2 ways:
Using mathOp as nonterminal you can return some associated value:
mathOp : '+' { $$ = '+'; } | '-' { $$ = '-'; } ...
Then usage will look like (pay attention to $2):
| expr mathOp expr { $$ = opr($2, 2, $1, $3); }
may be you would like to define more complicated mathOp then use %type