From fabf5db2373d18a7c97016ea00acc0e05601960a Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 7 Apr 2005 10:09:07 -0300 Subject: C stack is the same for the parser and the interpreter, so depth control should be unified in both parts. --- lparser.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'lparser.c') diff --git a/lparser.c b/lparser.c index 4355f5fc..6db1bf1a 100644 --- a/lparser.c +++ b/lparser.c @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 2.18 2005/03/09 16:28:07 roberto Exp roberto $ +** $Id: lparser.c,v 2.19 2005/03/16 16:59:21 roberto Exp roberto $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -33,10 +33,6 @@ #define luaY_checklimit(fs,v,l,m) if ((v)>(l)) errorlimit(fs,l,m) -#define enterlevel(ls) if (++(ls)->nestlevel > LUAI_MAXPARSERLEVEL) \ - luaX_lexerror(ls, "chunk has too many syntax levels", 0) -#define leavelevel(ls) ((ls)->nestlevel--) - /* ** nodes for block list (list of active blocks) @@ -295,6 +291,15 @@ static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) { } +static void enterlevel (LexState *ls) { + if (++ls->L->nCcalls > LUAI_MAXCCALLS) + luaX_lexerror(ls, "chunk has too many syntax levels", 0); +} + + +#define leavelevel(ls) ((ls)->L->nCcalls--) + + static void enterblock (FuncState *fs, BlockCnt *bl, int isbreakable) { bl->breaklist = NO_JUMP; bl->isbreakable = isbreakable; @@ -395,7 +400,6 @@ Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) { struct LexState lexstate; struct FuncState funcstate; lexstate.buff = buff; - lexstate.nestlevel = 0; luaX_setinput(L, &lexstate, z, luaS_new(L, name)); open_func(&lexstate, &funcstate); funcstate.f->is_vararg = NEWSTYLEVARARG; @@ -405,7 +409,6 @@ Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) { close_func(&lexstate); lua_assert(funcstate.prev == NULL); lua_assert(funcstate.f->nups == 0); - lua_assert(lexstate.nestlevel == 0); lua_assert(lexstate.fs == NULL); return funcstate.f; } -- cgit v1.2.3-55-g6feb