You are on page 1of 2

Reg. No.

: ___________________

UNIVERSITY
Karunya Institute of Technology & Sciences
(Declared under section-3 of the UGC Act, 1956)

School of Computer Science and Technology


III B.Tech CSE / IT
Internal Assessment Test I
Code : 12CS213 Date :12.02.2015
Subject Name : Principles of Compiler Design Duration : 2 hrs
Max.Marks :50

ANSWER ALL THE QUESTIONS


PART A (5x1=5 Marks)

1. Identify the type of error in the following code segments.


a. int a=10, b=20, c=0;
b=(b/2*a)-b;
c=a/b;
b. main(){
float k=2.1;
int num=0, value=5;
int a[10];
for(num=1;num<10;num++){
a[k]=num;
}
}
2. Differentiate Compiler and Interpreter.
3. Generate four possible strings for the regular expression: (a|b)*(cd)*
4. Differentiate NFA and DFA.
5. Draw the syntax tree for a=a*b+c.

PART B (3x5=15 Marks)

6. Diagrammatically represent the language processing system.


7. What are the possible error recovery techniques used by the compiler during lexical analysis
phase to recover from the detected errors?
8. Write a lex program to count the number of even numbers in a given input string.
9. Write a regular definition for “identifiers” in a programming language.
10. Check whether the following grammar is ambiguous or not.
B  B+B | BB | (B) | B* | a

PART C (3x10=30 Marks)


11. Explain the various phases of a compiler. Also show the step by step translation of the statement
“Percentage = 0.01 * NoPassed / TotalStrength” through the phases of compiler to the target
language.

12. Construct a minimum state DFA directly for the regular expression m*n(m|nm*) by constructing
the syntax tree and finding firstpos(), lastpos() and followpos().

13. Construct a predictive parser for the following grammar and check whether the input not (true or
false) is parsed without errors.
bexpr ->bexprorbterm | bterm
bterm ->btermand bfactor | bfactor
bfactor ->not bfactor| (bexpr) | true | false

You might also like