#define NUMAR 0 #include"getop.h" #include #include #include "stiva.h" void opereaza (int); void expresie (void); int x; char s[50] void factor (void) { if (x=='(') { x=getop (s); expresie(); if (x!=')') eroare(); x=getop (s); } else if (x==NUMAR) { opereaza (x); x=getop(); } else eroare() } void termen(void) { int op; factor(); while (x=='x'||x=='/') { op=x x=getop (s); factor(); opereaza (op); } } void expresie (void) { int op; termen; while (x=='+'||x=='-') { op=x; x=getop(s); termen() opereaza (op); } void opereaza (int op) { float op1,op2; if (op==NUMAR) push(ataf(s)); else { op1=top();pop(); op2=top();pop(); } switch (op) { case '+':push(op1+op2); break; case '-':push(op1-op2);break ; }