return(es); }
//
//
while (strcmp(token,\ { es=declaration_stat(); if (es>0) return(es); }
return(es);
}//
int declaration_stat() { int es=0;
fscanf(fp,\ if (strcmp(token,\不是标识符 es=name_def(token1);//插入符号表 if (es>0) return(es);
fscanf(fp,\ if (strcmp(token,\
fscanf(fp,\return(es); }
//
while (strcmp(token,\ { es=statement(); if (es>0) return(es); }
return(es); }
//
if (es==0 && strcmp(token,\语句>
if (es==0 && strcmp(token,\语句> if (es==0 && strcmp(token,\语句> if (es==0 && strcmp(token,\语句> if (es==0 && strcmp(token,\语句>
11
if (es==0 && strcmp(token,\语句> if (es==0 && strcmp(token,\复合语句> if (es==0 && (strcmp(token,\es=expression_stat();//<表达式语句> return(es); }
//
if (
@BRF↑label1 :输出 BRF label1, @BR↑label2:输出 BR label2,
@SETlabel↓label1:设置标号label1 @SETlabel↓label2:设置标号label2 */ int if_stat(){
int es=0,label1,label2; //if
fscanf(fp,\ printf(\
if (strcmp(token,\少左括号 fscanf(fp,\ printf(\ es=expression();
if (es>0) return(es);
if (strcmp(token,\少右括号
label1=labelp++;//用label1记住条件为假时要转向的标号
fprintf(fout,\输出假转移指令 fscanf(fp,\ printf(\ es=statement();
if (es>0) return(es);
label2=labelp++;//用label2记住要转向的标号
fprintf(fout,\输出无条件转移指令 fprintf(fout,\设置label1记住的标号 if (strcmp(token,\部分处理 { fscanf(fp,\ printf(\ es=statement();
if (es>0) return(es); }
fprintf(fout,\设置label2记住的标号 return(es); }
//
12
//
// @BRF↑label2@BR↑label1@SETlabel↓label2 //动作解释如下:
//@SETlabel↑label1:设置标号label1 //@BRF↑label2 :输出 BRF label2, //@BR↓label1:输出 BR label1,
//@SETlabel↓label2:设置标号label2 int do_stat(){
int es,label1,label2; es=0;
label1=labelp++;
fprintf(fout,\设置label1标号 fscanf(fp,\ printf(\ es=statement();
if (es>0) return(es);
fscanf(fp,\ printf(\
if(strcmp(token,\部分 { fscanf(fp,\ printf(\
if (strcmp(token,\少左括号 fscanf(fp,\ printf(\ es=expression();
if (es>0) return(es);
if (strcmp(token,\少右括号 } else
printf(\缺少while\ label2=labelp++;
fscanf(fp,\ printf(\ return(es); }
//
//
//@SETlabel↑label1:设置标号label1 //@BRF↑label2 :输出 BRF label2, //@BR↓label1:输出 BR label1,
//@SETlabel↓label2:设置标号label2 int while_stat()
13
{ int es=0,label1,label2; label1=labelp++;
fprintf(fout,\设置label1标号 fscanf(fp,\ printf(\
if (strcmp(token,\少左括号 fscanf(fp,\ printf(\ es=expression();
if (es>0) return(es);
if (strcmp(token,\少右括号 label2=labelp++;
fscanf(fp,\ printf(\ es=statement();
if (es>0) return(es);
fscanf(fp,\ printf(\ return(es); }
//
@SETlabel↑label1< expression >@BRF↑label2@BR↑label3; @SETlabel↑label4 < expression >@BR↓label1)
@SETlabel↓label3 <语句 >@BR↓label4@SETlabel↓label2 动作解释:
1. @SETlabel↓label1:设置标号label1 2. @BRF↑label2 :输出 BRF label2, 3. @BR↑label3:输出 BR label3,
4. @SETlabel↓label4:设置标号label4 5. @BR↑label1:输出 BR label1,
6. @SETlabel↓label3:设置标号label3 7. @BR↑label4:输出 BR label4,
8. @SETlabel↓label2:设置标号label2 int for_stat()
{ int es=0,label1,label2,label3,label4; fscanf(fp,\ printf(\
if (strcmp(token,\少左括号 fscanf(fp,\ printf(\ es=expression();
if (es>0) return(es);
if (strcmp(token,\少分号
14
label1=labelp++;
fprintf(fout,\设置label1标号 fscanf(fp,\ printf(\ es=expression();
if (es>0) return(es); label2=labelp++;
fprintf(fout,\输出假条件转移指令 label3=labelp++;
fprintf(fout,\输出无条件转移指令 if (strcmp(token,\少分号 label4=labelp++;
fprintf(fout,\设置label4标号 fscanf(fp,\ printf(\ es=expression();
if (es>0) return(es);
fprintf(fout,\输出无条件转移指令 if (strcmp(token,\少右括号 fprintf(fout,\设置label3标号 fscanf(fp,\ printf(\ es=statement();
if (es>0) return(es);
fprintf(fout,\输出无条件转移指令 fprintf(fout,\设置label2标号 return(es);}
//
//
//@ OUT:输出 OUT int write_stat()
{ int es=0;fscanf(fp,\ printf(\
es=expression(); if (es>0)return(es);
if (strcmp(token,\少分号 fprintf(fout,\输出指令 fscanf(fp,\ printf(\ return(es);}
//
//
//@LOOK↓n↑d:查符号表n,给出变量地址d; 没有,变量没定义
15
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库简单编译器的设计与实现1(3)在线全文阅读。
相关推荐: