我想寫入BNF形式的LR(1)的語法用於通過這兩個規則從The Complete Syntax of Lua描述的語言:LR(1)BNF語法功能參數與後省略號
parlist ::= namelist [`,´ `...´] | `...´
namelist ::= Name {`,´ Name}
我試圖下面的語法,但根據我使用的工具,兩者都是 「不LR(1)由於SHIFT-減少衝突」:
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>
對於這種語言,是否有BN(BNF)形式的LR(1)語法?
爲什麼不使用'namelist :: = Name'和'namelist :: = namelist,Name'規則? –