2013 Final Exam Solution

You might also like

Download as pdf
Download as pdf
You are on page 1of 18
Name: un: Comp 181 ~ Compiler Final Exam Final contains total of 150 points Time allotted is 2 hours (normal clas eng) Please state any assumptions and show your work. on A (45 point 4. Whats the elfference between a parse tree and an abstract syntax tree? Illustrate withthe help of following example. (6 points) Grammar: E > cint | (E) | E*E, where cint is terminal (an integer constant) and Eis a non-terminat Input string: 7 * (8 * 3) Facse tree i Presents he shucture fa given programe se arabic end trent fre om Result af parting Pestreck Synla tree 2 Abstracts cut seme detelle partic Cast) ferse tree, pachiertarly the non-Herminale Parselree. oN me 7 * (83) >» fr T#(en3 ee ee pus 2 3 HSS eti ote AST fe 7 #2) e+ & | Cin, indy 2 stare some advaages of bottom-up parser over a top-down parser. (pons) Ubike < ep-danom parser, a boHem—wy> parier hos Filner advan bogen be Can parse a rctecnlly copremned gramme 3B. She iginel grammer Boas not need |p be Nfb-Leceredk Me fefretecursien needs 0 he veneveck . he Mee pmserful os handling Bomar Name unw: Comp 181 ~ Compilers Final &xam 3 Consider the following grammar, which has a set of terminals T=, 6 df), onda set of ‘non-terminals NT= (SA, B,C) soasc APelcole eecraale cel (0) Compute the ist and FOLLOW set for al terminal nd non-terminl (10 pont) i 3) ; 3 | (©) Construct the L13) parsing table. (5 points) a8 a 4 (6) ts this grammar L1(2}? Why or why not? (3 points) 2 tobi har confvrets re Name: un: {Comp 181 ~ Compiles Final Exam “A. Conder the following grommar with terminale T= fb} sPsalb (a) on this grammar be recognized by a recursive descent parser? Why or why not? (5 points) ene FGST Cs) = 14, bt ee Gal Se F 5 Tapa \ €) Fouw6s) = Fay No. Crblid ae He LEG) tao Meo, Here Y left recursion vn the Gramrar, (0) Prove that he grammar ist). (10 pins) or stede 2, shift on 2’ and rohice en's? No emglick *, SLRG) (ts the grammar also LR(0)? Why or why not? (3 points) Me, Grfict ie resclved by me Devel Crk ahead -

You might also like