编译原理试题及答案.doc

上传人:rrsccc 文档编号:11046733 上传时间:2021-06-21 格式:DOC 页数:141 大小:2.02MB
返回 下载 相关 举报
编译原理试题及答案.doc_第1页
第1页 / 共141页
编译原理试题及答案.doc_第2页
第2页 / 共141页
编译原理试题及答案.doc_第3页
第3页 / 共141页
编译原理试题及答案.doc_第4页
第4页 / 共141页
编译原理试题及答案.doc_第5页
第5页 / 共141页
点击查看更多>>
资源描述

《编译原理试题及答案.doc》由会员分享,可在线阅读,更多相关《编译原理试题及答案.doc(141页珍藏版)》请在三一文库上搜索。

1、Delegates, staff: Hello! in the run-up to the Spring Festival, we held one session of four staff representatives Conference 2013-workshop, full back in 2012, careful analysis of the current situation, discuss 2013 development plans. Here, on behalf of my company 2013 work reports to the General Asse

2、mbly, for consideration. Pillar I, 2012 back in 2012, XX power companies adhere to the partys 17 great spirit for guidance, comprehensively implement the scientific concept of development, promoting cost-leadership strategy, standards, focus on implementation, lean management, continuously improve,

3、smooth present safety situation of enterprise management, business management and control scientific and standardized, and the dedication of staff, manage a harmonious and democratic atmosphere of the good situation. Main indicators are as follows:-the battery indicator: power generation totaled 7.8

4、15 billion kWh, beyond the annual budget implementation capacity of 315 million kWh, an increase of 757 million kWh. Sales totaled 7.425 billion kWh, exceeding sales of 330 million kWh the annual Executive budget, an increase of 729 million kWh. -Security measures: unplanned outages 2.5 times. No pe

5、rsonal injury accident occurred, no major accident and above, no major fire accidents without environmental pollution accidents, safety for three consecutive years to maintain stability to good posture. Business financial indicators: total profits of 255 million Yuan, beyond the annual budget of 207

6、 million Yuan, beyond the Datang company index 41.89 million Yuan, an increase of 1.76 million Yuan, FCM assessment at grade four. -Energy: power supply standard coal completing 312.25 g/kWh, down 0.1 g/kWh; integrated auxiliary power consumption ratio in 5.12%, down 0.26%; pollutant emissions perfo

7、rmance greatly reduced compared to last year, carbon 0.09 g/kWh, sulfur dioxide 0.104 g/kWh NOx 0.512 g/kWh; dust removal efficiency of more than 99.8%. -Reliability index: equivalent availability factor in 93.47%, increased 7.95% from a year earlier. Equivalent forced outage rate 0.08%, 0.16% reduc

8、tion over the same period a year earlier. Major achievements: first, we should adhere to the two management system basis, strengthening technological research, strengthen hidden hazards control and intrinsic safety Enterprise construction took new steps. -The two management system for improvement. F

9、ocus on promoting the power of the company management system and the application and implementation of the safety loop five-star management system, improve the safety management system, realize the system of safety control. Further regulate security routines, safety supervision and management networ

10、k role to play to achieve closed-loop. Strengthening the supervision and management of habitual violation of, strengthening the safety supervision of outsourcing contractors. Carried out in spring and autumn of security inspections, flood control and inspection, safety production month, day supervis

11、ion of production safety and the Olympic Games and other编译原理历年试题及答案一 (每项选择 2 分,共 20 分)选择题1将编译程序分成若干个“遍”是为了_b_。a.提高程序的执行效率b.使程序的结构更加清晰c.利用有限的机器内存并提高机器的执行效率d.利用有限的机器内存但降低了机器的执行效率2构造编译程序应掌握_d_。a.源程序 b.目标语言c.编译方法 d.以上三项都是3变量应当 c。a.持有左值 b.持有右值c.既持有左值又持有右值 d.既不持有左值也不持有右值4编译程序绝大多数时间花在_d_上。a.出错处理 b.词法分析c.目标

12、代码生成 d.管理表格5词法分析器的输出结果是_c_。a.单词的种别编码 b.单词在符号表中的位置c.单词的种别编码和自身值 d.单词自身值6正规式 MI 和 M2 等价是指_c_。a. MI 和 M2 的状态数相等 b.Ml 和 M2 的有向弧条数相等。C.M1 和 M2 所识别的语言集相等 d. Ml 和 M2 状态数和有向弧条数相等7中间代码生成时所依据的是c。a语法规则 b词法规则 c语义规则 d等价变换规则8后缀式 ab+cd+/可用表达式_b_来表示。a a+b/c+d b (a+b)/(c+d) c a+b/(c+d) d a+b+c/d9程序所需的数据空间在程序运行前就可确定,

