lua-users home
lua-l archive

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

Jose Marin wrote:

> It's possible to just check if a script contains syntax
> errors?

Here's how to do it Lua (rather than in C):

  local Func, ErrStr = loadstring(Str, "User-supplied code")

If Str contained a syntax error, Func will be nil and ErrStr
will be an error message.  Otherwise Func will be a function
that you can run (or not) at any time (possibly after using
setfenv to give it its own environment).

According to the Lua 5.0 manual, lua_load is the equivalent
function to do this from C.