[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Detecting expressions
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Sat, 10 May 2003 10:19:21 -0300
>Is there an easy way to tell whether a string is an expression?
Try wraping the string XXX as "return (XXX)" and using luaL_loadbuffer.
If it returns 0, then XXX is ok and you can execute it simply by doing
lua_pcall. The result of XXX will be left on he stack.
The parentheses try to limit XXX to a single expression. If you want to print
multiple expressions, sijply remove them. luac.c does this for lines starting
with "=".
--lhf