13、称为_c_管理技术。a.动态存储 b.栈式存储 c.静态存储 d.堆式存储10.堆式动态分配申请和释放存储空间遵守_d_原则。a.先请先放 b.先请后放 c.后请先放 d.任意二(每小题 10 分,共 80 分)简答题1.画出编译程序的总体结构图,简述各部分的主要功能。2. 已知文法 GE:EET+|T TTF* | F FF | a试证:FF*是文法的句型,指出该句型的短语、简单短语和句柄.3为正规式(a|b) *a(a|b)构造一个确定的有限自动机。4 设文法 G(S):S(L)|a S|aLL,S|S(1) 消除左递归和回溯;activities, comprehensive and t

14、amping Safety Foundation . Troubleshooting, management mechanism, give full play to role of technical supervision and realization of troubleshooting, management, improved process management. This year completed the boiler lower header leakage, boiler pressure, a major risk management, completed 29 o

15、f great risks and 3 General problems of governance. Complete chemistry lab construction, thermal control, and complete the boiler scale integrated management, host shafting vibration of 10 scientific and technological projects, such as. Complete supercritical 630MW on-line simulation system developm

16、ent and application of circulating water MCC standby power transformation, the transformation of desulfurization waste water, the unit water supply system of comprehensive treatment and discharge valve modification of coal mill 5 key technological transformation projects, group health is improved. -

17、Science and technology innovation is further increased. Strengthen the characteristics of supercritical unit major issues, gradually clearing the particularity of supercritical unit and regularity. Developed motor oil time management, switch action times, statistics, coal-aided measurement software,

18、 improves the production level of lean management. Increased investment in science and technology, reporting science and technology projects and 14 technical project total cost percentage of the total annual production output of 0.25%. Large-scale coal-fired power plant flue gas desulfurization, den

19、itrification complete development and application of key technologies project, won the national science and technology progress second prize. 630MW supercritical units optimized control strategies and the 630MW development and application of on-line simulation system for supercritical units, supercr

20、itical 600MW units of turbine driven boiler feed pump set of comprehensive treatment of defects Datang technology respectively one or two and third. Meanwhile, information technology achievements, the company was named China power information technology benchmarking enterprises. -Repair and maintena

21、nce has improved further. Modify the inspection standards and standards on a regular basis, standardizing work procedures, checking and inspection project. Deepening the BFS+ system, and implements maintenance information shared. Reorganizing RB logic again, and ensure the success of the RB. Innovat

22、ing the mechanism of maintenance management, implemented a project manager system. Successful completion of two autonomous maintenance, reliability improved steadily. Implementing two c-level maintenance, project themselves 48.7% and 42.3%, respectively. Accomplish two circulating pumps repair and o

23、verhaul of four Mills, maintenance teams to get exercise. Promote the work of energy saving and consumption reducing, complete the unit energy consumption diagnosis, plant water balance test, 10 energy-saving projects. Second, we should adhere to three on the economic benefits of improving, outreach

24、(2) 计算每个非终结符的 FIRST 和 FOLLOW;(3) 构造预测分析表。5 已知文法A-aAd| aAb|判断该文法是否 SLR(1)文法,若是构造相应分析表,并对输入串 ab#给出分析过程。6 构造算符文法 GH的算符优先关系(含)。GH:HH;M|MMd|aHb7已构造出文法 G(S)(1)S BB(2)B aB(3)B b1)。给出 DFA 图2).给出 LR 分析表3)假定输入串为 abaab,请给出 LR 分析过程(即状态,符号,输入串的变化过程)。8 将下面的语句翻译成四元式序列:while ACBA (1) A-aAd (2)A- aAb (3)A-(2)构造识别活前缀

25、的 DFAFOLLOW(A)=d,b,#对于状态 I0:FOLLOW(A)a=对于状态 I1:FOLLOW(A)a=因为,在 DFA 中无冲突的现象,所以该文法是 SLR(1)文法。(3)SLR(1)分析表状态 ACTION GOTOa B d # A0 S2 r3 r3 r3 11 acc2 S2 r3 r3 r3 33 S5 S44 r1 r1 r15 r2 r2 r2(4)串 ab#的分析过程步骤 状态栈 符号栈 当前字符 剩余字符串 动作1 0 # a b# 移进2 02 #a b # 归约 A-3 023 #aA b # 移进4 0235 #aAb # 归约 A- aAb5 01 #

