186 views
Give a grammar which is LL(1) but not LALR(1) .
| 186 views

+1 vote

After some googling, I found this grammar to be LL(1) but not LALR

S -> (X | E] | F)
X -> E) | F]
E -> A
F -> A
A -> ε

LALR fails because there is reduce reduce conflicts in E and F productions.

With LL(1), decision is made based on the FIRST set of alternatives where ')' and ']' falls in different set of alternatives.

Credits: stackoverflow

by Active (1.1k points)

+1 vote