Step 1: Analyze Statement S1.
SLR(1) grammars form a proper subclass of LR grammars.
Since LR parsers generate a unique rightmost derivation in reverse,
all LR (and hence SLR(1)) grammars are unambiguous.
However, the converse is not true. There exist grammars that are unambiguous but do not satisfy the stricter FOLLOW-set conditions required for SLR(1) parsing.
Therefore, there exist unambiguous grammars that are not SLR(1), making statement S1 true.
Step 2: Analyze Statement S2.
For arbitrary context-free grammars, general parsing algorithms are available.
Algorithms such as the CYK (Cocke–Younger–Kasami) algorithm and Earley’s parser can parse any context-free grammar in O(n³) time in the worst case, where n is the length of the input string.
Hence, S2 is also true.
Final Conclusion:
Since both statements S1 and S2 are true,
the correct option is:
Final Answer: (C)
Consider the augmented grammar with \(\{+,* , (, ), id\}\) as the set of terminals. \[ S' \rightarrow S \] \[ S \rightarrow S + R \mid R \] \[ R \rightarrow R^{\,*} P \mid P \] \[ P \rightarrow (S) \mid id \] If \(I_0\) is the set of two LR(0) items \(\{[S' \rightarrow S.], [S \rightarrow S. + R]\}\), then \(goto(\text{closure}(I_0), +)\) contains exactly \(\underline{\hspace{1cm}}\) items.
Consider the following ANSI C program:
int main() {
Integer x;
return 0;
}Which one of the following phases in a seven-phase C compiler will throw an error?
Consider the following augmented grammar with terminals {#, @, <, >, a, b, c}.
$S' → S$
$S → S\#cS$
$S → SS$
$S → S@$
$S → <S>$
$S → a$
$S → b$
$S → c$
Let I0 = CLOSURE({ S' → • S }). The number of items in the set GOTO(GOTO(I0, <), <) is .