LR(0),LL(0),LALR(1)等之间的关系? [英] Relationship between LR(0), LL(0), LALR(1), etc?

查看:247
本文介绍了LR(0),LL(0),LALR(1)等之间的关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的很难理解之间的关系:

I'm really struggling to unterstand the relationship between:

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

我很确定LALR(1)和SLR(1)是LR(1)的子集,但是我对其他的内容一无所知.他们都是独家的吗? LL(0)是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)?

谢谢

推荐答案

包含规则如下:

  • 每个LR(0)语法也都是SLR(1),但并非所有SLR(1)语法都是LR(0).
  • 每个SLR(1)语法也是LALR(1),但并非所有LALR(1)语法都是SLR(1).
  • 每个LALR(1)语法也都是LR(1),但并非所有LR(1)语法都是LALR(1).
  • 每个LL(1)语法也是LR(1),但并非所有LR(1)语法都是LL(1).
  • 每个LL(0)语法也是LR(0),SLR(1),LALR(1),LR(1)和LL(1). (LL(0)语法基本上是无用的; 请参阅此问题以了解详细说明原因).
  • 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).

在同样情况下,每种语言都有LR(1)语法也有LR(0)语法,但前提是您要标记该语法,尽管不能保证该语法很漂亮.

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.

这篇关于LR(0),LL(0),LALR(1)等之间的关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