Upload
er-mils-patel
View
120
Download
3
Tags:
Embed Size (px)
Citation preview
Unit -1QUE: 1 what is a compiler? Explain.
QUE: 2 explain why one study about compiler should.
QUE: 3 Draw and explain phases of compiler.
QUE: 4 what is the advantages of multipass compiler over single pass compiler? What are features of a good compiler?
QUE: 5 define and differentiate between compiler and interpreter?
QUE: 6 write short note on Bootstrapping?
QUE: 7 write short note on
(1) Cross compiler.(2) Compiler-compiler.(3) Input buffering.(4) Symbol table organization.(5) Error handler.
QUE: 8 explain the concept of LEX? Describe auxiliary definitions and transaction rules for LEX with suitable example.
QUE: 9 A LEX program given below –
Auxiliary Definitions
(non)
Translation rules
a
abb
a*b +
implement the LEX program as DFA.
QUE: 10 Using the transition system. Prove that the strings recognized are
(a + a ( b + aa )* b )* a ( b + aa )* a
QUE: 11 Design a DFA for decimal number which is divisible by 4.
QUE: 12 convert the following NFA in to DFA.
QUE: 13 Design a FA which accepts odd number of 1’s and any number of 0’s.
QUE: 14Construct a transition graph for a FA which accepts a language L over {0, 1} in
Which every string start with 0 ends with 1.
Unit 2
QUE: 1 what do you mean by ambiguous and unambiguous grammar? Explain with
Example.
QUE: 2 what is top down parsing? What are the difficulties encounter in this and how are
they overcome?
QUE: 3 compare the top down and bottom-up parsing techniques?
QUE: 4 what is predictive parser? How a parser is controlled by a program?
QUE: 5 what do you understand by operator precedence parsing? Write down limitations.
QUE: 6 write short note on error recovery procedures in LL and LR parsers.
QUE: 7 remove null production , unit production and useless symbols from the following
CFG S → PQ│RS│QT
P → a│ap
Q → ε│bQ
R → Rd│Rc
T →eT│ε
QUE: 8 define ambiguity of grammars. Prove that the grammar
S → AB,
B→ ab
A→ aa
A→ a
B→ b is ambiguous.
QUE: 9 consider the grammar
S → (L)/a
L→ L, S/S
(i) Find parse tree for the following –(A) (a, a)(B) (a,(a, a))(C) (a,((a, a),(a, a)))
(ii) Construct leftmost derivative for each(a)(iii) Construct rightmost derivative for each(a)
QUE: 10 let G be the grammar –
S →aB│bA
A → a│aS│bAA
B → b│bS│aBB
For the string “aaabbabbba” find –
(i) Leftmost derivation (ii) rightmost derivation (iii) parse tree.
QUE: 11 differentiate between operator grammar and operator precedence grammar .
Compute precedence relation for the following grammar-
E →E+T│T
T → T*F│F
F → (E) │id
Show the moves of operator precedence parser for input string “id+id*id”
QUE: 12 find LEADING and TRAILING of the following grammar
S →aAB│bA│ε
A → aAb│ε
B → bB│C
QUE: 13 consider the following grammar –
A → ABd│Aa│a
B → Be│b remove left recursion.
QUE: 14 do left factoring in the grammar -
A → aAB│aA│a
B → bB│b
QUE: 15 for the following grammar find FIRST and FOLLOW sets for each of
Nonterminals.
(a) S →aAB│bA│ε (b) S →ACB│CbB│Ba
A → aAb│ε A → da│BC
B → bB│ε B → g│ε C→ h│ε
QUE: 16 design LL (1) parsing table for the following grammar-
A → AcB│cC│C
B → bB│id
A → CaB│BbB│B
QUE: 17 consider the following grammar –
S →iCtSA│a
A → eS│ε
Whether it is LL(1) grammar. Give the explanation whether (i, t, e, b, a) are
Terminal symbol.
QUE: 18 consider the following grammar
text→ atom│list
atom→ number│identifier
list → (temp-seg)
text-seg → text, text-seg│text
(i) Left factor this grammar (ii) Construct FIRST and FOLLOW sets for the non-terminals of resulting
grammar.(iii) Show that resulting grammar is LL (1).(iv) Construct LL(1) parsing table for resulting grammar.
QUE: 19 construct the collection of LR(0) item sets and draw the goto graph for the
Following grammar-
S→SS│a│ε
Indicate the conflict (if any) in the various states of the SLR parser.
QUE: 20 design LL (0) parsing table for the following grammar-
S → cA│ccB
B → cA│a
A → ccB│b
QUE: 21 design LALR (1) parsing table for the following grammar-
S → Aa│bAc│dc│bda
A → d
Unit -3QUE: 1 Explain syntax directed translation in brief?
QUE: 2 differentiate between synthesized translation and inherited translation?
QUE: 3 Explain the types of attribute used in syntax directed translation?
QUE: 4 let the synthesized attribute “val” give the integer value associated with the non-
terminals in the following grammar -
L→E,
E→ E1+T│T
T→T1*F│F
F→ (E) │digit.
QUE: 5 write a brief note on -
(i) syntax tree.(ii) L-attribute definitions.(iii) S-attribute definitions. (iv) Type checking (v) Back patching
QUE: 6 What do you understand by top down translation?
QUE: 7 explain intermediate forms using postfix notation?
QUE: 8 write a short note on three-address code and how it is represented using triple,
Quadruples and indirect triple.
QUE: 9 Compare the relative merit and demerits of the following-
(i) triple,
(ii) Quadruples
(iii) indirect triple.
QUE: 10 translate the expression a*- (b+c) into-
(i) Postfix notation.(ii) on three-address code
QUE: 11 translate the expression –
Y = (4 * 7 + 1) * 2
(i) quadruples (ii) triples (iii) indirect triple
QUE: 12 construct syntax tree and Postfix notation for the following expression –
(a + b (b*c))↑d-e/ (f+g)
QUE: 13 translate the expression –
(A) - (a+b) *(c+d) + (a+b+c)(B) - (a+b) *(c+d) - (a+b+c) into
(i) quadruples (ii) triples (iii) indirect triple
QUE: 14 construct 3-address code for the following –
(A) If [(a<b) and(c>d) or (a>d))], then (B) while a<b do
z = x+y*z if c<d then
Else z = z+1 x = y+z
Else
x = y-z
QUE: 15 consider the following while statement –
While A>B and A< = 2*B-5 do
A : A+B;
(i) Construct the parse tree (ii) Write intermediate code
QUE: 16 generate the 3- address code for the following program fragment-
While (A<C and B>D)do
If A=1 then
C=C+1
Else
While A< = D do
A : = A+3;
QUE: 17 consider the program fragment –
Sum: = 0
For (i=1; i < = 20; i ++)
Sum: = sum +a[i] +b[i];
And generate 3-add code for it, there is four bytes per word.
QUE: 18 generate 3-add code for the following switch statement-
Switch (i+j)
{
Case 1: x: = y + z
Case 1: p: = q + r
Case 1: u: = v + w
}
QUE: 19 generate code for the following C statements for the target machine assuming
All variables are static, assume three registers are available.
x = a[i] +1
a[i] = b[c[i]]
a[i][j] = b[i][k]*c[k][j]
a[i] = a[i] +b[j]
a[i] + = b[j]
QUE: 20 generate 3-add code for the following switch statement-
Switch (a+b)
{
Case 2:
{
x: = y;
break;
}
Case 5:
{
Switch(x)
{
Case 0 :
{
a: = b + 1;
break;
}
Case 1 :
{
a: = b + 3;
break;
}
Default :
{
a: = 2;
break;
}
}
Break;
}
Case 9 :
{
a: = y - 1;
break;
}
Default :
{
a: = 2 ;
break;
}
Unit -4QUE: 1 write a short note on storage allocation (organisation)?
QUE: 2 what do you mean by activation record? Why this record is maintained by
Compiler? Explain various fields of activation record.
QUE: 3 what do you mean by heap allocation? Explain the following terms related to heap
Allocation.
(i) Fragmentation.(ii) Free list (iii) Reference count.
QUE: 4 Differentiate between
(i) Dynamic and static storage management.(ii) Stack allocation and heap allocation.(iii) Stack binding and dynamic binding.
QUE: 5 write a short note on block structure.
QUE: 6 what is hashing? What are the different types of hashing techniques available?
QUE: 7 write a short note on parameter passing? What is different parameter passing
Mechanism.
QUE: 8 write a short note on symbol table’s organization.
QUE: 9 write a short note on data structures used in symbol table?
QUE: 10 compare various symbol table management techniques.
Unit -5QUE: 1 Define basic blocks and control flow graphs?
QUE:2 write a short note on DAG construction. Explain application & advantages of DAG.
QUE: 3 write a short note on code optimization.
QUE: 4 explain the following optimizing transformations with suitable examples-
(i) Code movement.(ii) Common sub expression elimination
QUE: 5 write and explain data flow equations.
QUE: 6 write a short note on peep-hole optimization.
QUE: 7 write a short note on code generation.
QUE: 8 write a short note on design of code generator.
QUE: 9 what are the problem encountered in code generation.
QUE: 10 write the heuristic algorithm for DAG.
QUE: 11 write a short note on dependency graph.
QUE: 12 construct the DAG for the following basic block-
(a) t1: = a + b
t 2: = c + d
t3: = e - t 2
t4: = t1 - t3
and generate code for these three address statements.
(b) a = b + c
b = b – d
c = c + d
e = b + c
(c) i = 1 ;
J = 2;
Repeat
A[i] = j;
i = i+1;
until (i>10)
(d) ) t1: = 4 * i;
t 2: = a[t1];
t3: = 4 * i;
t4: = b[t3];
t 5 = t 2* t4;
t6 = prod + t 5;
prod = t6 ;
t7 = i+1;
i = t7;
if i<=20;
(e) D: = B * C;
E: = A + B;
B: = B * C;
A: = E – D;
(f) Z = X – Y + X * Y * U – V/W + X + V
QUE: 13 write a short note on local versus global optimization?
QUE: 14 write the algorithm for constructing a DAG from a basic block?
QUE: 15 Describe the process of code generation from DAG?
QUE: 16 write a short note on issue in design of code generator?
QUE: 17 what are the principle sources of optimization?
QUE: 18