[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Parse/Compile time checking and information
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Thu, 23 Aug 2001 17:22:47 -0300
>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