lua-users home
lua-l archive

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

Pierre-Yves Gérardy wrote:
If I understand it properly, according to the grammar at the end of
the reference manual,
the following statement should be legal (although it isn't in practice):

a = function() break end

Here are the relevant entries:

	function ::= `function´ funcbody
	funcbody ::= `(´ [parlist] `)´ block `end´
	block    ::= chunk
	chunk    ::= {stat [`;´]} [laststat [`;´]]
	laststat ::= `return´ [explist] | `break´

I'm a self thought programmer, so my grasp of theoretical CS is a bit
hazy. Does the bug lie in the spec or in my mind?

If you look at lparser.c, the parser is structured like the above, but with an additional check for a breakable enclosing block.

No idea how to put that in EBNF form, though...

Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia