Some searches lead this example for non-LALR (1) grammar, which is LL (1):
S ::= '(' X | E ']' | F ')' X ::= E ')' | F ']' E ::= A F ::= A A ::= Ξ΅
The LALR (1) construct fails because there is a reduction reduction conflict between E and F. In the set of LR (0) states, there is a state consisting of
E ::= A . ; F ::= A . ;
which is necessary for both S and X contexts. LALR (1) lookahead sets for these elements, thus mixing tokens originating from S and X productions. This is different for LR (1), where different states exist for these cases.
With LL (1), decisions are made by looking for FIRST sets of alternatives, where ')' and ']' are always found in different alternatives.
Gunther
source share