




已阅读5页,还剩1页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第 1 页 共 3 页 中 山 大 学 软 件 学 院 2008 级 软 件 工 程 专 业 2011 春季学期 编 译 原 理编 译 原 理 期 末 试 题 试期 末 试 题 试 卷卷 A 参考答案参考答案 考 试 形 式考 试 形 式 闭闭 卷卷 考 试 时 间考 试 时 间 2 小小 时时 中山大学授予学士学位工作细则中山大学授予学士学位工作细则 第六条第六条 考 试 作 弊 不 授 予 学 士 学考 试 作 弊 不 授 予 学 士 学 位位 方向方向 姓名姓名 学号学号 注意注意 答案一定要写在答卷中答案一定要写在答卷中 写在本试题卷中不给分写在本试题卷中不给分 本试卷要和答卷一起交回本试卷要和答卷一起交回 1 8 points Give a regular expression for each of the following languages over the alphabet a b 1 4 points All nonempty strings that start and end with the same symbol 2 4 points All strings that contain no repeated b s including the empty string 参考答案参考答案 1 a a b a b a b b a b 2 a ba b 2 12 points Consider the following NFA 1 4 points What language does the NFA accept Please describe it in natural language 2 8 points Convert the NFA to an equivalent DFA You may construct the DFA directly 参考答案参考答案 1 所有至少包含所有至少包含 2 个个 a 或或 1 个个 b 的由的由 a b 组成的字符串组成的字符串 2 警警 示示 第 2 页 共 3 页 3 7 points Minimize the DFA represented by the following transition table where state 0 is the start state and state 5 is the only accepting state a b 0 1 3 1 1 2 2 2 5 3 3 4 4 4 5 5 5 5 参考答案参考答案 4 10 points Give a context free grammar CFG for each of the following languages over the alphabet a b 1 5 points L aibj i 0 and 2 i j 3 i 2 5 points L w w contains an odd number of symbols and the symbol in the middle of w is a 参考答案参考答案 1 S aSbb aSbbb 2 S aSa aSb bSa bSb a 5 8 points Consider the following grammar over the alphabet a b c S Xa X bX X Y 第 3 页 共 3 页 Y Zc Z bZ Z 1 5 points Demonstrate that this grammar is ambiguous 2 3 points Please remove exactly one production from this grammar to obtain an unambiguous grammar generating the same language 参考答案参考答案 1 2 删除删除 X bX 或或 Z bZ 均可均可 6 12 points Compute FIRST and FOLLOW for each nonterminal in the following grammar S A A BA A iBA B CB B CB C A 参考答案参考答案 FIRST S FIRST A FIRST B FIRST C FIRST A i FIRST B FOLLOW S FOLLOW A FOLLOW A FOLLOW B FOLLOW B i FOLLOW C i 第 4 页 共 3 页 7 13 points Consider the following grammar S Xa X a aXb 1 9 points Construct a DFA for viable prefixes of this grammar using LR 0 items 2 4 points Identify a shift reduce conflict and a reduce reduce conflict under SLR 1 parsing 参考答案参考答案 1 2 由于由于 a FOLLOW X a b 因而在状态因而在状态 I0 或或 I2 遇到输入符号遇到输入符号 a 时既可移时既可移 进也可归约进也可归约 由于由于 a FOLLOW X a b 因而在状态因而在状态 I2 遇到输入符号遇到输入符号 a 时既时既 可可用产生式用产生式 X a 归约归约 也可也可用产生式用产生式 X 归约归约 8 10 points The following grammar generates binary fractions F 0 B B 0B 1B 0 1 Design a syntax directed definition SDD for the above grammar such that the nonterminal F has an attribute F val which keeps the decimal value of the binary fraction generated by F Please use as few attributes as possible and do NOT modify the grammar 参考答案参考答案 产生式产生式 语义规则语义规则 F 0 B F val B val B 0B1 B val B1 val 0 5 B 1B1 B val 0 5 B1 val 0 5 第 5 页 共 3 页 B 0 B val 0 B 1 B val 0 5 9 8 points Consider the following fragment of three address instructions 1 b 1 2 b 2 3 if w x goto B 4 e b 5 jump B 6 A jump D 7 B c 3 8 b 4 9 c 6 10 D if y z goto E 11 jump End 12 E g g 1 13 h 8 14 jump A 15 End h 9 Please partition these three address instructions into basic blocks and draw the control flow graph You may draw the resulting graph directly but you must mark each node by number n m indicating that the corresponding basic block consists of instructions n through m inclusive 参考答案参考答案 10 12 points Consider the following basic blocks 1 T0 3 14 7 B A 2 T1 2 T0 8 T5 2 T0 3 T2 R r 9 T6 R r 1 3 4 5 6 7 9 10 12 14 15 11 第 6 页 共 3 页 4 T3 R r 10 T7 T3 T5 5 T4 T3 T1 11 B A T7 6 A T2 T4 1 7 points Construct a DAG for this basic block 2 5 points Assuming that only A and B are live on exit from this basic block simplify
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 天然药物化学模拟考试题(含答案)
- 矿山安全设备监测检修工技能操作考核试卷及答案
- 化工工艺技术员三级安全教育(公司级)考核试卷及答案
- 玻璃制品冷加工工设备调试考核试卷及答案
- 2025年混凝土证考试试题及答案
- 2025年三基三严考核测试(医技)考试题库附答案
- 安徽美术色彩题库及答案
- 2025年二建实务真题及答案解析合集
- 2025年初级乐理试题及答案
- 糖汁中和工岗位操作规程考核试卷及答案
- 2025年安全员b证考试安徽省题库及答案解析
- 首台套申报培训课件
- GB/T 14193.1-2025液化气体气瓶充装规定第1部分:工业气瓶
- 幼儿园教学课件《半条棉被》课件
- 一建市政记忆口诀
- 阀门系数Cv和KV值计算表格(带公式)
- PETS公共英语二级大纲词汇
- 消控室制度上墙
- LED屏幕施工方案
- 做一名优秀的客房服务员.ppt
- 燃气煮面炉使用说明书
评论
0/150
提交评论