[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: minor lua refman grammar points
- From: David Manura <dm.lua@...>
- Date: Wed, 19 Jan 2011 22:29:58 -0500
Two minor points about the grammar in the Lua Reference Manual:
(1) Wouldn't it be more consistent to write explist with right
recursion, like the other lists?
explist ::= {exp ‘,’} exp -- original
explist ::= exp {‘,’ exp} -- suggested
namelist ::= Name {‘,’ Name} -- in comparison
(2) According to 5.2-alpha grammar,
block ::= {stat} [laststat [‘;’]]
stat ::= ‘;’ | .....
laststat ::= return [explist] | break
This implies you can have any number of semicolons before or after
each statement in a block, except for any laststat (i.e. `return` or
`break`), which can be followed by at most one semicolon. Therefore,
";;print();;" is valid, but ";;return;;" is not. Is that intended?
Moreover, as ";" is now formally considered a statement (the "empty
statement") rather than just a statement separator, the comment "The
return and break statements can only be written as the last statement
of a block" is no longer entirely correct.