精華區beta NTU-Exam 關於我們 聯絡資訊
課程名稱︰編譯程式設計 課程性質︰選修 課程教師:徐慰中 開課學院:電資學院 開課系所︰資工系 考試日期(年月日)︰2013.10.23 考試時限(分鐘): 試題 : 0) Which of the following are not in the six compilation phases? 1) Lexical analysis 2) Syntax analysis 3) Preprocessing phase 4) IR code generation 5) Linkage phase 1) Which of the following statements about the AC-to-DC compiler in Chapter 2 are not true? 1) AC-to-DC is a single pass compiler 2) AC supports type widening and narrowing 3) AC supports subtraction operations 4) AC-to-DC uses bottom-up parsing 2) Why do we try to use as much formalism as possible in the language specification? 1) To avoid ambiguity in analysis 2) To increase the expressive power 3) To automate the translator generation 4) To rule out non-CS students in the Compiler field 3) The CFG of AC is LL(1), what does it mean by LL? 1) Long Life parsing 2) Least difficult, Left to right parsing 3) Left to right parsing to find the Leftmost derivation tree 4) Left Lane parsing 4) What are the advantages of interpretation as opposed to compilation? 1) Higher degree of machine independence 2) Overall higher performance 3) Easier to write 4) Better diagnostics 5) In an AST, an internal node is usually 1) a non-terminal 2) a terminal 3) an operator 4) an operand 6) Which of the following are not authors of the textbook ("Crafting a Compiler")? 1) Alfred Aho 2) Charles N. Fischer 3) James Gosling 4) Ron K. Cytron 5) Wei Chung Hsu 7) Which of the following are authors of the textbook ("Compilers: Principles, techniques, & Tools, second edition")? 1) Alfred Aho 2) Shih-Wei Liao 3) Jeffrey Ullman 4) Monica Lam 5) Andrew Appel 8) Which of the following could be part of semantic analysis? 1) Check type consistency 2) Check whether a statement is reachable 3) Check for possible uninitialized variables 4) Check whether a while statement is nested 9) A retargetable compiler shares which of the following phases for different target machines? 1) Scanning 2) Parsing 3) IR code generation 4) Machine independent optimization 10) What is the target machine of our C-- compiler? 1) DC 2) ARM 3) ByteCode 4) MIPS 11) In which of the following CFG's, the OP is left associative? 1) <expr> → <primary> <OP> <expr> 2) <expr> → <expr> <OP> <primary> 3) <expr> → Val Rest Rest → <OP> <primary> Rest | λ 4) <expr> → <expr> <OP> <expr> 12) Which of the following are considered a cross-compiler? 1) A Fortran-to-C Compiler 2) A compiler generates x86 code, but runs on PowerPC 3) A compiler generates intermediate code 4) A C++ compiler generates C-- code 13) Which one of the following grammars is ambiguous? 1) S → S 0 | 1 2) S → 0 S | 1 ┌─┐ 3) S → S S | 0 | 1 │+│ 4) S → S S + | a | b └┬┘ _╱ ̄╲_ 14) The tree on the right is a ┌┴┐ ┌┴┐ 1) a concrete syntax tree │*│ │4│ 2) an annotated parse tree └┬┘ └─┘ 3) a syntax tree _╱ ̄╲_ 4) a parse tree ┌┴┐ ┌┴┐ 5) an abstract syntax tree (AST) │1│ │2│ └─┘ └─┘ 15) The transition table (i.e. a two dimensional table) generated by Lex is indexed by 1) state and non-terminals 2) token ID and input char 3) state and token ID 4) state and input char 16) Which of the following in C-- can be defined as tokens? 1) Identifiers 2) IF statements 3) white space 4) literal strings 5) comments 17) If you want to write a parser by hand, which of the following approaches is most likely? 1) Bottom-up parsing 2) Recursive descent, predicated parsing 3) Recursive descent, predictive parsing 4) Recursive decent, predictive parsing 5) Top-down, back-tracking parsing 18) What string or strings will be accepted by the following regular expression [a|b]* 1) λ 2) a|b 3) abba 4) a|aa|bb|b 19) How do we convert an NFA to a DFA 1) use Thompson's construction algorithm 2) use the subset construction algorithm 3) use the DFA minimization method 4) use a transition diagram method 20) Left recursion can be represented in the following form A → Aα | β For the following C syntax, what strings are considered β? ID_list → ID_list , ID | ID_list , ID DIM | ID DIM | ID 1) , ID 2) ID DIM and ID 3) ID DIM 4) , ID DIM and , ID 21) A name in regular definition is more like: 1) a Non-terminal in CFG 2) a Macro definition (w/o parameters) 3) a Procedure (w/o parameters) that can be in-lined 4) a static global variable 22) What are the rules used by Lex to solve conflicts between overlapped RE's 1) Longest possible match 2) Shortest match 3) Earlier ones preferred 4) Later defined preferred 23) Which of the following is most unlikely? 1) A C Compiler written in C 2) A C-- compiler written in C++ 3) A Lex scanner generator written in Lex 4) A Java VM interpreter written in Java 24) If bytecode is considered an IR, which of the following statements are true? 1) A Java compiler is a FE 2) A JIT compiler is a BE 3) DX (convert bytecode to dex) is a ME 4) DX is neither a FE nor a BE 25) What are the major components of a syntax-directed definition? 1) CFG 2) RE 3) Semantic rules 4) Target architecture definition 26) How can we make a scanning table smaller to consume less main memory? 1) Perform DFA minimization 2) Compressing the table using BZIP 3) Share identical rows/columns 4) Handle reserved words as IDs 27) Which of the following statements about NFA/DFA are true? 1) It is easier to map a RE to NFA 2) NFA transition table takes more space 3) DFA is generally faster than NFA 4) Converting NFA to DFA increases the number of states by at most 2X. Ans: 0) 3, 5 1) 1, 2, 4 2) 1, 3 3) 3 4) 1, 3, 4 5) 3 6) 1, 3, 5 7) 1, 3, 4 8) 1, 2, 3 9) 1, 2, 3, 4 10) 4 11) 2, 3 12) 2 13) 3 14) 3, 5 15) 4 16) 1, 3, 4, 5 17) 3 18) 1, 2, 3, 4 19) 2 20) 2 21) 2 22) 1, 3 23) 3 24) 1, 2, 3, 4 25) 1, 3 26) 1, 3, 4 27) 1, 3 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.24.78.41 ※ 文章網址: https://www.ptt.cc/bbs/NTU-Exam/M.1434156022.A.14E.html