26、A # 接受6 【解答】由 Md 和 Ma得:FIRSTVT(M)=d,a;由 H-H;得:FIRSTVT(H)=;由 HM 得:FIRSTVT(M) cFIRSTVT(H),即 FIRSTVT(H)=;,d,a由 Md 和 Mb 得:LASTVT(M)=d,b;由 H-,;m 得:LASTVT(H)=;由 HM 得:LASTVT(M)cLASTVT(H),即 LASTVT(H)=;,d,b对文法开始符 H,有#H#存在,即有=,#,也即;,#d. #, b#。对形如 Pab,或 PaQb,有 a=b,由 Ma|b 得:a=b;对形如 PaR,而 bFIRSTVT(R),有 ab。由 H;M

27、得:;FIRSTVT(M),即:d,:a由 MaH得:aFIRSTVT(H),即:a;,a;,即:;,d;,b;由 MHb 得:LASTVT(H)b,即:;b,db,bb由此得到算符优先关系表,见表 3.5。7 【解答】(1)LR 分析表如下:(2)分析表状态 ACTION GOTOa b # S B0 s3 s4 1 21 acc2 S3 S4 53 s3 s4 64 r3 r35 R1 R1 r16 R2 R2 R2(3) 句子 abaab 的分析过程表:句子 abaab 的分析过程步骤 状态 符号栈 输入串 所得产生式0 #0 # abaad#1 #03 #a baad#2 #034 #

28、ab aab# Bb3 #036 #aB aab# BaB4 #02 #B aab#5 #023 #Ba ab#6 #0233 #Baa b#7 #02334 #Baab #8 #02336 #BaaB #9 #0236 #BaB ad#10 #025 #BB ad#11 #01 #S d#12 # # d#13 识别成功8 【解答】该语句的四元式序列如下(其中 E1、E2 和 E3 分别对应:ACBD, A=1 和 AD 并且关系运算符优先级高):100 (j,A,C,102)101(j,_,_,113) /*E1 为 F*/102 (j2,4-3(3)求出流图中的循环:回边 5-2 对应的

29、循环:2、5、3、4;回边 4-3 对应的循环:3、4编译原理模拟试题一一、是非题(请在括号内,正确的划,错误的划)(每个 2 分,共 20 分)1计算机高级语言翻译成低级语言只有解释一种方式。()2在编译中进行语法检查的目的是为了发现程序中所有错误。()3甲机上的某编译程序在乙机上能直接使用的必要条件是甲机和乙机的操作系统功能完全相同。 ( )4正则文法其产生式为 A-a , A-Bb, A,BVN , a 、 bVT 。 ()5每个文法都能改写为 LL(1) 文法。 ()6递归下降法允许任一非终极符是直接左递归的。 ()7算符优先关系表不一定存在对应的优先函数。 ()8自底而上语法分析方法

30、的主要问题是候选式的选择。 ()9LR 法是自顶向下语法分析方法。 ()10简单优先文法允许任意两个产生式具有相同右部。 ()二、选择题(请在前括号内选择最确切的一项作为答案划一个勾,多划按错论)(每个 4 分,共 40 分)1 一个编译程序中,不仅包含词法分析,_,中间代码生成,代码优化,目标代码生成等五个部分。A( ) 语法分析 B( )文法分析 C( )语言分析 D( )解释分析2 词法分析器用于识别_。A( ) 字符串 B( )语句 C( )单词 D( )标识符3 语法分析器则可以发现源程序中的_。A( ) 语义错误 B( ) 语法和语义错误C( ) 错误并校正 D( ) 语法错误4

31、下面关于解释程序的描述正确的是_。(1) 解释程序的特点是处理程序时不产生目标代码(2) 解释程序适用于 COBOL 和 FORTRAN 语言(3) 解释程序是为打开编译程序技术的僵局而开发的A( ) (1)(2) B( ) (1) C( ) (1)(2)(3) D( ) (2)(3)5 解释程序处理语言时 , 大多数采用的是_方法。A( ) 源程序命令被逐个直接解释执行B( ) 先将源程序转化为中间代码 , 再解释执行C( ) 先将源程序解释转化为目标程序 , 再执行D( ) 以上方法都可以6 编译过程中 , 语法分析器的任务就是_。(1) 分析单词是怎样构成的 (2) 分析单词串是如何构成

