lua-users home
lua-l archive

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


> >      print((function(y) return y+10; end) (10));
> >
> > Is there a reason the () around the function object are
> required? To put it
> > another way -- what is the precedence of function() end in
> relation to the
> > call operator?
>
> LOL, you're finding some good ones today.
>
> I don't actually recall seeing a grammar diagram nor BNF for Lua anywhere.

There's a grammar for it in the reference manual:

http://www.lua.org/manual/5.0/manual.html#BNF

However, I've written a $-grammar for it that captures some of the more
subtle nuances of the language in practice.

> Btw, did my post about $-grammars make any sense at all?  I wasn't at the
> Grammar Forge site for long, just scanned some docs and diagrams briefly.

The grammar proper says that a function call requires a prefixexp, which
explains why the parentheses are required, at least syntactically, but I'm
wondering why the parentheses are strictly required, from a language
analysis POV.

As for the statement:

local t,f={},1

I'm still completely and utterly baffled as for where to find that in the
grammar specification. ;-)

--
Quinn Tyler Jackson
http://members.shaw.ca/qjackson/