lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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.