| exp add_sub term {$$= make_operator ($1, $2, $3);}to:
| term add_sub exp {$$= make_operator ($1, $2, $3);}Alternatively, you could fully replace all the rules for exp, term and factor. It is probably simplest to always do:
%typeand use "num" everywhere the question mentions "number".num num : number {$$= make_operand ($1);} ;
7a)
%typewhich can be run as e.g.:exp num exp : num {$$= $1;} | num add_sub num {$$= make_operator ($1, $2, $3);} | num mul_div num {$$= make_operator ($1, $2, $3);} ;
1; 1 =1 1+2; 2 + 1 =3 1*2; 2 * 1 =2 1+2*3; syntax error
7b)
%typeexp term num exp : term {$$= $1;} | exp add_sub term {$$= make_operator ($1, $2, $3);} ; term : num {$$= $1;} | term mul_div num {$$= make_operator ($1, $2, $3);} ;
and all the rest are very similar.