作者wesley10000 (wesley)
看板NTU-Exam
标题[试题] 98下 陈俊良 编译程式设计 期中考
时间Thu May 6 21:13:58 2010
课程名称︰编译程式设计 Compiler
课程性质︰必修
课程教师︰陈俊良
开课学院:电资学院
开课系所︰资工系
考试日期(年月日)︰98年5月4日
考试时限(分钟):120分钟
是否需发放奖励金:是
(如未明确表示,则不予发放)
试题 :
Consider the following grammar for questions 1-4
0. S -> E $
1. E -> v = E
2. E -> F
3. F -> F + F
4. F -> v
5. F -> ( E )
where S, E and F are nonterminals; S is the start symbol; other symbols are
terminals; and $ is the mark of end-of-file.
1. (a) Which one of (v+v)+v and v+(v+v) is equivalent to v+v+v? (2%)
(b) Which one of (v=v)+v and v=(v+v) is equivalent to v=v+v? (2%)
(c) Is v+(v=v+v)=v a legal sentence? (2%)
(d) Is v=(v=v+v)+v a legal sentence? (2%)
2. (a) Find first set for each nontermianl. (3%)
(b) Find follow set for each nontermianl. (3%)
(c) Find predict set for each production. (6%)
From now on, let '=' be right associative, and '+' be left associative.
3. Construct the SLR(1) parse table. (30%)
4. (a) Modify this grammar so that it become unambiguous. (10%)
(b) Modify if furthermore so that it becomes LL(1). (20%)
5. Today, many language compilers are written in the languages themselves. For
example, GCC is written in C and Javac is written in Java. How to do that?
(20%, at most 10 lines)
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.165.22.117
1F:推 andy74139 :已收录至!! 05/07 09:34