Consider the following grammar.
S → ( S )
S → x
Which of the following statements is (are) true?
S → ( S )
S → x
I. The grammar is ambiguous.
II. The grammar is suitable for top-down parsing.
III. The grammar is suitable for bottom-up parsing.
(A) I only (B) II only (C) III only (D) II and III only (E) I, II, and III
1
Expert's answer
2013-01-30T08:11:05-0500
It's ambiguous, because for any word we have only one wayto create it. Example: ((((x)))){S->(S),S->(S),S->(S),S->(S),S->x} It isn't suitable for top-down parsing, because by termsto use we must have either grammar only as A->a or only as A->ab, but not A->aAb (a="(", b=")" ) So answer is (A), because II doesn't suit.
Comments
Leave a comment