Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Compiler construction 左递归删除,得到等价文法_Compiler Construction_Context Free Grammar_Left Recursion_Pushdown Automaton - Fatal编程技术网

Compiler construction 左递归删除,得到等价文法

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

我知道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