北京印刷学院编译原理课程设计实验报告.pdf
《北京印刷学院编译原理课程设计实验报告.pdf》由会员分享,可在线阅读,更多相关《北京印刷学院编译原理课程设计实验报告.pdf(42页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、黑龙江大学黑龙江大学编译课程设计文档编译课程设计文档学号 20092612 姓名 张冰一 编译器的实现方式编译器的实现方式Microsoft Visual C+ 6.0利用 SLR(1)的分析方式进行语法分析二 编译器功能介绍编译器功能介绍首先将非终结符输入(以#结束输入) 。然后输入终结符(以#结束输入) 。输入文法,例如 E (i)(用空格代替 - ,以#结束输入文法) 。语法分析中可识别:while 语句,for 语句,if、else 语句。可识别数组,赋值运算,逻辑和赋值判断,+-*/运算。可将 while 语句和 if、else 语句翻译成四元式。可将源程序翻译为汇编程序。三 测试用
2、例与实验结果测试用例与实验结果测试用的源程序:void main()int i,j;if( i 100 & i 20)a = b + (c - 3*q) / h;elsewhile(i10)a = a + b;语法分析所用的语法:/*c=chart=intf=floatd=doubleo=ifu=elseh=forw=while*/生成的 FIRST 集:FIRST(A)(ieFIRST(B)!&|FIRST(E)(ieFIRST(F)(ieFIRST(K)iohwctfd(eFIRST(M)vFIRST(P)vFIRST(Q)ctfdFIRST(T)(ieFIRST(U)ctfdFIRST(
3、V)iFIRST(W)=FIRST(Z)*生成的 FOLLOW 集:FOLLOW(A);,)!&|(ie+-*/FOLLOW(B)(ieFOLLOW(E);,)!&|(ie+-FOLLOW(F);,)!&|(ie+-*/FOLLOW(K)FOLLOW(M)#FOLLOW(P)#FOLLOW(Q)iohwctfd(eFOLLOW(T);FOLLOW(U)*iFOLLOW(V);FOLLOW(W);,FOLLOW(Z)iLR(0)项目规范族如下:I0M - PP - vm()QKI1M - PI2P - vm()QKI3P - vm()QKI4P - vm()QKI5P - vm()QKI6P -
4、 vm()QKQ - UZV;U - cU - tU - fU - dI7P - vm()QKK - i=E;KK - EK - o(T)KuKKK - h(i=E;T;i=E)KKK - w(T)KKK - QKK - E - E+AE - E-AE - AQ - UZV;A- A*FA- A/FA- FU - cU - tU - fU - dF - (E)F - iF - eI8Q - UZV;Z - *Z - I9U - cI10U - tI11U - fI12U - dI13P - vm()QKI14K - i=E;KF - iI15K - EE - E+AE - E-AI16K -
5、o(T)KuKKI17K - h(i=E;T;i=E)KKI18K - w(T)KKI19K - QKK - i=E;KK - EK - o(T)KuKKK - h(i=E;T;i=E)KKK - w(T)KKK - QKK - E - E+AE - E-AE - AQ - UZV;A- A*FA- A/FA- FU - cU - tU - fU - dF - (E)F - iF - eI20E -AA-A*FA-A/FI21A- FI22F - (E)E - E+AE - E-AE - AA- A*FA- A/FA- FF - (E)F - iF - eI23F - eI24Q - UZV;
6、V - iWV - iW,ZVI25Z - *I26P - vm()QKI27K - i=E;KE - E+AE - E-AE - AA- A*FA- A/FA- FF - (E)F - iF - eI28E - E+AA- A*FA- A/FA- FF - (E)F - iF - eI29E - E-AA- A*FA- A/FA- FF - (E)F - iF - eI30K - o(T)KuKKT - EBTT - EE - E+AE - E-AE - AA- A*FA- A/FA- FF - (E)F - iF - eI31K - h(i=E;T;i=E)KKI32K - w(T)KKT
7、 - EBTT - EE - E+AE - E-AE - AA- A*FA- A/FA- FF - (E)F - iF - eI33K - QKI34A-A*FF - (E)F - iF - eI35A-A/FF - (E)F - iF - eI36F - (E)E - E+AE - E-AI37F - iI38Q - UZV;I39V - iWV - iW,ZVW - EW - =EW - I40K - i=E;KE - E+AE - E-AI41E - E+AA-A*FA-A/FI42E - E-AA-A*FA-A/FI43K - o(T)KuKKI44T - EBTT - EE - E+
8、AE - E-AB - B - B - =B - !=B - &B - |B - I45K - h(i=E;T;i=E)KKI46K - w(T)KKI47A-A*FI48A-A/FI49F - (E)I50Q - UZV;I51V - iWV - iW,ZVI52W - EE - E+AE - E-AE - AA- A*FA- A/FA- FF - (E)F - iF - eI53W - =EE - E+AE - E-AE - AA- A*FA- A/FA- FF - (E)F - iF - eI54K - i=E;KK - i=E;KK - EK - o(T)KuKKK - h(i=E;T
9、;i=E)KKK - w(T)KKK - QKK - E - E+AE - E-AE - AQ - UZV;A- A*FA- A/FA- FU - cU - tU - fU - dF - (E)F - iF - eI55K - o(T)KuKKI56T - EBTT - EBTT - EE - E+AE - E-AE - AA- A*FA- A/FA- FF - (E)F - iF - eI57B - B - =I59B - I60B - !=I61B - &I62B - |I63K - h(i=E;T;i=E)KKE - E+AE - E-AE - AA- A*FA- A/FA- FF -
10、(E)F - iF - eI64K - w(T)KKI65V - iW,ZVZ - *Z - I66W - EE - E+AE - E-AI67W - =EE - E+AE - E-AI68K - i=E;KI69K - o(T)KuKKK - i=E;KK - EK - o(T)KuKKK - h(i=E;T;i=E)KKK - w(T)KKK - QKK - E - E+AE - E-AE - AQ - UZV;A- A*FA- A/FA- FU - cU - tU - fU - dF - (E)F - iF - eI70T - EBTI71B - =I73B - !=I74B - &I7
11、5B - |I76K - h(i=E;T;i=E)KKE - E+AE - E-AI77K - w(T)KKK - i=E;KK - EK - o(T)KuKKK - h(i=E;T;i=E)KKK - w(T)KKK - QKK - E - E+AE - E-AE - AQ - UZV;A- A*FA- A/FA- FU - cU - tU - fU - dF - (E)F - iF - eI78V - iW,ZVV - iWV - iW,ZVI79W - EI80K - o(T)KuKKI81K - h(i=E;T;i=E)KKT - EBTT - EE - E+AE - E-AE - A
12、A- A*FA- A/FA- FF - (E)F - iF - eI82K - w(T)KKI83V - iW,ZVI84K - o(T)KuKKI85K - h(i=E;T;i=E)KKI86K - w(T)KKK - i=E;KK - EK - o(T)KuKKK - h(i=E;T;i=E)KKK - w(T)KKK - QKK - E - E+AE - E-AE - AQ - UZV;A- A*FA- A/FA- FU - cU - tU - fU - dF - (E)F - iF - eI87K - o(T)KuKKI88K - h(i=E;T;i=E)KKI89K - w(T)KK
13、I90K - o(T)KuKKK - i=E;KK - EK - o(T)KuKKK - h(i=E;T;i=E)KKK - w(T)KKK - QKK - E - E+AE - E-AE - AQ - UZV;A- A*FA- A/FA- FU - cU - tU - fU - dF - (E)F - iF - eI91K - h(i=E;T;i=E)KKI92K - o(T)KuKKI93K - h(i=E;T;i=E)KKE - E+AE - E-AE - AA- A*FA- A/FA- FF - (E)F - iF - eI94K - o(T)KuKKK - i=E;KK - EK -
14、 o(T)KuKKK - h(i=E;T;i=E)KKK - w(T)KKK - QKK - E - E+AE - E-AE - AQ - UZV;A- A*FA- A/FA- FU - cU - tU - fU - dF - (E)F - iF - eI95K - h(i=E;T;i=E)KKE - E+AE - E-AI96K - o(T)KuKKI97K - h(i=E;T;i=E)KKI98K - h(i=E;T;i=E)KKK - i=E;KK - EK - o(T)KuKKK - h(i=E;T;i=E)KKK - w(T)KKK - QKK - E - E+AE - E-AE -
15、 AQ - UZV;A- A*FA- A/FA- FU - cU - tU - fU - dF - (E)F - iF - eI99K - h(i=E;T;i=E)KKI100K - h(i=E;T;i=E)KKK - i=E;KK - EK - o(T)KuKKK - h(i=E;T;i=E)KKK - w(T)KKK - QKK - E - E+AE - E-AE - AQ - UZV;A- A*FA- A/FA- FU - cU - tU - fU - dF - (E)F - iF - eI101K - h(i=E;T;i=E)KKGO 函数:GO(I0,P)=I1GO(I0,v)=I2
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 北京 印刷 学院 编译 原理 课程设计 实验 报告
限制150内