lua-users home
lua-l archive

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


> 	But this way you would still accept (weird) things like:
> 
> (function () _G.mynewfunction = function () ... end end)()

Right. You need to use sandbox techniques or simply disable the "function"
keyword with, say, a token filter as the one below:

/*
* proxy.c
* lexer proxy for Lua parser -- disables "function"
* This code is hereby placed in the public domain.
* Add <<#include "proxy.c">> just before the definition of luaX_next in llex.c
*/

static int nexttoken(LexState *ls, SemInfo *seminfo)
{
	int t=llex(ls,seminfo);
	if (t==TK_FUNCTION) t=TK_NIL;
	return t;
}

#define llex nexttoken