F P h

advertisement
Faculty of Information Technology
Philadelphia University
Lecturer
Coordinator
: Dr. M. Maouche
: Dr M. Maouche
Department of Computer Science
Marking Schema
Internal Examiner : Dr. N. Nameer
Course Name: Compiler Construction (750324)
First Exam
Second Semester
Academic Year: 2014/15 Date: April, 7th , 2015
Section: 1
Time: 50 minutes
Question1: (8 marks)
1. Interpreter (1); compiler (2)
2. front end: language dependent (1)
back end: machine dependent (1)
3. Lexical analyzer, syntactic analyzer, semantic analyzer, intermediate code
generator, code optimizer, code generator (2)
4. a lexeme is a sequence of characters produced by the lexical analyzer from the input
source while a token is a couple which elements are a language dependent symbol
and a value. (2)
Question2: (4)
Question3: (3 marks)
void S(){
} }
if(lookahead == "("){
match("("); S(); match(")"); S();
Void match(Terminal t){
nextTerminal();
}else{
if(lookahead = t){
lookahead =
throw new SyntaxException()
} }
Question4: (4x1)
x(yz|zy) *z
(a) xz; included- x z (ignore the optional part of the expression)
(b) xyz: not included - x yz missing z
(c) xyzzyz : included - x yz zy z
(d) xzyyzz: included- x zy yz z
Question5:
1. Expression: a(ba)*
2. FSA:
(2)
(2)
Download