【发布时间】:2018-01-05 04:37:51
【问题描述】:
我想为The Complete Syntax of Lua的这两条规则描述的语言写一个BNF形式的LR(1)语法:
parlist ::= namelist [`,´ `...´] | `...´
namelist ::= Name {`,´ Name}
我尝试了以下语法,但根据我使用的工具,两者都是“由于移位减少冲突而不是LR(1)”:
parlist ::= namelist
parlist ::= namelist , ...
parlist ::= ...
namelist ::= Name namelist1
namelist1 ::= , Name namelist1
namelist1 ::= <epsilon>
parlist ::= namelist
parlist ::= namelist , ...
parlist ::= ...
namelist ::= namelist1 Name
namelist1 ::= namelist1 Name ,
namelist1 ::= <epsilon>
此语言是否存在 BNF 形式的 LR(1) 语法?
【问题讨论】:
-
你为什么不使用
namelist ::= Name和namelist ::= namelist , Name规则?
标签: parsing grammar context-free-grammar bnf lr