Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 16

UNIT-1

1.) Differetiate between one pass and multi-pass compiler?

2.) Construct minimum state DFA for regular expression (0 + 1)* 00 + 01.

3.) What is Lex? Explain with suitable code.

4.) Write short notes on:

(i) Compiler writing tools

(ii) Role of Lexical Analyzer

5.) What is a compiler?

6.) Explain the different phases of compiler with example.

7.) Convert b (a + b)* a into a DFA.

8.) Consider the following program:

main()

int x, y, z;

z = x + y;

List down the lexemes, tokens and the attributes of the tokens, at the end of
lexical analysis of the above program.

9.) Explain the various phases of compiler with the help of a diagram. Explain
the kind of transformation done on the source program by the individual
phases of the compiler on the statement position = initial + rate * 60.

10.) Write short notes on:

(i) Single pass vs Multi pass compilers


(ii) Bootstrapping

11.) What is symbol table?

12.) Explain the phases that constitute the front end of a compiler.

13.) What is LEX compiler? Write a LEX program to recognize tokens identifier,
number and relational operator.

14.) Construct a DFA over alphabet ∑ = {0,1}, which accepts the set of strings
either start with 01 or end with 01.

15.) Define compiler, interpreter and translator.

16.) Describe the different phases of a compiler for given input string

(b + c) * (b + c) * 2.

17.) Describe the various components of a compiler and also draw the block
diagram of a compiler.

18.)
19.)

20.) Given the language L = {ab, aa, baa}, derive L*. Explain each step in details.

UNIT-2
1.) Differentiate between top down and bottom up parser.

2.) Why there is a need to eliminate left recursion in top down parsing,
construct predictive parsing table for:

S → iEtSS1/a

S1 → eS/ε

E→b

3.) Consider the following grammar:

S → AaAb/ BbBa

A→ε

B→ε
Test whether the grammar is LL(1) or not and construct a predictive
parsing table for it.

4.) ) Write an algorithm to obtain the First() and following table, left factoring
the given grammar:

E→E+T/T

T→ T* F / F

F→ (E) / id

Also find first and follow ( ).

5.) What do you mean by left recursion? Support your answer with example.

6.) Give the rules to find out FIRST and FOLLOW of Non terminals of grammar.
For the given grammar find out FIRST and follow:

E → TE1

E1 → + TE1/ ε

T → FT1

T1 → *FT1

F → (E)/ id

7.) Construct SLR table for the given grammar:

S → AA

S → aA

A→b

8.) Define context free grammar.

9.) Explain shift-Reduce Parser and its working. Parse

the string id + id * id for the grammar


E → E + T/T using

T → T * F/F

F → id

10.) Consider the following grammar:

S→ CC

C → cC

C→d

Draw SLR Parse table.

11.) Write the four component of content free grammar

12.) Consider the following grammar:

S → 1 AB/ ε

A → 1 AC/OC

B → OS

C→1

and test that whether the grammar is LL(1) or not.

13.) Consider the following grammar:

S → AA

A → aA

A→b

and construct the LALR passing table.

14.) Explain the YACC tool in detail.

15.) Compare the Shift Reduce Parser with predictive parser.

16.) Test whether the grammar is LL.(1) or not and construct a predictive
parsing table for it.
S → AaAB/BbBa

A→ε

B→ε

17.) Construct the SLR parsing table for the following

grammar:

S → xAy/xBy/xAz

A → As/b

B→b

18.) Let a Context Free Grammar CFG {N, T, P, S} be N = {S), T= (a, b), Starting
symbol = S. P =S → SS | aSb | ε. One derivation from the above CFG is
"abaabb". Draw the tree representation.

19.) Convert the following CFG into CNF:

S → ASA / aB

A → B/S

B → b/ε.

20.) Explain the SLR algorithm with an example.

UNIT-3
1.) Describe Boolean expression and procedure calls.

2.) What is the role of semantic analyzer? Explain synthesized and inherited
attributes with example.

3.) What is 3 Address code? Translate the expression.


(a + b)*(c + d)+(a + b + c) into:

(i) Quadruples

(ii) Tripal

(iii) Indirect Tripal

Representation with brief explanation.

4.) Write short notes on:

(i) Translation of assignment strategies

(ii) Control flow

5.) For the given grammar

E → E1 + T

E → E1 - T

E→T

T → T1 * F

T →T1/F

T→F

F → (E)

F → num

Give the semantic rule to represent syntax directed definition for arithmatic
expression and draw annotated parse tree for 4-6/3+ 5.

6.) For the given arithmetic expression,

Q : = - b * (c + d)

give the quadruple, triple and indirect triple representation with brief
explanation.

7.) What is dependency graph? Give example.


8.) Explain S-attributed and L-attributed definitions.

Give examples to support your answer.

9.) What are quadruples, triples and indirect triples. Give their examples.

Give the quadruples, triple and indirect triple representation of the statement

X = (a + b)* + -c/d.

10.) Translate the expression a < b and c > d to three-address code.

11.) Write the three address code for the following program fragment:

