我想将LALR(1)语法转换为LL(1)语法,特别是如果声明。
我在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.
在这里,我意识到我必须删除左分解。
之后我无法解决epsilon生产问题......
if语句的LL(1)语法是什么?
答案 0 :(得分:1)
IF_Stmt -> if ( Expr_IF ) Stmt Optional_Else_Stmt
Optional_Else_Stmt -> (empty-string)
|else Stmt.
答案 1 :(得分:0)
Stmt -> if ( Expr ) Matched Optional_Else_Tail
| Other
Matched -> if ( Expr ) Matched else Matched
| Other
Optional_Else_Tail -> else Stmt
| ""