Categories

Compiler design-2

CSE - Compiler design - Questions and solutions-2
Question:-
Option (A)
1 only
Option (B)
1 and 2
Option (C)
1, 2 and 3
Option (D)
4 only
Correct Option:
C
Question Solution:
Simple two-pass assembler
(1) Allocates space for the literals.
(2) Compute the total length of program (syntax analysis)
(3) Builds the symbol table for the symbols and their values
Question:-
Option (A)
Syntactic error
Option (B)
Lexical error
Option (C)
Both lexical & semantic
Option (D)
Semantic error
Correct Option:
A
Question Solution:
In this the syntactic error or syntax error due to fro.
Question:-
Option (A)
Local optimization
Option (B)
Loop optimization
Option (C)
Constant folding
Option (D)
Strength reduction
Correct Option:
C
Question Solution:
Constant folding is the process of simplifying constant expression at compiles time.
In some compiler, constant folding is done early so that statements such as array initializers can accept simple arithmetic expressions. It can be done in complier’s front end.
Question:-
Option (A)
n1 < n2 < n3
Option (B)
n1 = n3 < n2
Option (C)
n1 = n2 = n3
Option (D)
n1 ≥ n3 ≥ n2
Correct Option:
B
Question Solution:
SLR parser has same number of states as in LALR. So no. of states in SLR = No. of states in LALR < No. of states in LR