while (P < q and r > s) do

if P = 1 then q = q + 1

else

while (p < = s) do

P=P+3

12.) Translate the given expression:

A = - b * (c + d)

Into

(i) Quadruples

(ii) Triples

(iii) Indirect Triples

13.) Write short notes on:

(i) Postfix Notation

(ii) Translation of procedure calls.

14.) Define Annotated Parse tree.

15.) For given production:


E → E1 + T

E → E1 - T

E→T

T → (E)

T → id

T → num

Construct the annotated parse tree x + 6 + x.

16.) Consider the following grammar:

E→E+T

E→T

T→T*F

T→F

F → id

And write:

(i) Postfix representation

(ii) Syntax tree representation

(iii) Three address code representation

17.) Compare Parse Tree and Syntax Tree.

18.) Explain in details the construction of a syntax tree for a binary infix
arithmetic expression:

a + a * (b – c) + (b - c) * d

19.) Describe in detail the outcome of Lexical Analysis, Semantic Analysis,


Intermediate Code, Code Optimization and Code Generator, while the
translation of an assignment statement: p = x + v * 60.
20.) What is top down evaluation? Explain.

UNIT-4
1.) What is dynamic storage allocation? Explain allocation strategies.

2.) What is different parameter passing method. Explain with example.

3.) What is the use of symbol table. describe ways to implement symbol table
and write the various fields of symbol table

4.) Explain about Activation tree.

5.) Define local and global variable.

6.) Explain about Activation Record.

7.) Explain run time storage organization.

8.) Explain activation record and its fields.

9.) Discuss the following parameter passing techniques with suitable example:

(i) Call by value

(ii) Call by reference

(iii) Call by name

10.) Explain different data structures used for symbol table organization

11.) Differentiate between static, stack and heap allocation strategies.

12.) Draw the activation tree for the following code:

...

printf("Enter Your Name:");

scanf("%s", username);

show_data(username);

printf("Press any key to continue...");


int show_data(char *user)

printf("Your name is %s", username);

return 0;

13.) Explain Structural, Linear and Hybrid types of intermediate


representations with examples.

14.) Explain in details Lexically-Scoped Symbol Tables.

15.) Explain in detail the strategies for reducing fragmentation in heap


memory.

16.) Explain the working of procedures and its activations and run-time. Write
with suitable example.

17.) Give a brief explanation on static allocation and dynamic allocation with
respective diagram.

18.) Discuss the role of symbol table in run- time environment with example.

UNIT-5
1.) Define the term loop optimization explain any two loop optimization
techniques.

2.) Explain in brief issues in the design of code gencrator.

3.) Write short notes on:

(i) Global data flow analysis

(ii) Register allocation


4.) What is the code optimization? Write a rule of basic block, translate the
following code to basic block and flow graph:

1 PROD = 0

21=1

3 T2 = addr(A)-4

4 T4 = addr(B)-4

5 T1 = 4*i

6 13 = T2[T1]

7 T5 = T4[T1]

8 T6 = T3*T5

9 PROD = PROD + T6

10 i = i + 1

11 IF I < = 20 GOTO 5.

5.) Translate the following code to basic block and flow graph

Sum : = 0

U:=1

While (I <= 10) do

Sum : = sum + a [ 2 * I ]

I:=I+i

Avg = sum/ i

6.) Generate the code sequence for assignment

a: = x - y + x - z + x - z .
7.) What is basic block?

8.) Explain various code optimization techniques.

9.) Consider the following expression, apply the algorithm of code generation
on it.

a = (p + q) - ((r + s) - t)

10.) Describe the flow-graph.

11.) Construct the following expression with its three

address code:

a = (p + q) - ((r+ s) - t)

t1 = p+ q

t2 = r + s

t3 = t2 – t

a = t1 +t2

generate the target code for the above expressions.

12.) For given structure:

Exp(x)

int p = 1;

for(I = 2; i <= x; I ++)

p=p*i

return(p);

Construct basic blocks and control data flow.


13.) What is Global Data Flow Analysis perform with one suitable example.

14.) Explain the Partition Algorithm for Basic Blocks.

15.) Create a Control Flow Graph for the following code and explain the steps
in details:

// assume an external input-output array: int a []

void quicksort( int m, int n) {

Int i, j, v, x; // temps

if (n <= m) return;

i=m-1

j=n

v = a[n];

while(1) {

do i =i + 1;

while( a[i]<v];

do j=j-1;

while(a[j]>v);

if(i>=j) break;

x = a[i];

a[j];

a[j] = x;

} //end while

X = a[i];

a[i] = a[n];

a[n] = x;
quicksort(m,j);

quicksort(i+1,n);

} //end quicksort

16.)

17.) Explain with examples, Target language, IR type, Selection of instruction,


Register allocation and Ordering of instructions with respect to Code
Generator.

18.) Write the differences between local and global optimization.

19.) Explain the following optimizations with example:

(i) Finding local common subexpression

(ii) Dead code elimination

20.) Write short notes on:


(i) The target machine

(ii) Loop in variant computation

You might also like