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

COMPILER DESIGN

The document outlines various concepts related to compiler design, including phases of compilation, parsing techniques, code optimization, and regular expressions. It poses questions on constructing parsing tables, syntax trees, and differentiating between compiler and interpreter, among others. Additionally, it includes multiple-choice questions related to lexical analysis, symbol tables, and grammar recognition.

Uploaded by

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

COMPILER DESIGN

The document outlines various concepts related to compiler design, including phases of compilation, parsing techniques, code optimization, and regular expressions. It poses questions on constructing parsing tables, syntax trees, and differentiating between compiler and interpreter, among others. Additionally, it includes multiple-choice questions related to lexical analysis, symbol tables, and grammar recognition.

Uploaded by

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

What are the different phases of compiler?

Explain the phases


in detail. 5
How many phases does analysis consists? What happens in 2+3
each phase.
Construct LALR parsing table for the grammar 5

What is a regular expression? State the rules, which define 2+3


regular expression?
Write down the output of each phase of compilation for the 5
expression.
x = a+b*50
i. Explain the peephole optimization in detail. 5
ii. Explain the machine dependent and independent 5
techniques.
iii. Explain and compare in detail the various implementation 5
forms of three address code.
i. Translate the arithmetic expression a*-(b+c) into syntax 4
tree.
ii. What do you mean by code optimization? Explain the 2+4
basic blocks and their optimization.
iii. Write the syntax directed definition for following 5
grammar to produce the three address codes for
assignments
S -> id = E
E -> id
i. Consider the following grammar: 8

a.Show steps of shift-reduce parsing for the input string


id+id*id.
b.Identify conflicts during the parsing.
ii. Describe the L- attributed definitions. 7
How L attributed definitions are evaluated?
i. Explain the principle sources of code optimization with 10
example.
ii. Differentiate between top-down parsing and bottom-up 5
parsing.
i. What is machine dependent code optimization? 5
ii. What is the purpose of code optimization? Explain in 7
detail about loop Optimization with example
iii. What are the types of three address statements. 3
Describe the functions performed in synthesis phase
5
Define parser. Mention the basic issues in parsing.
2+3
Find the First and Follow of the below given grammar: 5
E->TE’
E’->+TE’/ε
T->FT’
T’->*FT’/ε
F->(ε)/id
Give the LALR parsing table for the grammar 5
S -> L = R / R
L -> * R / id
R -> L
Differentiate token, pattern, lexeme 5

What do you mean by a syntax tree? 2


Left factor the following grammar: 3
A → aAB / aBc / aAc.
Differentiate between top-down parsing and bottom-up 5
parsing.
Explain, why SLR and LALR are more economical to 5
construct than canonical LR?
What do you mean by three-address code representation? 10
Explain with example.
Construct an SLR parsing table for the above grammar. 5
E -> E + T
E -> T
T -> T * F
T -> F
F -> (E)
F-> id
Write the code sequence for the d=(a-b)+(a-c)+(a-c) 5
Define Peephole optimization. 2+3
Write the characteristics of peephole optimization.
Differentiate compiler and interpreter. 5
Consider the following grammar 10
E → E+T | T
T → T*F | F
F → (E) | id
Find the CLR parser for the above grammar.
What do you mean by S-attributed definition and how they 5
are evaluated? Explain with example.

Explain the phase of a compiler with block diagram. 7


Construct the grammar: 5

Compute the complete LR(0) collection of item set from


above grammar.

State the rules, which define regular expression? 3


The action of parsing the source program into proper syntactic D
classes is called
(A) General syntax analysis
(B) Interpretation analysis
(C) Syntax analysis
(D) Lexical analysis
What is the similarity between LR, LALR and SLR? a

a) Use same algorithm, but different parsing table


b) Same parsing table, but different algorithm
c) Their Parsing tables and algorithm are similar but uses
top-down approach
d) Both Parsing tables and algorithm are different
LR stands for D
(A) Left to right
(B) Left to right reduction
(C) Right to left
(D) Left to right and right most derivation in reverse
Semantic errors can be detected at C
(A) Compile time only
(B) Run-time only
(C) Both (a) and (b)
(D) None of these
Synthesized attribute can be easily simulated by a A
(A) LR grammar
(B) LL grammar
(C) Ambiguous grammar
(D) None of these
Uniform symbol table _________ c
a) Has all constants in the program
b) Permanent table of rules in the form of patterns for
matching with the uniform symbol table to
discover syntactic structure
c) Consists of full or partial list of the tokens as they appear
in the program created by Lexical
analysis and used for syntax analysis and interpretation
d) A permanent table which has all key words and special
symbols of the language in symbolic
form
Which of these is true about LR parsing? c
a) Is most general non-backtracking shift-reduce parsing
b) It is still efficient
c) Is most general non-backtracking shift-reduce parsing &
It is still efficient
d) None of the mentioned
The lexical analyzer takes ____ as input and produces a list C
of ___ output.
(A) Machine code, mnemonic
(B) Tokens, source code
(C) Source code, tokens
(D) Both a and b
Symbol table can be used for D
(A) Storage allocation
(B) Checking type compatibility
(C) Suppressing duplication of error messages
(D) All of these
Lexical analysis is about breaking a sequence of characters A
into
(A) Tokens
(B) Lines
(C) Groups
(D) Packets
An LALR(1) parser for a grammar can have shift-reduce (S- b
R) conflicts if and only if ___________
a) The SLR(1) parser for G has S-R conflicts
b) The LR(1) parser for G has S-R conflicts
c) The LR(0) parser for G has S-R conflicts
d) The LALR(1) parser for G has reduce-reduce conflicts
Consider the following two statements: a
P: Every regular grammar is LL (1)
Q: Every regular set has LR (1) grammar
Which of the following is TRUE?
a) Both P and Q are true
b) P is true and Q is false
c) P is false and Q is true
d) Both P and Q are false
A bottom-up parser generates C
(A) Left-most derivation in reverse
(B) Left-most derivation
(C) Right-most derivation in reverse
(D) Right –most derivation
The translator program used in assembly language is called A
(A) Assembler
(B) Interpreter
(C) Compiler
(D) Translator
The output of lexical analyzer is B
(A) Strings of characters
(B) A set of tokens
(C) Syntax tree
(D) A set of regular expressions
Linear analysis is called ____ in a compiler. D
(A) Lexical analysis
(B) Scanning
(C) Testing
(D) Both a and b
CFG (Context Free Grammar) can be recognized by a D
(A) Push down automata
(B) Finite state automata
(C) 2 way linear bounded automata
(D) Both a and c
The bottom-up parsing method is also called A
(A) Shift reduce parsing
(B) Predictive parsing
(C) Recursive descent parsing
(D) None of these
Which of the following symbol table implementation has the D
minimum access time?
(A) Self-organizing list
(B) Linear
(C) Search tree
(D) Hash table
Which parser is most powerful in the following parsers? C
(A) SLR
(B) Operator Precedence
(C) Canonical LR
(D) LALR
A compiler translates high level programs into low level D
programs, which is called as
(A) Beta code
(B) Compiled code
(C) Source code
(D) Object code
The top-down parsing method is also called B
(A) Operator precedence parsing
(B) Recursive descent parsing
(C) Shift reduce parsing
(D) None of these
The cost of developing a compiler is proportional to D
(A) Flexibility of the available instruction set
(B) Complexity of the architecture of the target machine
(C) Complexity of the source language
(D) All of these
Grammar of the programming is checked at _____ phase of A
compiler.
(A) Syntax analysis
(B) Semantic analysis
(C) Code generation
(D) Code optimization

You might also like