mirror of https://github.com/rusefi/lua.git
C stack is the same for the parser and the interpreter, so depth
control should be unified in both parts.
This commit is contained in:
parent
de0bfe33b7
commit
fabf5db237
3
llex.h
3
llex.h
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: llex.h,v 1.51 2004/12/02 12:59:10 roberto Exp roberto $
|
** $Id: llex.h,v 1.52 2004/12/03 20:54:12 roberto Exp roberto $
|
||||||
** Lexical Analyzer
|
** Lexical Analyzer
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -63,7 +63,6 @@ typedef struct LexState {
|
||||||
ZIO *z; /* input stream */
|
ZIO *z; /* input stream */
|
||||||
Mbuffer *buff; /* buffer for tokens */
|
Mbuffer *buff; /* buffer for tokens */
|
||||||
TString *source; /* current source name */
|
TString *source; /* current source name */
|
||||||
int nestlevel; /* level of nested non-terminals */
|
|
||||||
} LexState;
|
} LexState;
|
||||||
|
|
||||||
|
|
||||||
|
|
17
lparser.c
17
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
|
** Lua Parser
|
||||||
** See Copyright Notice in lua.h
|
** 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 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)
|
** 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) {
|
static void enterblock (FuncState *fs, BlockCnt *bl, int isbreakable) {
|
||||||
bl->breaklist = NO_JUMP;
|
bl->breaklist = NO_JUMP;
|
||||||
bl->isbreakable = isbreakable;
|
bl->isbreakable = isbreakable;
|
||||||
|
@ -395,7 +400,6 @@ Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) {
|
||||||
struct LexState lexstate;
|
struct LexState lexstate;
|
||||||
struct FuncState funcstate;
|
struct FuncState funcstate;
|
||||||
lexstate.buff = buff;
|
lexstate.buff = buff;
|
||||||
lexstate.nestlevel = 0;
|
|
||||||
luaX_setinput(L, &lexstate, z, luaS_new(L, name));
|
luaX_setinput(L, &lexstate, z, luaS_new(L, name));
|
||||||
open_func(&lexstate, &funcstate);
|
open_func(&lexstate, &funcstate);
|
||||||
funcstate.f->is_vararg = NEWSTYLEVARARG;
|
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);
|
close_func(&lexstate);
|
||||||
lua_assert(funcstate.prev == NULL);
|
lua_assert(funcstate.prev == NULL);
|
||||||
lua_assert(funcstate.f->nups == 0);
|
lua_assert(funcstate.f->nups == 0);
|
||||||
lua_assert(lexstate.nestlevel == 0);
|
|
||||||
lua_assert(lexstate.fs == NULL);
|
lua_assert(lexstate.fs == NULL);
|
||||||
return funcstate.f;
|
return funcstate.f;
|
||||||
}
|
}
|
||||||
|
|
12
luaconf.h
12
luaconf.h
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: luaconf.h,v 1.40 2005/03/29 16:20:48 roberto Exp roberto $
|
** $Id: luaconf.h,v 1.41 2005/04/06 17:30:13 roberto Exp roberto $
|
||||||
** Configuration file for Lua
|
** Configuration file for Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -351,18 +351,12 @@
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short).
|
@@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and
|
||||||
|
@* syntactical nested non-terminals in a program.
|
||||||
*/
|
*/
|
||||||
#define LUAI_MAXCCALLS 200
|
#define LUAI_MAXCCALLS 200
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
@@ LUAI_MAXPARSERLEVEL is the maximum number of syntactical nested
|
|
||||||
@* non-terminals in a program.
|
|
||||||
*/
|
|
||||||
#define LUAI_MAXPARSERLEVEL 200
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ LUAI_MAXVARS is the maximum number of local variables per function
|
@@ LUAI_MAXVARS is the maximum number of local variables per function
|
||||||
@* (must be smaller than 250).
|
@* (must be smaller than 250).
|
||||||
|
|
Loading…
Reference in New Issue