UCS802
UCS802
UCS802
Roll Number:
Thapar University, Patiala
Department of Computer Science and Engineering
Q2. Consider the following grammar G2 and perform the following(s) : (10)
S —› V = E
E-->FIE+F
F --> V I integer I (E)
V id
a) Construct the DFA of LALR(1) items.
b) Construct LALR(1) parsing table.
c) Show the processing of input string : w=id=integer+id.
Q3. Execute the following program and explain its output in terms of the runtime environment : (15)
program chaining;
procedure p;
var x: integer;
procedure q;
procedure r
begin
x := 2;
If then p;
end{ of r}
begin
r;
end{ of q}
begin
q;
end { of p}
begin {of main }
p;
end.
Page 1 of 2
(10)
p4. Consider the following grammar for simple integer arithmetic expressions :
E-*E+TIE-TIT
• T-*T*FIF
F ->(E) I num
Q5. Explain the five phases of compiler. Illustrate with help of some example. (10)
(10)
Q8. Explain the term Left factoring. Illustrate with help of some example
Q9. Given the regular expression r = (b I a )*baa . Convert it into NFA using Thompson's Construction.
Convert the obtained NFA into DFA and minimize it. (10)
Q10. Discuss in brief the importance of symbol table in compiler design. (5)