I would like to write an LR(1) grammar in BNF form for the language described by these two rules from The Complete Syntax of Lua:
parlist ::= namelist [`,´ `...´] | `...´
namelist ::= Name {`,´ Name}
I have tried the following grammars, but according to the tool I am using, both are "not LR(1) due to shift-reduce conflict":
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>
Is there an LR(1) grammar, in BNF form, for this language?
namelist ::= Name
andnamelist ::= namelist , Name
rules? – Jonathan Leffler