Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.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 it语句的LL(1)语法是什么?_Parsing - Fatal编程技术网

Parsing it语句的LL(1)语法是什么?

Parsing it语句的LL(1)语法是什么?,parsing,Parsing,我想把LALR(1)语法转换成LL(1)语法,特别是if语句 我对if语句使用了LALR(1)语法 IF_Stmt -> Matched|Unmatched. Matched -> if ( Expr_IF ) Matched else Matched | Other. Unmatched -> if ( Expr_IF ) Matched |if ( Expr_IF ) Matched else Unmatched. 在这里,我意识到我必须删除左因

我想把LALR(1)语法转换成LL(1)语法,特别是if语句

我对if语句使用了LALR(1)语法

IF_Stmt -> Matched|Unmatched.
Matched -> if ( Expr_IF ) Matched else Matched | Other.
Unmatched -> if ( Expr_IF ) Matched
             |if ( Expr_IF ) Matched else Unmatched.
在这里,我意识到我必须删除左因子分解

在那之后,我无法解决ε生产问题


if语句的LL(1)语法是什么?

您能否描述一下您与OP的不同之处以及解决方案的工作原理。这有助于将来有人来看这篇文章。非常感谢你的推荐。顺便说一句,如果我把你的语法添加到我的整个语法中,就会出现ε产生问题。。程序->Stmt专业版。专业->Stmt专业。Stmt->Declare | Assign | IF | Stmt | component | Stmt | Iter | FOR | Function | Call | Function | body | Comment |行。Other->Declare | Assign | component | Stmt | Iter | FOR | Function | Call | Function | body | Comment |行。上述语法不是LL(1)。符号“else”冲突,因为它同时位于第一个(可选)和第二个(可选)(假设\u Stmt是Stmt)。所以“else”将在可选的两个分支的预测集中。
IF_Stmt -> if ( Expr_IF ) Stmt Optional_Else_Stmt
Optional_Else_Stmt -> (empty-string)
                      |else Stmt.
Stmt -> if ( Expr ) Matched Optional_Else_Tail
      | Other

Matched -> if ( Expr ) Matched else Matched
         | Other

Optional_Else_Tail -> else Stmt
                    | ""