Which of the following statements is/are true?
View worked solution
Answer: C
To determine the correct statement, let us analyze each option:
- Option A: parser uses backtracking
Incorrect. is a predictive, non-backtracking top-down parser. It uses a parsing table and a single lookahead token to make deterministic parsing decisions without backtracking. - Option B: For a grammar to be , it must be left-recursive
Incorrect. If a grammar is left-recursive (e.g., ), the parser will enter an infinite loop. Thus, an grammar must never be left-recursive. - Option C: For a grammar to be , it must be left-factored
Correct. Left-factoring is the process of removing common prefixes from the right-hand sides of productions for the same non-terminal (e.g., ). If a grammar is not left-factored, the parser cannot decide which production to choose with a single lookahead token. Hence, a grammar must be left-factored to be . - Option D: The parsers are more powerful than the SLR parsers
Incorrect. (and more generally, bottom-up shift-reduce parsers) are strictly more powerful than parsers. Every grammar is also an grammar, and the class of languages is a proper subset of languages.
Therefore, only statement C is true.
Free practice · Your answers on this page are not saved.
