Sub Code: BCST602 ROLL NO……………..……………..
SPECIAL BACK PAPER EXAMINATION, 2023 – 24
3rd
yr B.Tech. – Computer Science & Engineering
COMPILER DESIGN
Duration: 3:00 hrs Max Marks: 100
Note: - Attempt all questions. All Questions carry equal marks. In case of any ambiguity or missing data,
the same may be assumed and state the assumption made in the answer.
Q 1. Answer any four parts of the following. 5x4=20
a) What is a compiler? Explain the major data structures used in a compiler.
b) Describe the role of lexical analysis in the compilation process. How does
input buffering facilitate lexical analysis?
c) Differentiate between a front-end and a back-end compiler. Provide
examples of tasks handled by each.
d) What is a syntax tree? Explain its role in syntax-directed translation and how
it aids in semantic analysis.
e) Discuss the differences between SLR and LALR parsers. What are the
advantages of LALR parsing over SLR?
f) What is type checking in a compiler? Explain the role of a type system in
ensuring type safety.
Q 2. Answer any four parts of the following. 5x4=20
a) Describe the concept of function overloading and how a compiler handles it
during type checking.
b) Explain the storage organization of a run-time environment. What are the
common storage allocation strategies used?
c) What is intermediate code generation? Describe its role and importance in
the compilation process.
d) What is back patching in code generation? Describe its purpose and provide
an example of its application.
e) What is code optimization? Discuss the objectives and benefits of
optimizing code in a compiler.
f) What is symbolic debugging? How does it aid in debugging optimized
code?
Q 3. Answer any two parts of the following. 10x2= 20
a) Describe the process of dead code elimination with an example. How does this
optimization contribute to reducing code size and improving performance?
b) Explain the process of generating assembly code from DAG representations.
Illustrate with an example of a basic arithmetic expression.
c) Given the following grammar:
E→E+T|T
T→T*F|F
F → ( E ) | id
Construct a parse tree for the input string id + id * id.
Q 4. Answer any two parts of the following. 10x2= 20
a) Describe the procedure of constructing syntax trees for an expression involving
both arithmetic and boolean operations. Include examples of S-attributed and L-
attributed definitions.
b) Describe the input buffering techniques used in lexical analysis. How do they
help in efficient token recognition and processing?
c) Given the following CFG:
S → AB
A → aA | ε
B → bB | ε
Perform an LL (1) parsing on the string aaabb. Construct the parse table and show
how the parser processes the input string.
Q 5. Answer any two parts of the following. 10x2= 20
a) Compare and contrast various parsing techniques (e.g., LL, LR, SLR, LALR). Discuss
their applicability to different types of grammars with examples.
b) Explain loop optimization techniques such as loop unrolling and loop fusion.
Provide examples of how these techniques can enhance performance.
c) Discuss the role of procedure calls in code generation. How does the code
generator handle parameter passing, return values, and activation records?
**********