You are on page 1of 2

1. Which one of the following is a top-down parser?

a) Recursive descent parser


b) Operator precedence parser
c) An LR(k) parser
d) An LALR(k) parser

Ans : a

2. Consider the grammar defined by the following production rules:

S --> T * P
T --> U | T * U
P --> Q + P | Q
Q --> Id
U --> Id
Which one of the following is TRUE?
a) + is left associative, while ∗ is right associative
b) + is right associative, while ∗ is left associative
c) Both + and ∗ are right associative
d) Both + and ∗ are left associative

Ans: b

3. The grammar A → AA | (A) | e is not suitable for predictive-parsing because the grammar is?
a) Ambiguous
b) Left recursive
c) Right recursive
d) An operator grammar

Ans : b

4. Which of the following statements is false?


a) Unambiguous grammar has both kind of derivations
b) An LL(1) parser is a top-down parser
c) LALR is more powerful than SLR
d) Ambiguous grammar can’t be LR(k)

Ans : A

5.  Consider the following grammar G.

S→F⎪H
F→p⎪c
H→d⎪c
Which one is true?
S1: All strings generated by G can be parsed with help of LL (1).
S2: All strings generated by G can be parsed with help of LR (1).
a) Only S1
b) Only S2
c) Both S1 & S2
d) None of the mentioned
Ans : D

You might also like