(Department of Computer Science)
WARNING 1. PLAGIARISM OR HIRING OF GHOST WRITER(S) FOR SOLVING THE ASSIGNMENT(S) WILL DEBAR THE STUDENT FROM AWARD OF DEGREE/CERTIFICATE, IF FOUND AT ANY STAGE. 2. SUBMITTING ASSIGNMENT(S) BORROWED OR STOLEN FROM OTHER(S) AS ONE’S OWN WILL BE PENALIZED AS DEFINED IN “AIOU PLAGIARISM POLICY”.
Course: Compiler Construction (3468) Semester: Autumn, 2012
Level: BS (CS) Total Marks: 100
ASSIGNMENT No. 1
Note: All questions carry equal marks.
Q. 1 (a) Define Compiler, using a diagram describes the three phases of analysis of source program. (b) Explain all the phases of Compiler. (c) Consider the following grammar. S ―> XaYb X ―> bXc | b Y ―> dYa | d Find the first sets for each non-terminal of the given grammar.
Q. 2 (a) Explain the error detection and reporting mechanisms. (b) Write the intermediate representation code of the following position: = initial + rate * 60
Q. 3 (a) Convert the following NFA into equivalent DFA using subset construction Algorithm. [pic] Note: Show all necessary steps that are involved in subset construction algorithm. (b) Convert the Following regular expression into NFA using Thompson’s construction. a ((b|b*c)d)* |d*a
Q. 4 (a) Given the following grammar. G → E E → T + E | T T → F * T | F F → a i) Is this grammar ambiguous? Explain! ii) Draw all parse trees for sentence “a+a*a+a”. (b) Consider the following grammar. S→ A A→ A+A | B++ B → y Draw parse tree for the input “y+++y++”
Q. 5 (a) Explain the role of the Lexical Analyzer and Parser in detail. (b) Differentiate between Top-down parsing and Bottom-up parsing.
ASSIGNMENT No. 2
Total Marks: 100
Note: All questions carry