Compiler construction 左递归删除,得到等价文法
我知道Y是左递归的,但是为什么Z不是左递归的呢 为了你,我得到了Compiler construction 左递归删除,得到等价文法,compiler-construction,context-free-grammar,left-recursion,pushdown-automaton,Compiler Construction,Context Free Grammar,Left Recursion,Pushdown Automaton,我知道Y是左递归的,但是为什么Z不是左递归的呢 为了你,我得到了 S → Y | 0Z Y → Y1 | 1Z | 1Z 00 Z → 1Z | 0 然后因子分解 Y -> 1ZF | 1Z00 F -> 1F | e 其中“e”为空Z不是左递归的,因为规则是Z->1Z,而不是Z->Z1。更准确地说,Y将变成Y->1ZF | 1Z00F,同时消除左递归。 Y -> 1ZX | 1ZX F -> 1F | e X -> F | 00F
S → Y | 0Z
Y → Y1 | 1Z | 1Z 00
Z → 1Z | 0
然后因子分解
Y -> 1ZF | 1Z00
F -> 1F | e
其中“e”为空
Z
不是左递归的,因为规则是Z->1Z
,而不是Z->Z1
。更准确地说,Y将变成Y->1ZF | 1Z00F,同时消除左递归。
Y -> 1ZX | 1ZX
F -> 1F | e
X -> F | 00F