diff options
| -rw-r--r-- | llex.h | 3 | ||||
| -rw-r--r-- | lparser.c | 17 | ||||
| -rw-r--r-- | luaconf.h | 12 |
3 files changed, 14 insertions, 18 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: llex.h,v 1.51 2004/12/02 12:59:10 roberto Exp roberto $ | 2 | ** $Id: llex.h,v 1.52 2004/12/03 20:54:12 roberto Exp roberto $ |
| 3 | ** Lexical Analyzer | 3 | ** Lexical Analyzer |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -63,7 +63,6 @@ typedef struct LexState { | |||
| 63 | ZIO *z; /* input stream */ | 63 | ZIO *z; /* input stream */ |
| 64 | Mbuffer *buff; /* buffer for tokens */ | 64 | Mbuffer *buff; /* buffer for tokens */ |
| 65 | TString *source; /* current source name */ | 65 | TString *source; /* current source name */ |
| 66 | int nestlevel; /* level of nested non-terminals */ | ||
| 67 | } LexState; | 66 | } LexState; |
| 68 | 67 | ||
| 69 | 68 | ||
| @@ -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 | ||
| 294 | static 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 | |||
| 298 | static void enterblock (FuncState *fs, BlockCnt *bl, int isbreakable) { | 303 | static 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 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: luaconf.h,v 1.40 2005/03/29 16:20:48 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.41 2005/04/06 17:30:13 roberto Exp roberto $ |
| 3 | ** Configuration file for Lua | 3 | ** Configuration file for Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -351,19 +351,13 @@ | |||
| 351 | 351 | ||
| 352 | 352 | ||
| 353 | /* | 353 | /* |
| 354 | @@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short). | 354 | @@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and |
| 355 | @* syntactical nested non-terminals in a program. | ||
| 355 | */ | 356 | */ |
| 356 | #define LUAI_MAXCCALLS 200 | 357 | #define LUAI_MAXCCALLS 200 |
| 357 | 358 | ||
| 358 | 359 | ||
| 359 | /* | 360 | /* |
| 360 | @@ LUAI_MAXPARSERLEVEL is the maximum number of syntactical nested | ||
| 361 | @* non-terminals in a program. | ||
| 362 | */ | ||
| 363 | #define LUAI_MAXPARSERLEVEL 200 | ||
| 364 | |||
| 365 | |||
| 366 | /* | ||
| 367 | @@ LUAI_MAXVARS is the maximum number of local variables per function | 361 | @@ LUAI_MAXVARS is the maximum number of local variables per function |
| 368 | @* (must be smaller than 250). | 362 | @* (must be smaller than 250). |
| 369 | */ | 363 | */ |
