You are on page 1of 3

Subject: Compiler Design Subject Code: KCS-502

Session: 2021-22 Branch: CS-V (A/D)

Assignment-1
1. How does finite automata useful for lexical analysis? Construct the NFA and DFA for the
following regular expression (a + b)* abb.
2. What do you understand by preliminary scanning? Describe the ways how lexical analyzer
is grouped to make a pass.
3. Construct minimum state DFA for the following regular expression (a | b)* a (a | b).
4. What is a compiler. Explain role of different phases when source program is translated into
target program. What are different tools used in compiler construction.
5. Describe role of lexical analyzer in compilation process. What are various issue in lexical
analysis. What are various methods to handle errors in lexical analysis phase?
6. How lexical analyzer removes white spaces from a source file? Explain the buffer input scheme
for scanning the source program.
7. How a bootstrapping of a compiler to more than one machine is done? Discuss.

Assignment -2
1. What is grammar? Write the grammar for palindrome of {0,1}
2. Consider the context-free grammar
S⇨aSbS/bSaS/€
Derive the string w=bbabaabbaa
a. Left most deviation.
b.Right most deviation.
c. Derivation Tree.
3. Define the term parsing. Explain Backtracking parser with suitable example.
4. Construct a predictive parsing table for the following grammar:
S→A
A → aB│Ad
B → bBC│f
C→g
5. Test whether the following grammar is LL (1).
S → AB│eDa
A → ab│c
B → dC
C → eC│Ɛ
D → fD│Ɛ
6. Why LR parsing is good and attractive?Explain the rules for GOTO operation in LR parsing.
Assignment Sheets-3
1. Translate the expression –(a + b) * (c + d) + (a + b + c) into
(a) Quadruples (b) Triples (c) Indirect Triples
2. What is SDD and SDTS. What is role of these in compilation? What is synthesize and
inherited attribute. What is S-attributed definition?
3. What is symbol table? Discuss the various approaches used for organization of symbol
table.
4. What are the different data structures for the symbol table implementation? Explain
these with suitable example.
5. Explain various allocation storage strategies. Which storage allocation model is to be
used if a language permits recursion?
6. What are the various types of errors that may appear in compilation process? Explain
the function of Error handling phase of a compiler.

Assignment Sheets-4
1. Explain activation record and display structure.
2. Discuss the following parameter passing technique with suitable example:

Call by value

Call by name

Call by reference

3. What do you mean by heap allocation? Explain the following terms related to heap
allocation:

• Fragmentation
• Free List
• Bit Map
• Reference Count
4. What do you understand by Lexical phase error and syntactic phase error? Discuss various
methods for recovery of errors.
5. Explain the implementation of simple stack allocation scheme
while Run- Time administration.

Assignment Sheets-5
1. What are the major techniques used for optimization?
2. Consider the following three address code statements:
(i) PROD=0;
(ii) I=1;
(iii) T2=addr(A)-4;
(iv) T4=addr(B)-4;
(v) T1=4*I;
(vi) T3=T2[T1];
(vii) T5=T4[T1];
(viii) T6=T3*T5;
(ix) PROD=PROD+T6;
(x) I=I+1;
(xi) If I<=20 GOTO (v)

Perform Optimization on the above code.


3. Explain how DAG helps in elimination of common sub expression. Construct the DAG for
following basic block
D=B*C
E=A+B
B=B*C
A=E–D
4. What do you mean by code optimization? What are the areas of optimization?
5. Explain the concept of global data flow analysis in code optimization respect with suitable
example.

You might also like