0% found this document useful (0 votes)
6 views1 page

UCS802

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 1

Page 1 of 1

Roll Number.
Thapar Institute of Engineering & Technology, Patiala
Department of Computer Science and Engineering

B. E. (Final Year) Auxiliary Examination Course code: UCS 802


Cour§e Name:Compiler Construction
Time: 3 Hours, M. Marks: 100 Name Of Faculty: Dr. Sunita Garhwal
DATE: 21/08/2023

Note: Attempt all questions. Assume missing data, if any, suitably


01. Convert the regular expression r = ab*a(alb)* into NFA using Thompson's construction. Convert the
obtained NFA into DFA using Subset construction and minimize it. (10)
02, Consider the following grammar G: (15)
S —>aABe
A —> Abc
A —> b
B--* d
a) Construct the DFA of LR(0) items.
b) Construct LR(0) parsing table.
c) Show the parsing stack and the actions for the input string : w=a bbcbcde.

Q3. Differentiate between the following with suitable examples: (15)


a) Dead Code Elimination and Loop Optimization.
b) Abstract Syntax Tree and Directed Acyclic Graphs.

Q4. Explain the five phases of compiler. Illustrate with help of example. (10)

Q5. Consider the following expression: (15)


(A/B + C) * ( B + C)—( A +B + C)
a) Write sequence of three-address instructions that would be generated by above expression.
b) Represent the Quadruples, Triples and Indirect-Triple implementation for the above three-address
code.

Q6 Consider the following grammar: (20)


E —>E+T I T
T—> T*F F
F—>(E) I id
a) Remove the left recursion from the above grammar.
b) Construct First and Follow sets for the non-terminals of the resulting grammar.
c) Construct LL(1) parsing table.
d) Show the parsing stack and the actions for the input string : w="1+2*3".

Q7. Explain Error Handling and Recovery for the Lexical and Syntax analysis phases of
compiler. (15)

You might also like