0% found this document useful (0 votes)
23 views6 pages

Assignment Compiler

The document is an assignment on compiler design, covering various topics such as lexical analysis, parsing techniques, and code generation. It includes multiple-choice questions, short questions, and long questions aimed at assessing knowledge in compiler components and their functions. Key concepts addressed include DFA, lexical analyzers, parsers, intermediate code, and optimization techniques.

Uploaded by

rajkumarkus2004
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)
23 views6 pages

Assignment Compiler

The document is an assignment on compiler design, covering various topics such as lexical analysis, parsing techniques, and code generation. It includes multiple-choice questions, short questions, and long questions aimed at assessing knowledge in compiler components and their functions. Key concepts addressed include DFA, lexical analyzers, parsers, intermediate code, and optimization techniques.

Uploaded by

rajkumarkus2004
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/ 6

ASSIGNMENT

Compiler design

Which component of the compiler performs lexical analysis?

a) Parser

1 b) Scanner

c) Code Generator

d) Syntax Analyzer

What does DFA stand for in lexical analysis?

a) Data Flow Automata

2 b) Deterministic Finite Automaton

c) Deterministic Finite Algorithm

d) Data Finite Automata

What is the role of a lexical analyzer?

a) To parse the syntax

3 b) To generate code

c) To recognize tokens

d) To optimize code

Which of the following tools is commonly used for lexical analysis?

a) YACC

4 b) LEX

c) Bison

d) Flex

5 Regular expressions are converted to:

a) Context-Free Grammars

b) DFA
ASSIGNMENT
Compiler design

c) Syntax Trees

d) Three Address Code

Minimizing DFA helps in:

a) Increasing complexity

6 b) Reducing number of states

c) Eliminating syntax errors

d) Removing semantic errors

The role of the parser is to:

a) Perform optimization

7 b) Generate object code

c) Check syntax

d) Recognize tokens

Top-down parsing is also known as:

a) Shift-reduce parsing

8 b) Recursive descent parsing

c) Operator precedence parsing

d) Bottom-up parsing

Which parser uses look ahead symbols?

a) LL(1)

9 b) LR(0)

c) LALR

d) SLR

10 In LR parsing, the shift-reduce action is used to:


a) Detect syntax errors
b) Derive grammar rules
ASSIGNMENT
Compiler design

c) Replace handle with non-terminal


d) Translate expressions
YACC tool is used for:

a) Lexical analysis

11 b) Code generation

c) Parsing

d) Optimization

Which of the following is not a type of parser?


a) LL
12
b) LR
c) DFA
d) LALR
Intermediate code is:
a) Machine dependent
13 b) Human-readable
c) Machine-independent
d) Redundant
Three-address code typically has:
a) Two operands
14 b) Three operators
c) Three operands
d) One operand
Type checking is done to ensure:
a) Grammar correctness
15 b) Type compatibility
c) Parsing success
d) Code optimization
Which structure is used to represent intermediate code?
a) DAG
16 b) Syntax Tree
c) Stack
d) Parse Table
Syntax directed definitions are used in:
a) Parsing
17 b) Token generation
c) Intermediate code generation
d) Optimization
18 What is the purpose of a syntax-directed translation scheme?
a) Lexical analysis
b) Semantic analysis
c) Token parsing
ASSIGNMENT
Compiler design

d) Code optimization
The run-time stack is used for:
a) Token generation
19 b) Storage of activation records
c) Optimizing code
d) Register allocation
Heap memory is used for:
a) Temporary variables
20 b) Static variables
c) Dynamic memory allocation
d) Loop variables
What is the main issue in code generation?
a) Speed
21 b) Register allocation
c) Syntax parsing
d) DFA construction
Non-local data can be accessed using:
a) Stack pointer
22 b) Display or static links
c) Dynamic link
d) Base pointer only
Stack allocation is used for:
a) Constants
23 b) Heap
c) Local variables
d) Global variables
What is a simple code generator responsible for?
a) Creating syntax trees
24 b) Producing machine code
c) Grammar checking
d) Intermediate code
Code optimization is done to:
a) Minimize syntax errors
25 b) Reduce execution time
c) Increase code size
d) Improve lexical tokens
Peep-hole optimization is applied to:
a) Lexical tokens
26 b) Intermediate code
c) Assembly code
d) Grammar
DAG stands for:
a) Directed Acyclic Grammar
27 b) Direct Access Graph
c) Directed Acyclic Graph
d) Data Acyclic Graph
ASSIGNMENT
Compiler design

What is optimized in basic block optimization?


a) Stack
28 b) Heap
c) Control Flow
d) Instruction sequence
Global data flow analysis helps in:
a) Finding tokens
29 b) Lexical simplification
c) Optimization across blocks
d) Parser construction
A major goal of data flow analysis is:
a) Minimize parsing
30 b) Identify dead code
c) Simplify regular expressions
d) Generate parse trees

SHORT QUESTIONS

1 Define a compiler. How it works ?


2 What is lexical analysis?
3 What is the difference between DFA and NFA?
4 How is input buffering handled?
5 What is a context-free grammar?
6 Define LL(1) grammar.
7 What is the difference between top-down and bottom-up parsing?
8 What is a shift-reduce parser?

9 What is a three-address code?

10 What is the purpose of syntax-directed definitions?


11 What is type checking?
12 Differentiate between syntax tree and DAG.
13 What is storage organization in a compiler?
14 Define stack allocation.
15 How does a compiler manage heap memory?
16 What is the use of an activation record?
17 Define code optimization.
18 What is peep-hole optimization?

LONG QUESTION

1 Explain the structure of a compiler in detail.


2 Describe the process of lexical analysis with an example.
ASSIGNMENT
Compiler design

3 Convert a regular expression into a DFA and minimize it.


4 Explain the construction of an SLR parsing table.
5 Describe recursive descent parsing with a sample grammar.
6 Write a grammar for arithmetic expressions and construct its LL(1) table.
7 Discuss different forms of intermediate code with examples.
8 Explain syntax-directed translation with evaluation order.
9 Translate an expression into three-address code and explain type checking.
10 Explain the run-time environment and memory management.
11 Describe access to non-local data on the stack.
12 Design a simple code generator and discuss the steps involved
13 Describe different code optimization techniques.

14 Explain DAG construction and its use in optimization.

15 What is global data flow analysis? Discuss with examples.

You might also like