Search code examples
compiler-constructiongrammar

A grammar is not LL(1) even though it has no left recursion or common prefixes


Supposedly, following grammar is not LL(1). However I cannot find a reason for that. I think it is perfectly LL(1) because it has no left recursion and there is no common prefix issue. Can someone clarify?

http://awesomescreenshot.com/0ae48mn37b


Solution

  • LL(1) means that a parser can be constructed that uses a single token look-ahead, and in stmt, both assignment and subr_call start with ID so a parser cannot distinguish between the two cases just by looking at the first token (ID).