Relationship between LR(0), LL(0), LALR(1), etc?

冷暖自知 提交于 2020-01-02 06:12:33

问题


I'm really struggling to unterstand the relationship between:

  • LR(0)
  • LL(0)
  • LALR(1)
  • SLR(1)
  • LR(1)
  • LL(1)

I'm pretty sure LALR(1) and SLR(1) are subsets of LR(1), but I'm lost about the others. Are they all exclusive? Is LL(0) a subset of LL(1)?

Thanks


回答1:


The containment rules are the following:

  • Every LR(0) grammar is also SLR(1), but not all SLR(1) grammars are LR(0).
  • Every SLR(1) grammar is also LALR(1), but not all LALR(1) grammars are SLR(1).
  • Every LALR(1) grammar is also LR(1), but not all LR(1) grammars are LALR(1).
  • Every LL(1) grammar is also LR(1), but not all LR(1) grammars are LL(1).
  • Every LL(0) grammar is also LR(0), SLR(1), LALR(1), LR(1), and LL(1). (LL(0) grammars are basically useless; see this question for details why).

It's also the case that every language that has an LR(1) grammar also has an LR(0) grammar provided that you endmark the grammar, though the grammar isn't guaranteed to be pretty.



来源:https://stackoverflow.com/questions/36652221/relationship-between-lr0-ll0-lalr1-etc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!