[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: lpeg and lua command line
- From: "Wesley Smith" <wesley.hoke@...>
- Date: Sun, 31 Aug 2008 00:35:42 -0700
I'm currently working on a build tool that is essentially a variation
of lua.c. One of its functions is to parse special tokens in source
files like C comments etc. and I wanted to try using LPEG for this
purpose. I naively added lpeg.c to my project and added
luaopen_lpeg(L); in the appropriate place in main() of lua.c but get
the following error:
PANIC: unprotected error in call to Lua API (no calling environment)
Here's my main:
int main (int argc, char **argv) {
int status;
struct Smain s;
lua_State *L = lua_open(); /* create state */
luaopen_lfs(L);
luaopen_lpeg(L);
if (L == NULL) {
l_message(argv[0], "cannot create state: not enough memory");
return EXIT_FAILURE;
}
s.argc = argc;
s.argv = argv;
status = lua_cpcall(L, &pmain, &s);
report(L, status);
lua_close(L);
return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS;
}
I looked at the luaopen_lpeg function and it apparently messes with
the environment. I'm wondering what exactly it's doing and is there a
way to not get a PANIC from including it like this? When I comment
lpeg out, scripts run fine.
thanks for any advice,
wes