编译器源代码

上传人:工**** 文档编号:494322738 上传时间:2023-06-29 格式:DOCX 页数:22 大小:25.23KB
返回 下载 相关 举报
编译器源代码_第1页
第1页 / 共22页
编译器源代码_第2页
第2页 / 共22页
编译器源代码_第3页
第3页 / 共22页
编译器源代码_第4页
第4页 / 共22页
编译器源代码_第5页
第5页 / 共22页
点击查看更多>>
资源描述

《编译器源代码》由会员分享,可在线阅读,更多相关《编译器源代码(22页珍藏版)》请在金锄头文库上搜索。

1、#include stdio.h#include string.h”#define ACC -2/mmmmmm*/#define sy_if0#define sy_then1#define sy_else2#define sy_while3#define sy_begin4#define sy_do5#define sy_end6#define a7#define semicolon8#define e9#define jinghao10#define S11#define L12#define tempsy15#define EA18#define E019#define plus34#de

2、fine times36#define becomes38#define op_and39#define op_or40#define op_not41#define rop42#define lparent48#define rparent49#define ident56#define intconst57/mmmmmmm*/ char ch=0;int count=0;static char spelling10=;static char line81=;char *pline;static char ntab110010;struct ntabint tc;int fc;ntab220

3、0;int label=0;struct rwordschar sp10;int sy;;struct rwords reswords10=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 aaint sy1;int pos;buf1000,n,n1,E,sstack100,ibuf100,stack1000;struct aa oth;struct fourexpchar op10;s

4、truct aa arg1;struct aa arg2;int result;fexp200;int ssp=0;struct aa *pbuf=buf;int nlength=0;int lnum=0;int tt1=0;FILE *cfile;/mmmmmmmmm*/ int newt=0;int nxq=100;int Ir;int lr1;int sp=0;int stack1100;int sp1=0;int num=0;struct llint nxq1;int tc1;int fc1;labelmark10;int labeltemp10;int pointmark=-1,po

5、inttemp=-1;int sign=0;/*IDdOiapALR-dibii大大大大大大大大大大大大大大大大大大大大static int action1913=2,-1,-1,3,4,-1,-1,5,-1,-1,10,1,-1,T,T,T,T,T,T,T,T,T,T,ACC,T,T, -1,-1,-1,-1,-1,-1,-1,-1,-1,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,-1,-1,-1, 2,-1,-1,3,4,-1,-1,5,-1,-1,-1,9,8,-1,-1,104,-1,-1,-1,104,-1,104,-1,104,-1,-1, -

6、1,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,12,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,105,-1,13,-1,-1,-1,-1, 2,-1,-1,3,4,-1,-1,5,-1,-1,-1,14,-1,2,-1,-1,3,4,-1,-1,5,-1,-1,-1,15,-1, -1,-1,103,-1,-1,-1,103,-1,103,-1,103,-1,-1,2,-1,-1,3,4,-1,-1,5,-1,-1,-1

7、,9,16, -1,-1,17,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,102,-1,-1,-1,102,-1,102,-1,102,-1,-1, -1,-1,-1,-1,-1,-1,106,-1,-1,-1,-1,-1,-1,2,-1,-1,3,4,-1,-1,5,-1,-1,-1,18,-1,-1,-1,101,-1,-1,-1,101,-1,101,-1,101,-1,-1;大大大大大大大大大大大大大大大大大大大大EaE6iziEpALR-dtbi大大大大大大大大大大大大大大大大大大大大static int action1107=3,T,T,2,T,T,1

8、,-1,4,5,-1,-1,ACC,-1,3,T,T,2,T,T,6,-1,104,104,-1,104,104,-1,3,T,T,2,T,T,7,3,-1,-1,2,-1,-1,8,T,4,5,T,9,T,T,-1,101,5,-1,101,101,-1,-1,102,102,-1,102,102,-1,-1,103,103,-1,103,103,-1;/*2蛔臼士ii它如ALROf。士i*/ static int action21611=1,-1,4,-1,5,-1,-1,-1,13,7,8,-1,2,-1,101,-1,101,101,101,-1,-1,-1,3,-1,-1,-1,-1

9、,-1,-1,-1,-1,-1,-1,-1,-1,-1,102,-1,102,102,102,-1,-1,-1,1,-1,4,-1,5,-1,-1,-1,11,7,8,1,-1,4,-1,5,-1,-1,-1,6,7,8,-1,-1,-1,104,-1,9,10,104,-1,-1,-1,1,-1,4,-1,5,-1,-1,-1,14,7,8,1,-1,4,-1,5,-1,-1,-1,15,7,8,105,-1,105,-1,105,-1,-1,-1,-1,-1,-1,107,-1,107,-1,107,-1,-1,-1,-1,-1,-1,-1,-1,-1,12,-1,9,10,-1,-1,-

10、1,-1,-1,-1,-1,103,-1,103,103,103,-1,-1,-1,-1,-1,-1,-1,-1,9,10,ACC,-1,-1,-1,-1,-1,-1,106,-1,9,10,106,-1,-1,-1,-1,-1,-1,108,-1,9,10,108,-1,-1,-1;/*眼p%KD印如3霁* readline()char chi;pline=line;ch1=fgetc(cfile);while(ch1!=n)&(ch1!=EOF)*pline=ch1;pline+;ch1=fgetc(cfile);*pline=0;pline=line;/*6o3c0%k宜i,OxOG*r

11、eadch()if(ch=0)readline();lnum+;ch=*pline;pline+;/*&它臼。fl。蛔苜xOA它士0*/ find(char spel)int ss1=0;int ii=0;while(ss1=0)&(iinlength)if(!strcmp(spel,ntab1ii)ss1=1;ii+;if(ss1=1)return ii-1;else return -1; identifier() int iii=0,j,k;int ss=0;k=0;dospellingk=ch;k+;readch();while(ch=a)&(ch=z)|(ch=0)&(ch=9);pl

12、ine-;spellingk=0;while(ss=0)&(iii10)if(!strcmp(spelling,reswordsiii.sp)ss=1;iii+;/*10uxQAa*/if(ss=1)bufcount.sy1=reswordsiii-1.sy;elsebufcount.sy1=ident;j=find(spelling);if(j=-1)bufcount.pos=tt1;strcpy(ntab1tt1,spelling);tt1+;nlength+;else bufcount.pos=j;count+;for(k=0;k=0)&(ch=9);bufcount.sy1=intconst;bufcount.pos=ivalue;count+;pline-;/*宜电。%*scan()int i;while(ch!=)switch(ch)case :break;

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 学术论文 > 其它学术论文

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号