0% found this document useful (0 votes)
186 views

Compiler 2022 Midterm - Answers

The document is a midterm exam for a compiler course. It contains 10 multiple choice questions testing concepts related to compilers, regular expressions, and finite automata. The questions cover the roles of different compiler phases like the semantic analyzer and parser. They also assess understanding of regular expressions and their use in specifying languages, as well as properties of deterministic finite automata.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
186 views

Compiler 2022 Midterm - Answers

The document is a midterm exam for a compiler course. It contains 10 multiple choice questions testing concepts related to compilers, regular expressions, and finite automata. The questions cover the roles of different compiler phases like the semantic analyzer and parser. They also assess understanding of regular expressions and their use in specifying languages, as well as properties of deterministic finite automata.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Helwan University Second Term – 2021/2022

Faculty of Computers and Artificial Intelligence Time: 30 Minutes


Computer Science Department CS419 - Compiler
Midterm Exam (Model A)

Question 1 – Choose Correct Answer (only one choice ):-

(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

(10) DFA can have ε-transition.


(A) True (E ) False

With best wishes


Dr. Ahmed Hesham Mostafa
Prof.Dr. Hala Abdel Galil

You might also like