lua-users home
lua-l archive

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


>I was wondering what the easiest way was to check the syntax of a block of
>code (from a buffer), without executing was?

In Lua 4.1 it's lua_loadbuffer.
In Lua 4.0, wrap the contents of the buffer as a function. In Lua, this would be
	dostring("return function () "..buffer.." end")
In C, it would be a little more complicated (but use the buffer functions
in lauxlib).
In any case, the result of dostring or lua_dobuffer will tell you whether there
was any syntax error. There can be no execution error.
	
>Also, what is the best way to extract the error messages when a compile
>error occurs? Should I create a C tag method for _ERRORMESSAGE?

No, just set _ERRORMESSAGE to a C function.

>And finally,
>one last question. Is there any way to get the line number that the
>compile/parse error occured on?

Yes, it's in the message string that _ERRORMESSAGE receives.
Look for " at line ".
--lhf