Among simple LR (SLR), canonical LR, and look-ahead LR (LALR), which of the following pairs identify the method that is very easy to implement and the method that is the most powerful, in that order?
View worked solution
Answer: C
To identify the correct pair, let's compare the three bottom-up parsing methods: Simple LR (SLR), Canonical LR (CLR), and Look-Ahead LR (LALR).
-
Ease of Implementation (Easiest): SLR
- SLR parsers use the simple state machine.
- The parsing table is constructed by placing reduce actions in the row of a state for all terminals in the set of the non-terminal being reduced.
- This makes SLR the simplest and easiest to implement among the three.
-
Parsing Power (Most Powerful): Canonical LR (CLR)
- CLR (or ) uses explicit lookahead symbols within its states, preventing many shift-reduce and reduce-reduce conflicts that occur in SLR and LALR.
- It can parse the largest class of deterministic context-free grammars (all grammars).
- Therefore, CLR is the most powerful parser among the three.
Thus, the pair identifying the method that is very easy to implement and the method that is the most powerful, in that order, is SLR, canonical LR.
Free practice · Your answers on this page are not saved.
