[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Checking Syntax....
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Fri, 28 Jul 2000 19:58:14 -0300 (EST)
>Is there a way to check the syntax of or validate a
>lua script programmatically, without actually running it?
Not directly, but if you don't use "function x() .. end " constructions,
only "x=function() ... end", then you can put the whole chunk inside a fake
function and return it:
return function ()
--- code for the chunk here
end
If this new chunk loads without errors, then there were not syntax errors
in the original chunk.
If you then want to run it, then save the results of dofile and then
call the first result as a function (which it is).
Perhaps we could remove the restriction that "function x() .. end" cannot
occur inside other functions, as has already been discussed here.
This would make the solution above completely general.
--lhf