Compiler 2022 Midterm - Answers
Compiler 2022 Midterm - Answers
(1) The ……… phase of the compiler is responsible for variables type checking.
(a) Semantic Analyzer (b) Syntax analyzer (c) Lexical Analyzer (d) None
(2) The …… performs syntax analysis based on the grammar of the programming language.
(a) Optimizer (b) Scanner (c) Parser (d) None
(3) The lexical analyzer reads the stream of characters making up the source program and groups the characters
into meaningful sequences called ……
(a) Token Names (b) Lexemes (c) Attribute Values (d) None
(4) The Regular Expression (RE) which generates any number of 0′s is followed by any number of 1′s followed by
any number of 2′s is ……..
(a) (0|1|2)* (b) 0*1*2* (c) (0*| 1 | 2) (d) (0|1)*2*
(5) The string which is NOT generated by the regular expression RE = ( (ab|abb)* bbab? ) is ………
(a) ababbbbbab (b) abbbab (c) ababbabbbab (d) abababab
(6) If ∑={a, b, c}, find the RE which generates the set of all strings containing at most one occurrence of b
(a) (a|c)*(b?)(a|c)* (b) (a|c)*b(a|c)* (c) (a|c|b)*b(a|c|b)* (d) (a|c)*b+(a|c)*
(7) If ∑={a, b, c}, find the RE which generates the set of all strings with no consecutive b’s
(a) (a|c|cb|ab)* (b) (a|c|ba|bc)* (c) (a|c|ba|cb)*(b|ε) (d) (a|c|ba|bc)*(b|ε)
(8) If ∑ = {a, b}, find the RE which generates all strings which do not contain the substring ba
(a) a*b* (b) (a|b)* (c) (ab|a|b)* (d) (a|b)+
(9) A Deterministic Finite Automata (DFA) can take only one path through the state graph.
(A) True (E ) False