[Luaeclipse-developers] Syntax Validation for Modules

Luís Eduardo Jason Santos jasonsantos at quantumsatis.net
Fri Sep 21 10:35:47 GMT+3 2007


Hello, people

I was working on syntax valitation when I found this tricky question.

We validate a script through execution in lua, via the loadstring function
in Lua API.

This works fine for standalone lua scripts. But when we are talking about
Lua 5.1 module system, we cannot use this same method to check for
compilation errors on declared modules without experimenting a compilation
error everytime find the varargs expression (...) - usually seen as a common
idiom on the module declaration.

The vararg expression, when used within a module receives the name by which
this module was called on the require() function.

We could add a 'function(...) '  enclosing all chunks to be checked for
errors (and therefore avoiding this tricky error) but that might lead to
undesirable side effects (such as, allowing the varargs expression to be
used on simple scripts even when it is *not* legal)

We could, of course, check to see if there's any module() call before we add
the function(...) to the syntax check, but that would not be actually
complete, for we might find uses of the vararg expression on modules called
by require() that do not contain a module() declaration.

On a perfect world, I would be willing to delegate to the developer the
indication - through Eclipse GUI -  of which files are modules and which
ones are executable scripts, but I am not so sure if that's so easy to
implement or comfortable to the end user...

But then again, if we try to guess which is which, we might very well find
we are unable to cover all cases even after parsing every require() on the
project.

I would like to hear some opinions on what solution would be the most
appropriate for the moment and what would be a more desirable final
solution.

Best regards,
-- 
Luís Eduardo Jason Santos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.luaforge.net/pipermail/luaeclipse-developers/attachments/20070921/f58bc6e6/attachment.htm


More information about the Luaeclipse-developers mailing list