You are on page 1of 5

CS6660 Compiler Design 16 MARKS QUESTIONS

UNIT 1
INTRODUCTION TO COMPILERS
PART-B

1. Explain the various phases of compiler in detail. Also write down the output for the following
expression after each phase a=b*c-d or a=b+c*50
2. Briefly explain the compiler construction tool.
3. Describe how various phases should be combined as a pass in a compiler.
4. Elaborate on grouping of phases in a compiler.
5. What are the phases of the compiler? Explain the phases in detail.
6. Write down the output of each phase for the expression a: = b + c * 50.

UNIT 2
LEXICAL ANALYSIS
1. Write a short note on token specification.
2. Write about R.E.
3. Explain in detail about input buffering.
4. For the R.E. (a/b)*a(a/b). Draw the NFA. Obtain DFA form NFA. Minimize
DFA using new construction. Write down the algorithm wherever necessary.
a) (a/b)* abb
b) (a/b)* a (a/b).
c) (a/b)* a (a/b).
d) (a/b)* a(a/b) (a/b)
e) (a/b)* abb (a/b)*
5. Explain the Role of lexical analyzer in detail.

6. Give the minimized DFA for the following expression (a/b)* abb (same as 4 question pbm.).
7. Explain the optimization of DFA-based patte n matchers.
8. Write the tool for generating lexical analyzer

SNS College of Engineering Department of CSE


CS6660 Compiler Design 16 MARKS QUESTIONS

UNIT 3
SYNTAX ANALYSIS
1. What is FIRST and FOLLOW? Explain in de a l with an example. Write down the necessary
algorithm.
First and Follow:
1. E->E+T/T
T->T*F/F
F-> (E)/id

2. S-> (L)/a
L->L, S/a

3. E->E | T/T
T->T&F/F F->! F/ (E)/1/0

Top do n parsing:
1. S->a/^/ (T) T->T, S/S

2. S->a/^/(R) T->S, T/S R->T


Input for both problem for 1 and 2 : ( a, (a, a))
(((a, a), ^, (a)), (a))
Shift reduce parsing
1. S-> (L)/a L->L, S/a
Input :( a, (a, a)) (a,((a, a),(a, a)))

2. S->aZ A->bY
B->X
Input: XYZ

3. E->E+E/E*E/id/ (E)/-E Input: id+id*id


4. S->aABe
A->Abc/b
B->d
Input: abbcde
5. S->ictS/ictSeS/a C->b
Input: ibtibtaea
6. S->a/^/ (T)
T->T, S / S
7.S->a/^/(R) T->S, T/S R->T
Input for both 6 & 7 problem :( a, (a, a))
(((a, a), ^, (a)), (a))
8.E->E+E/T T->T*F/F F-> (E)/id
Input: id+ (id+id) id*(id+id)

SNS College of Engineering Department of CSE


CS6660 Compiler Design 16 MARKS QUESTIONS

Operator precedence parsing:

1. E->E+E/E*E/id Input: id+id*id


id*id+id

2. E->E+E/T
T->T*F/F
F-> (E)/id
Input: id+ (id+id) id*(id+id)

3. S-> (L)/a L->L, S/S


Input: (a, a) (a, (a, a))
(a, ((a, a),(a, a)))

4. id+id*id
5. id*(id^id)-id/id

6. id+ (id*id)

LR (0):

1. E->E+E/T T->T*F/F F-> (E)/id

2. E->E | T/T
T->T&F/F F->! F/ (E)/1/0

3. S->iSeS/iS/a

4. E->E+E/ E*E/(E)/id

5. E->EsubEsupE
->EsubE ->EsupE -> {E}/c
LL (1):
1. S->AaAb/BbBa
A->
B->
Check whether the grammar is LL (1) but not SLR (1)

LR (1):
1. S->CC
C->Cc
C->d

SNS College of Engineering Department of CSE


CS6660 Compiler Design 16 MARKS QUESTIONS

2. S->Aa/bAc/Bc/bBa A->d
B->d
Check whether the grammar is LR (1) but not LALR (1)
LALR:
1. S->CC
C->Cc
C->d
2. S->Aa/bAc/dc/bda A->d
Check whether the grammar is LALR (1) but not SLR (1)

UNIT 4
SYNTAX DIRECTED TRANSLATION & RUN TIME ENVIRONMENT

1. Explain intermediate language with e.g.

2. What is three address codes. Mention the types. How would you implement the three address
statement with e.g.
3. Explain about declaration with e.g.

4. Describe the case statement.

5. How would you generate the intermediate code for the Boolean expression?

6. What are the various ways of calling the procedure? Explain in detail.

7. Explain how declarations are done in a procedure using syntax directed translation scheme.

8. How would you generate the intermediate code for the flow of control statements and control
flow expression in the statement. Explain in detail with e.g.

9. Explain procedure call with e.g.

10. Describe the methods for generating syntax directed definition for control statements.

UNIT 5
CODE OPTIMIZATION AND CODE GENERATION

1. What are the issues in the design of code generator? Explain in detail.
2. Discuss about the run time storage management.
3. Explain basic blocks and flow graphs.

SNS College of Engineering Department of CSE


CS6660 Compiler Design 16 MARKS QUESTIONS

4. Explain about transformation on a basic block.

5. Write a code generation algorithm. Explain about the descriptor and function getreg().Give an
example.
5. Write short notes on peephole optimization
6. Explain DAG representation of basic blocks.
7. Explain principle sources of code optimization in details.
8. Explain the Source language issues with details.
10. Explain the Storage organization strategies with examples.
11. Explain storage allocation strategy.
12. Explain about Parameter passing.
13. Explain about the local names in runtime storage managements.
14. Explain about activation records and its purpose.
15. Explain about Optimization of basic blocks.
16. Explain the various approaches to compiler development.
17. Explain simple code generator with suitable example.
18. Discuss about the following:
a) Copy Propagation b) Dead-code Elimination and c) Code motion

SNS College of Engineering Department of CSE

You might also like