欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    北京印刷学院编译原理课程设计实验报告.pdf

    • 资源ID:36108956       资源大小:1.83MB        全文页数:42页
    • 资源格式: PDF        下载积分:20金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要20金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    北京印刷学院编译原理课程设计实验报告.pdf

    黑龙江大学黑龙江大学编译课程设计文档编译课程设计文档学号 20092612 姓名 张冰一 编译器的实现方式编译器的实现方式Microsoft Visual C+ 6.0利用 SLR(1)的分析方式进行语法分析二 编译器功能介绍编译器功能介绍首先将非终结符输入(以#结束输入) 。然后输入终结符(以#结束输入) 。输入文法,例如 E (i)(用空格代替 - ,以#结束输入文法) 。语法分析中可识别:while 语句,for 语句,if、else 语句。可识别数组,赋值运算,逻辑和赋值判断,+-*/运算。可将 while 语句和 if、else 语句翻译成四元式。可将源程序翻译为汇编程序。三 测试用例与实验结果测试用例与实验结果测试用的源程序: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(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 - 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 - 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;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 - 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+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;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 - (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 - &I75B - |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 - AA- 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)KKI90K - 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 - 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 - 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)=I2GO(I2,m)=I3GO(I3,()=I4GO(I4,)=I5GO(I5,)=I6GO(I6,Q)=I7GO(I6,U)=I8GO(I6,c)=I9GO(I6,t)=I10GO(I6,f)=I11GO(I6,d)=I12GO(I7,U)=I8GO(I7,c)=I9GO(I7,t)=I10GO(I7,f)=I11GO(I7,d)=I12GO(I7,K)=I13GO(I7,i)=I14GO(I7,E)=I15GO(I7,o)=I16GO(I7,h)=I17GO(I7,w)=I18GO(I7,Q)=I19GO(I7,A)=I20GO(I7,F)=I21GO(I7,()=I22GO(I7,e)=I23GO(I8,Z)=I24GO(I8,*)=I25GO(I13,)=I26GO(I14,=)=I27GO(I15,+)=I28GO(I15,-)=I29GO(I16,()=I30GO(I17,()=I31GO(I18,()=I32GO(I19,U)=I8GO(I19,c)=I9GO(I19,t)=I10GO(I19,f)=I11GO(I19,d)=I12GO(I19,i)=I14GO(I19,E)=I15GO(I19,o)=I16GO(I19,h)=I17GO(I19,w)=I18GO(I19,Q)=I19GO(I19,A)=I20GO(I19,F)=I21GO(I19,()=I22GO(I19,e)=I23GO(I19,K)=I33GO(I20,*)=I34GO(I20,/)=I35GO(I22,A)=I20GO(I22,F)=I21GO(I22,()=I22GO(I22,e)=I23GO(I22,E)=I36GO(I22,i)=I37GO(I24,V)=I38GO(I24,i)=I39GO(I27,A)=I20GO(I27,F)=I21GO(I27,()=I22GO(I27,e)=I23GO(I27,i)=I37GO(I27,E)=I40GO(I28,F)=I21GO(I28,()=I22GO(I28,e)=I23GO(I28,i)=I37GO(I28,A)=I41GO(I29,F)=I21GO(I29,()=I22GO(I29,e)=I23GO(I29,i)=I37GO(I29,A)=I42GO(I30,A)=I20GO(I30,F)=I21GO(I30,()=I22GO(I30,e)=I23GO(I30,i)=I37GO(I30,T)=I43GO(I30,E)=I44GO(I31,i)=I45GO(I32,A)=I20GO(I32,F)=I21GO(I32,()=I22GO(I32,e)=I23GO(I32,i)=I37GO(I32,E)=I44GO(I32,T)=I46GO(I34,()=I22GO(I34,e)=I23GO(I34,i)=I37GO(I34,F)=I47GO(I35,()=I22GO(I35,e)=I23GO(I35,i)=I37GO(I35,F)=I48GO(I36,+)=I28GO(I36,-)=I29GO(I36,)=I49GO(I38,;)=I50GO(I39,W)=I51GO(I39,)=I52GO(I39,=)=I53GO(I40,+)=I28GO(I40,-)=I29GO(I40,;)=I54GO(I41,*)=I34GO(I41,/)=I35GO(I42,*)=I34GO(I42,/)=I35GO(I43,)=I55GO(I44,+)=I28GO(I44,-)=I29GO(I44,B)=I56GO(I44,)=I58GO(I44,)=I59GO(I44,!)=I60GO(I44,&)=I61GO(I44,|)=I62GO(I45,=)=I63GO(I46,)=I64GO(I51,)=I65GO(I52,A)=I20GO(I52,F)=I21GO(I52,()=I22GO(I52,e)=I23GO(I52,i)=I37GO(I52,E)=I66GO(I53,A)=I20GO(I53,F)=I21GO(I53,()=I22GO(I53,e)=I23GO(I53,i)=I37GO(I53,E)=I67GO(I54,U)=I8GO(I54,c)=I9GO(I54,t)=I10GO(I54,f)=I11GO(I54,d)=I12GO(I54,i)=I14GO(I54,E)=I15GO(I54,o)=I16GO(I54,h)=I17GO(I54,w)=I18GO(I54,Q)=I19GO(I54,A)=I20GO(I54,F)=I21GO(I54,()=I22GO(I54,e)=I23GO(I54,K)=I68GO(I55,)=I69GO(I56,A)=I20GO(I56,F)=I21GO(I56,()=I22GO(I56,e)=I23GO(I56,i)=I37GO(I56,E)=I44GO(I56,T)=I70GO(I57,=)=I71GO(I58,=)=I72GO(I60,=)=I73GO(I61,&)=I74GO(I62,|)=I75GO(I63,A)=I20GO(I63,F)=I21GO(I63,()=I22GO(I63,e)=I23GO(I63,i)=I37GO(I63,E)=I76GO(I64,)=I77GO(I65,*)=I25GO(I65,Z)=I78GO(I66,+)=I28GO(I66,-)=I29GO(I66,)=I79GO(I67,+)=I28GO(I67,-)=I29GO(I69,U)=I8GO(I69,c)=I9GO(I69,t)=I10GO(I69,f)=I11GO(I69,d)=I12GO(I69,i)=I14GO(I69,E)=I15GO(I69,o)=I16GO(I69,h)=I17GO(I69,w)=I18GO(I69,Q)=I19GO(I69,A)=I20GO(I69,F)=I21GO(I69,()=I22GO(I69,e)=I23GO(I69,K)=I80GO(I76,+)=I28GO(I76,-)=I29GO(I76,;)=I81GO(I77,U)=I8GO(I77,c)=I9GO(I77,t)=I10GO(I77,f)=I11GO(I77,d)=I12GO(I77,i)=I14GO(I77,E)=I15GO(I77,o)=I16GO(I77,h)=I17GO(I77,w)=I18GO(I77,Q)=I19GO(I77,A)=I20GO(I77,F)=I21GO(I77,()=I22GO(I77,e)=I23GO(I77,K)=I82GO(I78,i)=I39GO(I78,V)=I83GO(I80,)=I84GO(I81,A)=I20GO(I81,F)=I21GO(I81,()=I22GO(I81,e)=I23GO(I81,i)=I37GO(I81,E)=I44GO(I81,T)=I85GO(I82,)=I86GO(I84,u)=I87GO(I85,;)=I88GO(I86,U)=I8GO(I86,c)=I9GO(I86,t)=I10GO(I86,f)=I11GO(I86,d)=I12GO(I86,i)=I14GO(I86,E)=I15GO(I86,o)=I16GO(I86,h)=I17GO(I86,w)=I18GO(I86,Q)=I19GO(I86,A)=I20GO(I86,F)=I21GO(I86,()=I22GO(I86,e)=I23GO(I86,K)=I89GO(I87,)=I90GO(I88,i)=I91GO(I90,U)=I8GO(I90,c)=I9GO(I90,t)=I10GO(I90,f)=I11GO(I90,d)=I12GO(I90,i)=I14GO(I90,E)=I15GO(I90,o)=I16GO(I90,h)=I17GO(I90,w)=I18GO(I90,Q)=I19GO(I90,A)=I20GO(I90,F)=I21GO(I90,()=I22GO(I90,e)=I23GO(I90,K)=I92GO(I91,=)=I93GO(I92,)=I94GO(I93,A)=I20GO(I93,F)=I21GO(I93,()=I22GO(I93,e)=I23GO(I93,i)=I37GO(I93,E)=I95GO(I94,U)=I8GO(I94,c)=I9GO(I94,t)=I10GO(I94,f)=I11GO(I94,d)=I12GO(I94,i)=I14GO(I94,E)=I15GO(I94,o)=I16GO(I94,h)=I17GO(I94,w)=I18GO(I94,Q)=I19GO(I94,A)=I20GO(I94,F)=I21GO(I94,()=I22GO(I94,e)=I23GO(I94,K)=I96GO(I95,+)=I28GO(I95,-)=I29GO(I95,)=I97GO(I97,)=I98GO(I98,U)=I8GO(I98,c)=I9GO(I98,t)=I10GO(I98,f)=I11GO(I98,d)=I12GO(I98,i)=I14GO(I98,E)=I15GO(I98,o)=I16GO(I98,h)=I17GO(I98,w)=I18GO(I98,Q)=I19GO(I98,A)=I20GO(I98,F)=I21GO(I98,()=I22GO(I98,e)=I23GO(I98,K)=I99GO(I99,)=I100GO(I100,U)=I8GO(I100,c)=I9GO(I100,t)=I10GO(I100,f)=I11GO(I100,d)=I12GO(I100,i)=I14GO(I100,E)=I15GO(I100,o)=I16GO(I100,h)=I17GO(I100,w)=I18GO(I100,Q)=I19GO(I100,A)=I20GO(I100,F)=I21GO(I100,()=I22GO(I100,e)=I23GO(I100,K)=I101四 编译器算法实现编译器算法实现正文(小四)分析表及说明,每个模块的流程图。词法分析流程图:五 关键技术关键技术cifa.hanalysis()函数是词法分析的函数,通过将“源文件.c”中的字符逐一读入进行分析,将分析结果分别写入三个文件当中:编码文件.txt、常数.txt、标识符.txt 。cal.hChange()函数是将源程序中需要进行运算的表达式转换为逆波兰式。Cal()函数是对转换完成的逆波兰式进行计算。实验 8.cppGrammer 中存放分析输入流所用的文法。getFIRST()函数用于计算每个非终结符的 FIRST 集合。getFOLLOW()函数用于计算每个非终结符的 FOLLOW 集合。getSELECT()函数用于计算每个文法的 SELECT 集合。getCLOSURE()函数用于生成项目集规范族,先将 I0 计算出,然后根据 I0逐步扩展项目集。生成四元式是通过递归回填的方式将四元式第四项的地址填入。huibian()函数是用于生成汇编程序的函数。六 总结总结本程序的语法分析中可对数组、指针进行识别,可对 for、if else、while 语句进行分析、可对逻辑判断语句进程分析。所用文法覆盖的范围比较广。但在生成四元式中无法对 for 语句进行分析判断。七 参考文献参考文献编译原理(第 2 版)

    注意事项

    本文(北京印刷学院编译原理课程设计实验报告.pdf)为本站会员(叶***)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开