编译器中的项集和 SLR(1) 问题
Item set and SLR(1) Questions in Compiler
我 运行 进入了一个由我们的助教解决的旧考试问题。谁能帮帮我?
当我们创建关于 S--> aSb | a
语法的 SLR(1)
时,项目集 LR(0)
之一如下:
{ S-->a.Sb, S-->a., S-->.aSb, S-->.a}
关于从上述集合中提取的规则,其中哪些是正确的:
a) one reduced and 2 shift and 1 goto is produced.
b) one reduced and 2 shift and2 goto is produced.
c) two reduced and 1 shift and 1 goto is produced.
d) when we input a, we have conflict.
谁能说出为什么 (3) 是正确的?关于这个问题的一些细节?
编辑:我认为 Goto 指的是 Action 和 goto 表。
存在三种可能的先行符号:a
、b
和 $
(输入结束标记)。过渡是:
lookahead action
--------- ------
a shift
b reduce S->a
$ reduce S->a
并且在非终端 S 上产生一个 goto 动作,目标是状态 {S -> aS.b}
我 运行 进入了一个由我们的助教解决的旧考试问题。谁能帮帮我?
当我们创建关于 S--> aSb | a
语法的 SLR(1)
时,项目集 LR(0)
之一如下:
{ S-->a.Sb, S-->a., S-->.aSb, S-->.a}
关于从上述集合中提取的规则,其中哪些是正确的:
a) one reduced and 2 shift and 1 goto is produced.
b) one reduced and 2 shift and2 goto is produced.
c) two reduced and 1 shift and 1 goto is produced.
d) when we input a, we have conflict.
谁能说出为什么 (3) 是正确的?关于这个问题的一些细节?
编辑:我认为 Goto 指的是 Action 和 goto 表。
存在三种可能的先行符号:a
、b
和 $
(输入结束标记)。过渡是:
lookahead action
--------- ------
a shift
b reduce S->a
$ reduce S->a
并且在非终端 S 上产生一个 goto 动作,目标是状态 {S -> aS.b}