[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Just checking a script syntax
- From: "Aaron Brown" <aaron-lua@...>
- Date: Tue, 25 Oct 2005 12:17:06 -0400
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.
--
Aaron