enum token_value {
NAME, NUMBER, END,
PLUS='+', MINUS='-', MUL='*', DIV='/',
PRINT=';', ASSIGN='=', LP='(', RP=')'
};
token_value curr_tok;
double term();
double prim();
double expr();
double error(const char* s);
token_value get_token();
double term() {
double left=prim();
for(;;)
switch(curr_tok) {
MUL:
get_token();
left*=prim();
break;
DIV:
get_token();
double d = prim();
if(d==0) return(error("Division by zero"));
left/=prim();
break;
default:
return(left);
}
}
C++, Непонятная ошибка |