精華區beta NTU-Exam 關於我們 聯絡資訊
課程名稱︰編譯程式設計 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
andy74139 :已收錄至精華區!! 05/07 09:34