twopass.h, to add
mypower to operatortype.
twopass.c, to add
'^' to operators
case mypower: return nint(pow(lh,rh)); to evaluate
#include <math.h>
makefile, to add
-lm to the end of gcc twopass_y.o twopass_l.o twopass.o -o twopass
twopass_l.l, to add
"^" {yylval.a_number= mypow; return mypower;}
twopass_y.y, to add
Note that this will give you a "shift-reduce conflict",
but you can ignore this as long as you only use ^ operators
when you test the program.
%token
| factor my_power term {$$= make_operator ($1, $2, $3);} to term