lua-users home
lua-l archive

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

> (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?

Yes. (See below.)

> 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.

As you said, both "return" and "break" have their own optional
semicolons in the gramar. So, a semicolon in "return;" is not an empty
statement. (It cannot be an empty statement, so the gramar is not

-- Roberto