0
P → PL | L
L → N; | M; | C
N → print E
M → print "W"
W → TW | ε
C → if E {P} | if E {P} else {P}
E → (EOE) | V (note: this has a variable O)
O → + | - | *
V → 0 | 1 | 2 | 3 (note: this has a terminal 0 (zero))
T → a | b | c | d

For the above grammar G, is it not LL(1) because it evokes FIRST/FIRST conflict when trying to predict the production of P? I am really struggling on how to prove that it is not LL(1)... Any help or advice would be very thankful!

유승기
  • 21
  • 1
  • 6

1 Answers1

0

A left-recursive grammar cannot be LL(k) for any k. P → P L is left-recursive.

In addition, L has two productions starting with the same terminal, so it is impossible to choose between them with only one symbol of lookahead.

rici
  • 234,347
  • 28
  • 237
  • 341