Let G be the LALR(1) gramar. Then which of the following is always correct when same G is used to construct LR(0) and SLR(1) parser?
A
LR(0) and SLR(1) table contain same number of shift entries
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
B
LR(0) table and LALR(1) table contain same number of reduced entries
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
None of these
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
SLR(1) table and LALR(1) table contain same number of reduced entries
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution
The correct option is A LR(0) and SLR(1) table contain same number of shift entries We know number of states in LR(0), SLR (1) and LALR(1) are always equal.
The following entries are always same in LR(0), SLR(1) and LALR(1):
Shift entries in action part of parsing tables
State entries in go to part of parsing tables
But reduced entries may differ in their parsing tables. So, LR(0) and SLR(1) table contain same number of shift entries for the given LALR(1) grammar.