lua-users home
lua-l archive

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


Peter Hill:
> Regardless, one *should* be able to have:
>     function(a) return a end (123)

Luiz Henrique de Figueiredo:
> This does not work because it requires 2 lookaheads.

I've been looking through the syntax (I'm currently writing a Lua parser in
Visual Basic) and I can't seem to see why it requires two lookaheads.

- If "function" occurs in the position of an expression then it must be a
function literal.

- If "function" occurs where a statement may occur then, having absorbed the
'function' token, one merely needs to do a single lookahead to see if the
next token is "(" (meaing a function literal) or not (meaning a function
statement).

What am I missing?

*cheers*
Peter Hill.