Question Details

Which of the following is always true for LL(1) parser?

Options

A

Grammar must be left factored

B

LL(1) parser is more powerful than SLR(1).

C

LL(1) is non back tracking.

D

Grammar must be left recursive.

Show Answer

Correct Answer :

Option C

LL(1) is non back tracking.

Solution :

The correct option is LL(1) is non back tracking.

Detailed Explanation:
An LL(1) parser is a deterministic, top-down parser. The name "LL(1)" describes its configuration and behavior:
• The first L stands for scanning the input from Left to right.
• The second L stands for producing a Leftmost derivation.
• The number 1 indicates that the parser uses exactly 1 lookahead symbol at each step to make its parsing decisions.

For any valid LL(1) grammar, the parser's transition table (or parsing table) has at most one production rule for any given combination of a non-terminal and a lookahead terminal. This means that at any point during parsing, the parser knows exactly which rule to apply without any ambiguity. Because there is never a choice between multiple rules for a single lookahead symbol, the parser never needs to make a guess, encounter a failure, and roll back to try another alternative. Therefore, LL(1) parsing is strictly non-backtracking.

Analysis of the other options:
Grammar must be left factored: If a grammar is already LL(1), it does not need to be left factored. Left factoring is a technique applied to non-LL(1) grammars (specifically those with common prefixes) to try to convert them into an LL(1) structure. Therefore, the grammar itself does not "must" be left factored if it is already compliant.
LL(1) parser is more powerful than SLR(1): This is incorrect. SLR(1) is a bottom-up parser, and bottom-up parsers are generally more powerful than top-down parsers. The class of grammars parsed by SLR(1) strictly subsumes the class of grammars parsed by LL(1).
Grammar must be left recursive: This is incorrect. Left recursion is a major conflict in top-down parsing. If a grammar has left recursion, the LL(1) parser will enter an infinite loop. Therefore, an LL(1) grammar must never be left recursive.

Unlock Our Free Library

Access expert-curated educational resources and study materials—completely free.

Ask AI Tutor
5 left
Q1 View Question & Options
AI Tutor is solving this question...
Reading question context & options...