You are on page 1of 3

1)

Consider the grammar {E -> E + E | E * E |id}. For the string “id1 + id2 * id3”, in a
shift-reduce parsing, the rule applied for the fourth reduction is

(A) E -> E + E
(B) E -> E * E
(C) E -> id
(D) None of the other options

Ans: (B): E -> E * E

2)
For the grammar
S → AB | C
A → bA | a
B → abbS | bS | ε
C → bC | ε
Follow(A) is
(A) a, b, $
(B) a, $
(C) a, b
(D) b, $

Ans: A

3)
In shift-reduce parsing, handle is at

(A) Anywhere in the stack


(B) Bottom of the stack
(C) Top of the stack
(D) Nowhere in the stack
Ans: C
Explanation: The handle is at the top of the stack in shift-reduce parsing.

4)
A bottom-up parser generates

(A) Left-most derivation in reverse


(B) Right-most derivation in reverse
(C) Left-most derivation
(D) Right-most derivation
Ans: B: Right-most derivation in reverse

Explanation:
A bottom-up parser generates right most derivation in reverse.
5)
In shift-reduce parsing, an accepted input string reduces to

(A) Start symbol


(B) $
(C) Null
(D) None of the other options

Ans: A: Start symbol

Explanation: In shift-reduce parsing, an accepted input string is reduced to start symbol

6)
In Operator Precedence parsing handle is

(A) Between <. and .>


(B) After ·>
(C) Before <·
(D) None of the other options

Ans: A

7)
An operator-precedence parser is a

(A) Shift-reduce parser


(B) Bottom-up parser
(C) Parser constructing derivation in the reverse
(D) All of the other options

Ans: D

8)
An optimizer Compiler __________

(A) Is optimized to occupy less space


(B) Is optimized to occupy less space & Optimize the code
(C) Optimize the code
(D) None of the mentioned

Ans) d)

Explanation: An optimising compiler is a computer programme that strives to minimise or


maximise specific characteristics of an executable programme.

9)
For the grammar rule T → xyyS | yS, Firstop(T) equals

(A) {x}
(B) {x, y, S}
(C) {x, y}
(D) {S}
Ans: B

10)
By considering the rule B → tqqS, which of the precedence relations between t and q
can be inferred?

(A) t ≐ q and q ≐ q
(B) t ≐ q only
(C) q ≐ t and t ≐ q
(D) q ≐ t and q ≐ q

Ans: A

You might also like