Question

I am studying LL/LR parses and while reading the LL parser page on Wikipedia, I found this grammar:

S → F
S → ( S + F )
F → a

From the article it is LL (LL(0) I assume from the table); but I found a proof which states that an LL(0) parser has no Left-recursion (in this case with S). So, how comes that this is a proper LL(0) (or at least, this is what I understood from the article).

Is the 'no left-recursion' some sort of general rule or just a flag of a possible issue?

And can the parsing table tell me for sure whether the grammar I am working on is LL(0)?

Was it helpful?

Solution

Yes, you can identify a LL(0) grammar by looking at the parse table, as follows:

  1. Every non-terminal is associated with only one right-hand side.
  2. There is no use of the EBNF operators ?, *, or +.

Many would state an additional rule that recursion is not allowed. However, this is trivially implied by the previous rules due to the fact that any recursion would result in an infinite loop.

Your example grammar is not LL(0) because there are 2 productions defined for the non-terminal s.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top