(Affiliated to Dr. APJ Abdul Kalam Technical University, Lucknow) Internal Examination(TEST-2)-Odd Semester 2021-22 Program: B.Tech. Semester : V M.M.40 Branch Code: CSE Subject: Compiler Design Date : 30/11/2021 Time : 2 Hour KL1- Remembering KL4- Analyzing Knowledge Level (KL) KL2- Understanding KL5- Evaluating KL3- Applying KL6- Creating
Question 1- Answer Any TWO Questions (5X2=10 Marks)
a. Consider the following grammar: CO2 KL S→B/SabS, B→bB/ε Compute FOLLOW(B) Also Discuss about shift-reduce parsing b. Check whether the given grammar is LR(0) or not: CO2 KL S→PQy, P→Sy/x, Q→yS c. Construct the CLR(1) parsing table for the following CO2 KL grammar: S→AA, A→aA/b
Question 2 - Answer Any TWO Questions (5X2=10 Marks)
a. Consider the following given grammar and design a SLR parsing table CO2 KL S→AA, A→aA A→b b. Check whether given grammar is ambiguous or not. If ambiguous then convert it into CO2 KL unambiguous grammar: E→E+E/E*E/id c. CO2 KL Construct an LALR(1) parsing table for the following given grammar:
S→Ba/bBc/dc/bda B→d
Question 3 - Answer Any TWO Questions (5X2=10 Marks)
a. Find the postfix notation for the following expression: CO3 KL (a+b+c)*(c+q) b. Consider the following grammar and give the syntax directed definition to construct CO3 KL parse tree for the input expression 4*7+3*9. Also construct an annotated parse tree according to your syntax directed definition. E→E+T/T, T→T*F/F, F→num. c. Design SDT to convert infix into postfix. CO3 KL
Question 4 - Answer Any TWO Questions (5X2=10 Marks)
a. Translate the following arithmetic expression into quadruples and triples: CO3 KL (i). x=y*z+y*-z (ii). a=-b*(c+d)+b b. Design SDT to create 3 address codes. CO3 KL c. Differentiate between S-attributed SDT and L-attributed SDT CO3 KL