编译原理本科试卷A.doc
《编译原理本科试卷A.doc》由会员分享,可在线阅读,更多相关《编译原理本科试卷A.doc(9页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、姓名 学号 学院 班级 座位号 ( 密 封 线 内 不 答 题 )密封线线_ _ 诚信应考,考试作弊将带来严重后果! 华南理工大学期末考试 编译原理 试卷A注意事项:1. 考前请将密封线内填写清楚; 2. 所有答案请直接答在试卷上; 3考试形式:闭卷; 4. 本试卷共 大题,满分100分,考试时间120分钟。题 号一二三四五总分得 分评卷人Note: Whether English or Chinese doesnt impact your score.1. Fill in the blanks (18%)a. Normally, A complier consists of a number
2、 of phases. They are Scanner Grammarparser, _Semantic analyzer_, _Source Code Optimizer_, Code Generator, and _target code optimizer _.b. The logical units the scanner generates are called Tokens. For a modern programming language, there are five types of token. They are _Identifier_, _Reserved Word
3、s_, _Number_, _, _. c. Based on the following C source code fragmentint gets(char *s) if (s = NULL) printf(“illegal point parameter n”); return -1; return 0;Please answer:a) “int” is a _b) “printf” is a _ c) “s” is a (an) _ d) “= =” is a _ e) “0” is a _d. A grammar G usually includes four components
4、, they are _, _, _, and _.2. (Terms Translation, 12%)Please give a brief explanation to the following terms in compiler science domaina) Compiler b) Source code c) Scanner d) Tokens e) Terminal symbol f) Ambiguous Grammar 3. (Scanning; 20%)(a) (10%) Construct an NFA that recognizes the same language
5、 as defined by the following regular expression: (a*ba*b)*ba*(b) (10%) Using the subset construction, convert the NFA into a DFA. abA=0,1,2,5BCB=2BDC=3,6, 7,8EFD=3DFE=3,7, 8EFF=1,2,4,5BC4. (LL parsing; 25%) Consider the following grammar G(S): S-number | ListList - (Seq)Seq - Seq, S | SWhere number
6、and “,” are terminal symbols, and the others symbols are non-terminal.(a) (7%) Please write the left-most derivation for sentence “(4, (34)”(b) 8%Please convert the grammar G into a LL(1) grammar G1 by remove the left recursion.(c) 10%Based on your LL(1) grammar G1, please calculate the FOLLOW set a
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 编译 原理 本科 试卷
限制150内