Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/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
Parsing 把语法弄糟_Parsing_Compiler Construction_Grammar_Ll - Fatal编程技术网

Parsing 把语法弄糟

Parsing 把语法弄糟,parsing,compiler-construction,grammar,ll,Parsing,Compiler Construction,Grammar,Ll,我已经在转换它上浪费了两个多时间,但我总是起床得到公共前缀ID 谁能给我解释一下吗?因为我试图做一个非常大的语法,需要我的基本知识清楚 A、 B、C、D是唯一的非端子 A : ‘(‘ B ‘)’ | ID ASSIGN C | C C : C '+' D | C '-' D | D D : ID | ID '(' actuals ')' | ID '(' ')' | INT_LIT | ‘(‘ C ‘)’ B : B ';' A | A 在LL中,

我已经在转换它上浪费了两个多时间,但我总是起床得到公共前缀ID

谁能给我解释一下吗?因为我试图做一个非常大的语法,需要我的基本知识清楚

A、 B、C、D是唯一的非端子

A : ‘(‘ B ‘)’ 
 | ID ASSIGN C 
 | C 

C : C '+' D 
 | C '-' D 
 | D 

D : ID 
 | ID '(' actuals ')' 
 | ID '(' ')' 
 | INT_LIT 
 | ‘(‘ C ‘)’ 


B : B ';' A | A

在LL中,一个产品不能有多个从同一个终端开始的选项,所以如果愿意的话,可以将这些公共部分拉到一个共享头中。所以

D : ID 
 | ID '(' actuals ')' 
 | ID '(' ')' 
 | INT_LIT 
 | ‘(‘ C ‘)’ 
变成了一种类似于

D : D_things_that_start_with_ID
 | D_things_that_do_not_start_with_ID
在哪里


其他常见的引线符号也是如此。

我已经试过了,但问题是一旦你从第一个非端子开始,它就会进入一个循环。请试着从第一个开始,你就会明白我的问题。谢谢,右-您必须消除左递归。如何做到这一点在这里已经讨论了很多次,当然在其他地方也是如此。
D_things_that_start_with_ID :
  ID D_things_that_follow_ID

D_things_that_follow_ID :
  epsilon
  | '(' actuals ')' 
  | '(' ')' 

D_things_that_do_not_start_with_ID :
 INT_LIT 
 | ‘(‘ C ‘)’