Correct option is B
Statement I:
·
LL (1) parsers are examples of
top-down parsers, not bottom-up parsers. They parse the input from left-to-right and produce a leftmost derivation.
·
LR parsers (such as SLR, CLR, LALR) are
bottom-up parsers. They work by reducing the input string to the start symbol of the grammar.
Hence, Statement I is
false.
Statement II:
·
Recursive descent parsers are
top-down parsers, which build the parse tree starting from the root and work towards the leaves. This part of the statement is
true.
· However,
SLR parsers are
bottom-up parsers, not top-down parsers. They reduce substrings (right-hand sides of production rules) to non-terminals (left-hand sides).
Hence, Statement II is also
false.
Information Booster
1.
Top-Down Parsing:
· Starts from the root of the parse tree and tries to construct it down to the leaves.
· Examples: Recursive Descent Parsing, LL (1) Parsing.
· Predictive parsers belong to this category and require the grammar to be
LL(k).
2.
Bottom-Up Parsing:
· Starts from the leaves (input symbols) and attempts to construct the parse tree up to the root.
· Examples: LR (0), SLR (1), LALR (1), CLR (1).
3.
Key Differences Between LL and LR Parsers:
·
LL Parsers: Use left-to-right scanning and leftmost derivation.
·
LR Parsers: Use left-to-right scanning and rightmost derivation (in reverse).
4.
Recursive Descent Parsing:
· A manual implementation technique for top-down parsers.
· Can handle grammars that are not left-recursive or ambiguous.
Additional Knowledge
· Recursive descent parsing is simple but inefficient for handling complex grammars.
· Bottom-up parsers are more powerful and can handle a broader range of grammars compared to top-down parsers.
· SLR parsers are simpler but less powerful than CLR or LALR parsers.