Consider the following grammar G S → F | H F → p | c H → d | c Where S, F, and H are non-terminal symbols, p, d, and c are terminal symbols. Which of the following statement(s) is/are correct? S1. LL(1) can parse all strings that are generated using grammar G S2. LR(1) can parse all string that are generated using grammar G

Consider the following grammar G S → F | H F → p | c H → d | c Where S, F, and H are non-terminal symbols, p, d, and c are terminal symbols. Which of the following statement(s) is/are correct? S1. LL(1) can parse all strings that are generated using grammar G S2. LR(1) can parse all string that are generated using grammar G Correct Answer Neither S1 nor S2

Concept:

First, check the grammar is ambiguous or not. If a grammar is ambiguous then it cannot be LL(1) and LR(1).

Explanation:

Given grammar is: S → F | H

F → p | c

H → d | c

First derivation for “c”:

S → F → c

Second derivation for “c”:

S → H → c

Two parse tree exists for single string and hence given grammar is ambiguous. It is neither LL(1) nor LR(1).

Related Questions