.\\
ssym['(']=lparen; ssym[')']=rparen; ssym['=']=eql; ssym[',']=comma; ssym['.']=period;
ssym['#']=neq;//not equal ssym[';']=semicolon;
strcpy(&symwork[plus][0],\strcpy(&symwork[minus][0],\strcpy(&symwork[times][0],\strcpy(&symwork[slash][0],\strcpy(&symwork[lparen][0],\strcpy(&symwork[rparen][0],\strcpy(&symwork[eql][0],\
strcpy(&symwork[comma][0],\strcpy(&symwork[neq][0],\
strcpy(&symwork[period][0],\
strcpy(&symwork[semicolon][0],\strcpy(&word[0][0],\关键字小写字母 strcpy(&word[1][0],\strcpy(&word[2][0],\strcpy(&word[3][0],\strcpy(&word[4][0],\strcpy(&word[5][0],\strcpy(&word[6][0],\
strcpy(&word[7][0],\strcpy(&word[8][0],\strcpy(&word[9][0],\strcpy(&word[10][0],\strcpy(&word[11][0],\strcpy(&word[12][0],\wsym[0]=beginsym; wsym[1]=callsym; wsym[2]=constsym; wsym[3]=dosym; wsym[4]=endsym; wsym[5]=ifsym; wsym[6]=oddsym; wsym[7]=procsym; wsym[8]=readsym; wsym[9]=thensym;
.\\
wsym[10]=varsym; wsym[11]=whilesym; wsym[12]=writesym; }
void WordAnalyse() {
switch(sym) { case nul://fout <<\ break; case ident:fout <<\ cout<<\ case number:fout <<\ cout<<\\, \ case plus:fout <<\ cout<<\ case minus:fout <<\ cout<<\ case times:fout <<\ cout<<\ case slash:fout <<\ cout<<\ case oddsym:fout <<\ cout<<\\, \ case lss:fout <<\ cout<<\ case eql:fout <<\ cout<<\ case neq:fout <<\ cout<<\ case leq:fout <<\ cout<<\ case gtr:fout <<\ cout<<\ case geq:fout <<\ cout<<\ case lparen:fout <<\ cout<<\ case rparen:fout <<\
.\\
cout<<\ case comma:fout <<\ cout<<\ case semicolon:fout <<\ cout<<\\, \ case period:fout <<\ cout<<\ case becomes:fout <<\ cout<<\\, \ case beginsym:fout <<\ cout<<\\, \ case endsym:fout <<\ cout<<\ case ifsym:fout <<\ cout<<\ case thensym:fout <<\ cout<<\\, \ case whilesym:fout <<\ cout<<\\, \ case writesym:fout <<\ cout<<\\, \ case readsym:fout <<\ cout<<\\, \ case dosym:fout <<\ cout<<\ case callsym:fout <<\ cout<<\ case constsym:fout <<\ cout<<\\, \ case varsym:fout <<\ cout<<\ case procsym:fout <<\ cout<<\\, \ default :break; }
.\\
}
int getch() {
if(cc==ll) { if(fin.eof()) { cout<<\ return -1; } ll=cc=0; fin.getline(line,81); ll=strlen(line); ch=' '; return 0; }
if(cc==0) cout < cout< #define getchdo if(-1==getch()) return -1 //词法分析部分 实验1 int getsym()//读符号 大写字母不要出现 { int i,j,k; //用于循环等辅助计数 while(ch==' '||ch==9||ch==10) ////////////////////////////////////////// { getchdo; } if(ch>='a'&&ch<='z') { k=0; while(ch>='a'&&ch<='z'||ch>='0'&&ch<='9') //名字或保留字以a.z 开头 { if(k .\\ k++; } getchdo; } ID[k]=0; i=0; j=norw; do /* 搜索当前符号是否为保留字 */ { k=(i+j)/2; if(strcmp(ID,word[k])<=0)j=k-1; if(strcmp(ID,word[k])>=0)i=k+1; }while(i<=j); if(i-1>j)sym=wsym[k]; else sym=ident; /* 搜索失败,则是名字或数字 */ } else { if(ch>='0'&&ch<='9') { k=0; num=0; sym=number; do{ ID[k]=ch; num=num*10+ch-'0'; k++; getchdo; }while(ch>='0'&&ch<='9'); if(flg==1) { num=-num; flg=0; } ID[k]=0; k--; if(k>nmax) { // error(30); ; } }