UGC NET CS 2018Theory of Computation and Compilers › Syntax AnalysisVerified
UGC NET CS 2018 PYQ: Consider the following grammar $G$: $S \rightarrow A \mid B$ $A \rightarrow a \mid c$ $B \rightarrow b \mid…
Consider the following grammar $G$:
- $S \rightarrow A \mid B$
- $A \rightarrow a \mid c$
- $B \rightarrow b \mid c$
where $\{ S, A, B\}$ is the set of non-terminals, $\{ a, b, c, \}$ is the set of terminals.
Which of the following statement(s) is/are correct?
- $S_1$: $LR(1)$ can parse all strings that are generated using grammar $G$.
- $S_2$: $LL(1)$ can parse all strings that are generated using grammar $G$.
Choose the correct answer from the code given below:
- AOnly $S_1$
- BOnly $S_2$
- CBoth $S_1$ and $S_2$
- DNeither $S_1$ nor $S_2$Correct answer
Answer
(D) Neither $S_1$ nor $S_2$
Approach
Check FIRST-set overlap for LL(1) and the reduce-reduce conflict for LR(1) caused by ambiguity.
Reviewed by UGC IQ Editorial Team.