aboutsummaryrefslogtreecommitdiff
path: root/lparser.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-04-07 10:09:07 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-04-07 10:09:07 -0300
commitfabf5db2373d18a7c97016ea00acc0e05601960a (patch)
tree984c0e14d70e857e577a1be2d0e9d8815d92bdac /lparser.c
parentde0bfe33b7380fcf165b95dd36895865e1321226 (diff)
downloadlua-fabf5db2373d18a7c97016ea00acc0e05601960a.tar.gz
lua-fabf5db2373d18a7c97016ea00acc0e05601960a.tar.bz2
lua-fabf5db2373d18a7c97016ea00acc0e05601960a.zip
C stack is the same for the parser and the interpreter, so depth
control should be unified in both parts.
Diffstat (limited to 'lparser.c')
-rw-r--r--lparser.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/lparser.c b/lparser.c
index 4355f5fc..6db1bf1a 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 2.18 2005/03/09 16:28:07 roberto Exp roberto $ 2** $Id: lparser.c,v 2.19 2005/03/16 16:59:21 roberto Exp roberto $
3** Lua Parser 3** Lua Parser
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -33,10 +33,6 @@
33 33
34#define luaY_checklimit(fs,v,l,m) if ((v)>(l)) errorlimit(fs,l,m) 34#define luaY_checklimit(fs,v,l,m) if ((v)>(l)) errorlimit(fs,l,m)
35 35
36#define enterlevel(ls) if (++(ls)->nestlevel > LUAI_MAXPARSERLEVEL) \
37 luaX_lexerror(ls, "chunk has too many syntax levels", 0)
38#define leavelevel(ls) ((ls)->nestlevel--)
39
40 36
41/* 37/*
42** nodes for block list (list of active blocks) 38** nodes for block list (list of active blocks)
@@ -295,6 +291,15 @@ static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) {
295} 291}
296 292
297 293
294static void enterlevel (LexState *ls) {
295 if (++ls->L->nCcalls > LUAI_MAXCCALLS)
296 luaX_lexerror(ls, "chunk has too many syntax levels", 0);
297}
298
299
300#define leavelevel(ls) ((ls)->L->nCcalls--)
301
302
298static void enterblock (FuncState *fs, BlockCnt *bl, int isbreakable) { 303static void enterblock (FuncState *fs, BlockCnt *bl, int isbreakable) {
299 bl->breaklist = NO_JUMP; 304 bl->breaklist = NO_JUMP;
300 bl->isbreakable = isbreakable; 305 bl->isbreakable = isbreakable;
@@ -395,7 +400,6 @@ Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) {
395 struct LexState lexstate; 400 struct LexState lexstate;
396 struct FuncState funcstate; 401 struct FuncState funcstate;
397 lexstate.buff = buff; 402 lexstate.buff = buff;
398 lexstate.nestlevel = 0;
399 luaX_setinput(L, &lexstate, z, luaS_new(L, name)); 403 luaX_setinput(L, &lexstate, z, luaS_new(L, name));
400 open_func(&lexstate, &funcstate); 404 open_func(&lexstate, &funcstate);
401 funcstate.f->is_vararg = NEWSTYLEVARARG; 405 funcstate.f->is_vararg = NEWSTYLEVARARG;
@@ -405,7 +409,6 @@ Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) {
405 close_func(&lexstate); 409 close_func(&lexstate);
406 lua_assert(funcstate.prev == NULL); 410 lua_assert(funcstate.prev == NULL);
407 lua_assert(funcstate.f->nups == 0); 411 lua_assert(funcstate.f->nups == 0);
408 lua_assert(lexstate.nestlevel == 0);
409 lua_assert(lexstate.fs == NULL); 412 lua_assert(lexstate.fs == NULL);
410 return funcstate.f; 413 return funcstate.f;
411} 414}