|
关于Basic程序解释器及编译原理的简单化(1)--词法分析和代数式求值(5) break; } for (t=*h-1;t>0;--t) *r=(*r)*ex; break; } } /* reverse the sign */ void unary(char o,int *r) { if (o=='-') *r = -(*r); }
/* find the value of a variable */ int find_var(char *s) { if (!isalpha(*s)) { serror(4); /* not a variable */ return 0; } return variables[toupper(*token)-'A']; }
/* display an error message */ void serror(int error) { char *e[] = { "syntax error", "uNBAlanced parentheses", "no expression present", "equal sign expected", "not a variable", "label table full", "duplicate label", "undefined label", "THEN expected", "TO expected", "too many nested FOR loops", "NEXT without FOR", "too many nested GOSUB", "RETURN without GOSUB" };
printf ("%s\n",e[error]);
|