Philadelphia University
Faculty of Information Technology
Lecturer
: Dr. M. Maouche
Coordinator
: Dr M. Maouche
Internal Examiner : Dr. N. Nameer
Examination Paper
Department of Computer Science
Course Name: Compiler Construction (750324) Section: 1 Final Exam Semester 2 2015/2016
Date: 14/06/2016 Time: 120 minutes
Information for Candidates
1.This examination paper contains six questions totalizing 40 marks
2. The marks for parts of questions are shown in round brackets.
Advice to Candidates
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 in software development processes. Answers in the pass
category represent the minimum acceptable standard.
Question1 (16 marks)
1. What are the input(s) and output(s) of a lexical analyzer. (2 marks)
2. What are the input(s) and output(s) of a parser. (2 marks)
3. Name at least two different intermediate representation formats. (2 marks)
4. Name two different techniques of parsing. (2 marks)
5. Name one of the major function performed by the semantic analyzer of a compiler. Give a concrete
example. (2 marks)
6. Identify two major problems that must be addressed by the code generator of a compiler when
dealing with a function call. (2 marks)
7. What are the kinds of type equivalence? (2 marks)
8. Name the symbol tables manipulated by a compiler of an object oriented programming language. (2
marks)
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 (5 marks)
Consider the following grammar;
S X$
XaXc
XXX
Xb
S and X are non terminal symbols and a, b, and c are terminal symbols.
1. Compute
2. Compute
Closure({X X . X})
Goto({X a . Xc }, X)
(3 marks)
(2 marks)
Question3 (5 marks)
Consider the following grammar
E x+T
T (E)
Tx
where E and T are non terminal symbols and (, ), and x are terminal symbols.
We want to apply the predictive recursive descent algorithm to this grammar. For this purpose write the
pseudo code of the following functions:
boolean T() {………} (3 marks)
boolean E () {………} (2 marks)
Question4 (5 marks)
Consider the following class :
Class WaterTank {
int capacity ;
int
water;
void add_water (int wata) {………};
void remove_water (int watr) {………};
}
Draw the AST (abstract syntax tree) for this class.
Question5 (5 marks)
Consider the following function code:
While b ≠ 0
if a > b
a := a − b
else
b := b − a
return a
Draw the AST (abstract syntax tree) for this code.
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
Question6 (4 marks)
Consider the following assignment statement:
a = b*c +d*e - f
Write the three address code representation of this statement.
© Copyright 2026 Paperzz