32、语句和说明的(3) 分析语句和说明是如何构成程序的 (4) 分析程序的结构A( ) (2)(3) B( ) (2)(3)(4)C( ) (1)(2)(3) D( ) (1)(2)(3)(4)7 编译程序是一种_。A. ( ) 汇编程序 B( ) 翻译程序 C( ) 解释程序 D( ) 目标程序8 文法 G 所描述的语言是_的集合。A. ( ) 文法 G 的字母表 V 中所有符号组成的符号串B( ) 文法 G 的字母表 V 的闭包 V* 中的所有符号串C( ) 由文法的开始符号推出的所有终极符串D. ( ) 由文法的开始符号推出的所有符号串9 文法分为四种类型,即 0 型、1 型、2 型、3 型

33、。其中 3 型文法是_。A. ( ) 短语文法 B( ) 正则文法 C( ) 上下文有关文法 D( ) 上下文无关文法10 一个上下文无关文法 G 包括四个组成部分,它们是:一组非终结符号,一组终结符号,一个开始符号,以及一组 _。A( ) 句子 B( ) 句型 C( ) 单词 D( ) 产生式三、填空题(每空 1 分,共 10 分)1编译程序的工作过程一般可以划分为词法分析,语法分析,语义分析,中间代码生成,代码优化等几个基本阶段,同时还会伴有_表格处理_和 _出错处理_。2若源程序是用高级语言编写的,_目标程序_是机器语言程序或汇编程序,则其翻译程序称为 _编译程序_ 。3编译方式与解释方

34、式的根本区别在于_是否生成目标代码_。4对编译程序而言,输入数据是_源程序_, 输出结果是_目标程序_。5产生式是用于定义_语法成分_的一种书写规则。6语法分析最常用的两类方法是_自上而下_和_自下而上_分析法。四、简答题(20 分)1. 什么是句子? 什么是语言 ?答:(1)设 G 是一个给定的文法,S 是文法的开始符号,如果 S x(其中 xVT*),则称 x 是文法的一个句子。(2)设 GS是给定文法,则由文法 G 所定义的语言 L(G)可描述为: L(G)xS x,xVT* 。2. 写一文法,使其语言是偶正整数的集合,要求:(1)允许 0 打头;(2) 不允许 0 打头。解:(1)GS

35、=(S,P,D,N,0,1,2,9,P,S)P:S-PD|DP-NP|ND-0|2|4|6|8N-0|1|2|3|4|5|6|7|8|9(2)GS=(S,P,R,D,N,Q ,0,1,2,9,P,S)P:S-PD|P0|DP-NR|NR-QR|QD-2|4|6|8N-1|2|3|4|5|6|7|8|9Q-0|1|2|3|4|5|6|7|8|93. 已知文法 GE 为:ET|E+T|E-TTF|T*F|T/FF ( E ) |i 该文法的开始符号(识别符号)是什么? 请给出该文法的终结符号集合 VT 和非终结符号集合 VN 。 找出句型 T+T*F+i 的所有短语、简单短语和句柄。解: 该文法的

36、开始符号(识别符号)是 E。该文法的终结符号集合 VT=+、-、*、/、(、)、i。 非终结符号集合 VN=E、T、F。句型 T+T*F+I 的短语为 i、T*F、第一个 T、T+T*F+i; 简单短语为 i、T*F、第一个 T;句柄为第一个 T。4. 构造正规式相应的 NFA : 1(0|1)*101解 1(0|1)*101 对 应 的 NFA 为5. 写出表达式(ab*c)/(ab)d 的逆波兰表示和三元式序列。逆波兰表示: abc*ab/d三元式序列: (*,b,c) (,a,) (,a,b) (/,) (,d)五.计算题(10 分)构造下述文法 GS 的自动机: S-A0 A-A0|S1|0该自动机是确定的吗?若不确定,则对它确定化。解:由于该文法的产生式 S-A0,A-A0|S1 中没有字符集 VT 的输入,所以不是确定的自动机。 要将其他确定化,必须先用代入法得到它对应的正规式。把 S?A0 代入产生式 A?S1有:A=A0|A01|0=A(0|01)|0=0(0|01)*。 代入 S-A0 有该文法的正规式:0(0|01)*0,所以,改写该文法为确定的自动机为:由于状态 A 有 3 次输入 0 的重复输入,所以上图只是 NFA,下面将它确定化:下 表 由 子

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1