0% found this document useful (0 votes)
7 views

model

This document outlines the model exam for the Compiler Design course at Stella Mary's College of Engineering, detailing the structure of the exam, including question types and marks distribution. It includes a variety of questions covering topics such as compiler phases, lexical analysis, syntax trees, type checking, and code generation. The exam is scheduled for November 21, 2024, and consists of multiple parts with questions that assess different levels of understanding and application of compiler design concepts.

Uploaded by

binusha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

model

This document outlines the model exam for the Compiler Design course at Stella Mary's College of Engineering, detailing the structure of the exam, including question types and marks distribution. It includes a variety of questions covering topics such as compiler phases, lexical analysis, syntax trees, type checking, and code generation. The exam is scheduled for November 21, 2024, and consists of multiple parts with questions that assess different levels of understanding and application of compiler design concepts.

Uploaded by

binusha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

NOV24A R21 Register No

STELLA MARY’S COLLEGE OF ENGINEERING


(An Autonomous Institution)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
MODEL EXAM (MAY - DEC 2024)
III Year / V Semester
CS3501- COMPILER DESIGN
Date & Time:21/11/2024 & 9.30 AM to 12.30 PM Marks:100 marks

N ote:
•Write the examination using blue or black pen, Draw neat sketch with pencil (if necessary)
• Use tables or charts (if necessary), Answer all questions)
Bloom’s
Q.No. Question Taxonomy CO
Level
Part-A
(Each Question carries 2 Marks)
1. Define Compiler.
A compiler is a program that translates source code written in a
high-level programming language into machine code or an
Remembering CO1
intermediate code. This process involves several stages,
including lexical analysis, syntax analysis, semantic analysis,
optimization, and code generation.
2. What are the issues of Lexical Analyzer
The lexical analyzer, also known as the scanner, faces several
challenges:
1. Tokenization: Accurately dividing the input into
meaningful tokens.
2. Handling Errors: Identifying and reporting lexical errors Remembering CO1
effectively.
3. Ambiguities: Resolving ambiguities in token recognition.
4. Efficiency: Processing large source files efficiently.
5. Integration: Interfacing seamlessly with the syntax
analyzer.
3. Compare Syntax tree and Parse tree
Aspect Syntax Tree Parse Tree
Concrete
Abstract representation
Definition representation of
of the structure of code
grammar rules
Focuses on semantic Focuses on syntactic
Purpose
meaning structure
Understanding CO2
Contains operators and Contains all grammar
Nodes
operands rule applications
Simplifies by omitting Contains all details of
Simplification
redundant nodes the derivation
Includes all
For a + b: root = +,
Example intermediate steps of
children = a, b
parsing
4. What is the rule to eliminate the left recursion for the gram- Remembering CO2
mar
S → Aa | b ; A →Ac | Sd |ε
Left recursion can be eliminated as follows:
1. Identify left-recursive productions:
o A → Ac and A → Sd are left-recursive.
2. Introduce a new non-terminal A' for recursion:
S → Aa | b
A → SdA' | A'
A' → cA' | ε
5. Differentiate between S-attribute grammar and L
-attribute grammar
S-Attributed
Aspect L-Attributed Grammar
Grammar
Uses only synthesized Uses both synthesized and
Definition Analyzing CO3
attributes inherited attributes
Evaluation
Bottom-up evaluation Top-down evaluation
Order
Suitable for simple Suitable for more complex
Use Case
computations translations
6. What is type checking?
Type checking ensures that operations in a program are applied
to compatible data types. It can be done: Remembering CO3
1. Static Type Checking: Performed at compile time.
2. Dynamic Type Checking: Performed at runtime.
7. Enlist the storage allocation strategies used in run time
Environment.
1. Static Allocation: Memory is allocated at compile time and
does not change.
Analyzing CO4
2. Stack Allocation: Memory is allocated and deallocated in a
Last-In-First-Out (LIFO) order.
3. Heap Allocation: Memory is allocated dynamically at
runtime as needed.
8. What are the problems in code generation
1. Efficient Resource Utilization: Generating code that
minimizes CPU, memory, and registers usage.
2. Target Machine Dependency: Adapting to specific
machine architectures. Remembering CO4
3. Correctness: Ensuring the generated code adheres to the
semantics of the source.
4. Optimization: Balancing optimization with compilation
time.
9. Define Basic Block
A basic block is a sequence of instructions with the following
properties:
Remembering CO5
1. It has a single entry point (no jumps to the middle of the
block).
2. It has a single exit point (no jumps out except at the end).
10. What are the characteristics of peep hole optimization?
Peephole optimization involves making local transformations to
improve code quality. Characteristics include:
1. Small Window: Focuses on a small set of instructions.
2. Redundancy Elimination: Removes unnecessary
instructions. Remembering CO5
3. Strength Reduction: Replaces expensive operations with
cheaper ones.
4. Control Flow Optimization: Simplifies conditional jumps.
5. Machine-Specific: Targets improvements specific to the
hardware.
Part-B
(Each Question carries 13 Marks)
Bloom’s
Q.No. Question Taxonomy CO
Level
11.(a) Explain the various phases of the compiler and trace it with the
Evaluating CO1
program segment (c=a+b*5).
Or
11.(b) i) Explain the input buffering techniques in detail.
ii) Explain how to recognize valid operators of c program using Evaluating CO1
Lex tool.
12.(a) What is ambiguous grammer? Is the following grammar
ambiguous? Remembering CO2
E->E+E /E*E/(E)/id
Or
12.(b) List all LR(0) items for the following grammar
S->AS/b Remembering CO2
A->SA/a
13.(a) Construct a syntax direct definition for constructing a syntax tree
for assignment statements
S->id:=E
E->E1=E2
Applying CO3
E->E1*E2
E->-E1
E->(E1)
E->id
Or
13.(b) Explain about the specification of type checking system. Evaluating CO3
14.(a) Discuss about the code generation algorithm in detail Create CO4
Or
14.(b) Explain about various ways to pass a parameter in a function with
Evaluating CO4
example.
15.(a) For the code
Sum = 0
do 10 i=1, n
10 sum = sum +a(i) *a(i)
Explain the following:
Evaluating CO5
1)Three address code
2) Control flow graph
3) Local common sub expression elimination
4) Invariant code motion
5) Reduction in strength
Or
15.(b) Explain the DAG representation of basic block with example Evaluating CO5
Part-C
(Each Question carries 15 Marks)
16.(a) Explain in detail about predictive Translator with an example Evaluating CO3
Or
16 (b) Illustrate about intermediate languages in detail with example. Understanding CO3

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy