GTU Computer Engineering (Semester 7)
Compiler Design
December 2015
Total marks: --
Total time: --
INSTRUCTIONS
(1) Assume appropriate data and state your reasons
(2) Marks are given to the right of every question
(3) Draw neat diagrams wherever necessary


1(a) Define lexeme, token and pattern. Identify the lexemes that make up the tokens in the following program segment. Indicate corresponding token and pattern.
void swap (int a, int b)
{
  int k;
  k=a;
  a=b
  b=k;
}
7 M
1(b) Explain Semantic Analysis and Syntax Analysis phases of compiler with suitable example. Also explain the reporting errors by these two phases.
7 M

2(a) Write a short note on Symbol Table Management.
7 M
Solve any one question from Q.2(b) & Q.2(c)
2(b) Construct DFA for following Regular expression. Use firstpos, lastpos and followpos functions to construct DFA.
( a* | b *) *
7 M
2(c) Construct NFA for following Regular Expression using Thomson's Construction. Apply subset construction method to convert into DFA.
(a | b) *abb
7 M

Solve any one question from Q.3 & Q.4
3(a) Construct LL(1) parsing table for the following Grammar:
S → (L) | a
L → L.S | S
7 M
3(b) Check whether the following grammar is CLR or not.
S → Aa | bAc | Bc | bBa
A → d
B &rarr d
7 M

4(a) Define: Left Recursive. State the rule to remove left recursive from the grammar. Eliminate left recursive from following grammar.
S → Aa | b
A → Ac | Sd | f
7 M
4(b) Construct SLR Parsing Table for the following grammar.
S → 0S0 | 1S1 | 10
7 M

Solve any one question from Q.5 & Q.6
5(a) Explain Operator Precedence Parsing method with example.
7 M
5(b) Show syntax directed definition for simple desk calculator. Also show annotated parse tree for 3*5+4n, where n indicates newline.
7 M

6(a) Explain LALR parser in detail. Support your answer with example.
7 M
6(b) Give the translation scheme that converts infix to postfix expression for the following grammar and also generate the annotated parse tree for input string 7+3+2.
E → E+T
E → T
T → 0 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9
7 M

Solve any one question from Q.7 & Q.8
7(a) Translate following arithmetic expression
- (a*b)+(c+d)-(a+b+c+d) into
1] Quadruples
2] Triple
3] Indirect Triple
7 M
7(b) Explain various dynamic storage allocation techniques.
7 M

8(a) Explain any three code optimization techniques with example.
7 M
8(b) Explain various issues in design of code generator.
7 M



More question papers from Compiler Design
SPONSORED ADVERTISEMENTS