diff options
Diffstat (limited to 'llex.c')
-rw-r--r-- | llex.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -40,16 +40,11 @@ | |||
40 | 40 | ||
41 | #define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r') | 41 | #define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r') |
42 | 42 | ||
43 | #if defined(LUA_COMPAT_GLOBAL) | ||
44 | #define GLOBALLEX ".g" /* anything not recognizable as a name */ | ||
45 | #else | ||
46 | #define GLOBALLEX "global" | ||
47 | #endif | ||
48 | 43 | ||
49 | /* ORDER RESERVED */ | 44 | /* ORDER RESERVED */ |
50 | static const char *const luaX_tokens [] = { | 45 | static const char *const luaX_tokens [] = { |
51 | "and", "break", "do", "else", "elseif", | 46 | "and", "break", "do", "else", "elseif", |
52 | "end", "false", "for", "function", GLOBALLEX, "goto", "if", | 47 | "end", "false", "for", "function", "global", "goto", "if", |
53 | "in", "local", "nil", "not", "or", "repeat", | 48 | "in", "local", "nil", "not", "or", "repeat", |
54 | "return", "then", "true", "until", "while", | 49 | "return", "then", "true", "until", "while", |
55 | "//", "..", "...", "==", ">=", "<=", "~=", | 50 | "//", "..", "...", "==", ">=", "<=", "~=", |
@@ -189,10 +184,15 @@ void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source, | |||
189 | ls->linenumber = 1; | 184 | ls->linenumber = 1; |
190 | ls->lastline = 1; | 185 | ls->lastline = 1; |
191 | ls->source = source; | 186 | ls->source = source; |
192 | ls->envn = luaS_newliteral(L, LUA_ENV); /* get env name */ | 187 | /* all three strings here ("_ENV", "break", "global") were fixed, |
193 | ls->brkn = luaS_newliteral(L, "break"); /* get "break" name */ | 188 | so they cannot be collected */ |
194 | /* "break" cannot be collected, as it is a reserved word" */ | 189 | ls->envn = luaS_newliteral(L, LUA_ENV); /* get env string */ |
195 | lua_assert(isreserved(ls->brkn)); | 190 | ls->brkn = luaS_newliteral(L, "break"); /* get "break" string */ |
191 | #if defined(LUA_COMPAT_GLOBAL) | ||
192 | /* compatibility mode: "global" is not a reserved word */ | ||
193 | ls->glbn = luaS_newliteral(L, "global"); /* get "global" string */ | ||
194 | ls->glbn->extra = 0; /* mark it as not reserved */ | ||
195 | #endif | ||
196 | luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */ | 196 | luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */ |
197 | } | 197 | } |
198 | 198 | ||