#include "stdio.h" #include "string.h" #define ACC -2 /**************************************/ #define sy_if 0 #define sy_then 1 #define sy_else 2 #define sy_while 3 #define sy_begin 4 #define sy_do 5 #define sy_end 6 #define a 7 #define semicolon 8 #define e 9 #define jinghao 10 #define S 11 #define L 12 #define tempsy 15 #define EA 18 #define E0 19 #define plus 34 #define times 36 #define becomes 38 #define op_and 39 #define op_or 40 #define op_not 41 #define rop 42 #define lparent 48 #define rparent 49 #define ident 56 #define intconst 57 /********************************************/ char ch='\0'; int count=0; static char spelling[10]={""}; static char line[81]={""}; char *pline; static char ntab1[100][10]; struct ntab { int tc; int fc; }ntab2[200]; int label=0; struct rwords { char sp[10]; int sy; }; struct rwords reswords[10]={{"if",sy_if}, {"do",sy_do}, {"else",sy_else}, {"while",sy_while}, {"then",sy_then}, {"begin",sy_begin}, {"end",sy_end}, {"and",op_and}, {"or",op_or}, {"not",op_not}}; struct aa { int sy1; int pos; }buf[1000], n, n1, E, sstack[100], ibuf[100], stack[1000]; struct aa oth; struct fourexp { char op[10]; struct aa arg1; struct aa arg2; int result; }fexp[200]; int ssp=0; struct aa *pbuf=buf; int nlength=0; int lnum=0; int tt1=0; FILE *cfile; /********************************************************/ int newt=0; int nxq=100; int lr; int lr1; int sp=0; int stack1[100]; int sp1=0; int num=0; struct ll { int nxq1; int tc1; int fc1; }labelmark[10]; int labeltemp[10]; int pointmark=-1,pointtemp=-1; int sign=0; /********************³ÌÐòÓï¾äµÄLR·ÖÎö±í********************/ static int action[19][13]= {{2,-1,-1,3,4,-1,-1,5,-1,-1,10,1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,ACC,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1,-1,6,-1,-1,-1},...