Philadelphia University Faculty of Information Technology Lecturer : Dr. M. Maouche Coordinator : Dr M. Maouche Internal Examiner : Dr. N. Nameer Department of Computer Science Examination Paper Course Name: Compiler Construction (750324) Section: 1 Second Exam First Semester Academic Year: 2015/16 Date: December, 31th, 2015 Time: 50 minutes Information for Candidates 1.This examination paper contains 4 questions, totaling 20 marks. 2.The marks for parts of questions are shown in round brackets. Advice to Candidates 1. You should write your answers precisely, clearly and to the point . I. Basic Notions Objectives. The aim of the question in this part is to evaluate the required minimal student knowledge and skills. Answers in the pass category represent the minimum acceptable standard. Question1: (6 marks) Answer the following MCQ questions 1. Shift Reduce parsers are: A. Top Down parsers B. Bottom parsers C. May be top down or bottom up parsers D. None of the above. 2. A top down parser generates A. Right Most Derivation B. Left Most Derivation C. Right Most Derivation in Reverse D. Left Most Derivation in Reverse 3. LR stands for A. Left to Right B. Left to Right Reduction C. Right to left D. Left to right and right most derivation in reverse 4. Recursive descent parsing is an example A. Top down parsing B. Bottom parsing C. Backtracking parsing D. Reduce Shift parsing 5. What is a sentential form? A. One line of a derivation B. An arbitrary string of grammar symbols C. The content of the LL(1) parse stack D. The string of symbols between the current point in the parse and the root of the parse tree 6. Which of the following is concerned by semantic analysis A. Uniqueness checks B. Type checks C. Flow of control checks D. All of the above II. Familiar Problems Solving Objectives. The aim of the question in this part is to evaluate that the student has some basic knowledge of the key aspects of the lecture material and can attempt to solve familiar problems Question2: (6 marks) Given the following grammar: SA S B A cA + b Aa B cB + a Bb S, A, B are non terminals; a, b, c and + are terminals Compute: First (S) = { } (3 marks) ; Followers (B) = { } (3 marks) Explain each step of the computations. Question3: (5 marks) Given the following grammar: E (E + E) Ex E is a start non terminal x, (, ), and + are terminals. 1. Compute the state S0 of the FSA obtained by applying the reduce shit parsing technique. (2 marks) 2. Compute: Goto (S0, E) and Goto (S0, () (3 marks) Explain each step of your computations. III. Unfamiliar Problems Solving Objectives. The aim of the question in this part is to evaluate that the student has some basic knowledge of the key aspects of the lecture material and can attempt to solve unfamiliar problems. Question4: (3 marks) Construct a recursive-descent parser for the following grammar: S -> + S S | - S S | a Assume that the match function is available.