diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-01-19 11:20:30 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-01-19 11:20:30 -0200 |
commit | 4ac58853dc820127a11a14ed8bde1fae9458369e (patch) | |
tree | e8179692c97e935ba921c8ebd17abf9c8510d89e /llex.c | |
parent | f2c451d7455aad3496f32dfa2bfca7f7e8b5376d (diff) | |
download | lua-4ac58853dc820127a11a14ed8bde1fae9458369e.tar.gz lua-4ac58853dc820127a11a14ed8bde1fae9458369e.tar.bz2 lua-4ac58853dc820127a11a14ed8bde1fae9458369e.zip |
thead-specific state separated from "global" state
Diffstat (limited to 'llex.c')
-rw-r--r-- | llex.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llex.c,v 1.74 2001/01/10 17:41:50 roberto Exp roberto $ | 2 | ** $Id: llex.c,v 1.75 2001/01/15 18:07:56 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 | */ |
@@ -35,7 +35,7 @@ void luaX_init (lua_State *L) { | |||
35 | int i; | 35 | int i; |
36 | for (i=0; i<NUM_RESERVED; i++) { | 36 | for (i=0; i<NUM_RESERVED; i++) { |
37 | TString *ts = luaS_new(L, token2string[i]); | 37 | TString *ts = luaS_new(L, token2string[i]); |
38 | LUA_ASSERT(strlen(token2string[i])+1 <= TOKEN_LEN, "incorrect token_len"); | 38 | lua_assert(strlen(token2string[i])+1 <= TOKEN_LEN); |
39 | ts->marked = (unsigned char)(RESERVEDMARK+i); /* reserved word */ | 39 | ts->marked = (unsigned char)(RESERVEDMARK+i); /* reserved word */ |
40 | } | 40 | } |
41 | } | 41 | } |
@@ -65,7 +65,7 @@ void luaX_error (LexState *ls, const char *s, int token) { | |||
65 | char buff[TOKEN_LEN]; | 65 | char buff[TOKEN_LEN]; |
66 | luaX_token2str(token, buff); | 66 | luaX_token2str(token, buff); |
67 | if (buff[0] == '\0') | 67 | if (buff[0] == '\0') |
68 | luaX_syntaxerror(ls, s, ls->L->Mbuffer); | 68 | luaX_syntaxerror(ls, s, G(ls->L)->Mbuffer); |
69 | else | 69 | else |
70 | luaX_syntaxerror(ls, s, buff); | 70 | luaX_syntaxerror(ls, s, buff); |
71 | } | 71 | } |
@@ -123,10 +123,10 @@ void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source) { | |||
123 | /* use Mbuffer to store names, literal strings and numbers */ | 123 | /* use Mbuffer to store names, literal strings and numbers */ |
124 | 124 | ||
125 | #define EXTRABUFF 128 | 125 | #define EXTRABUFF 128 |
126 | #define checkbuffer(L, n, len) if ((len)+(n) > L->Mbuffsize) \ | 126 | #define checkbuffer(L, n, len) if ((len)+(n) > G(L)->Mbuffsize) \ |
127 | luaO_openspace(L, (len)+(n)+EXTRABUFF) | 127 | luaO_openspace(L, (len)+(n)+EXTRABUFF) |
128 | 128 | ||
129 | #define save(L, c, l) (L->Mbuffer[l++] = (char)c) | 129 | #define save(L, c, l) (G(L)->Mbuffer[l++] = (char)c) |
130 | #define save_and_next(L, LS, l) (save(L, LS->current, l), next(LS)) | 130 | #define save_and_next(L, LS, l) (save(L, LS->current, l), next(LS)) |
131 | 131 | ||
132 | 132 | ||
@@ -176,7 +176,7 @@ static void read_number (LexState *LS, int comma, SemInfo *seminfo) { | |||
176 | } | 176 | } |
177 | } | 177 | } |
178 | save(L, '\0', l); | 178 | save(L, '\0', l); |
179 | if (!luaO_str2d(L->Mbuffer, &seminfo->r)) | 179 | if (!luaO_str2d(G(L)->Mbuffer, &seminfo->r)) |
180 | luaX_error(LS, "malformed number", TK_NUMBER); | 180 | luaX_error(LS, "malformed number", TK_NUMBER); |
181 | } | 181 | } |
182 | 182 | ||
@@ -220,7 +220,7 @@ static void read_long_string (LexState *LS, SemInfo *seminfo) { | |||
220 | } endloop: | 220 | } endloop: |
221 | save_and_next(L, LS, l); /* skip the second ']' */ | 221 | save_and_next(L, LS, l); /* skip the second ']' */ |
222 | save(L, '\0', l); | 222 | save(L, '\0', l); |
223 | seminfo->ts = luaS_newlstr(L, L->Mbuffer+2, l-5); | 223 | seminfo->ts = luaS_newlstr(L, G(L)->Mbuffer+2, l-5); |
224 | } | 224 | } |
225 | 225 | ||
226 | 226 | ||
@@ -272,7 +272,7 @@ static void read_string (LexState *LS, int del, SemInfo *seminfo) { | |||
272 | } | 272 | } |
273 | save_and_next(L, LS, l); /* skip delimiter */ | 273 | save_and_next(L, LS, l); /* skip delimiter */ |
274 | save(L, '\0', l); | 274 | save(L, '\0', l); |
275 | seminfo->ts = luaS_newlstr(L, L->Mbuffer+1, l-3); | 275 | seminfo->ts = luaS_newlstr(L, G(L)->Mbuffer+1, l-3); |
276 | } | 276 | } |
277 | 277 | ||
278 | 278 | ||
@@ -367,7 +367,7 @@ int luaX_lex (LexState *LS, SemInfo *seminfo) { | |||
367 | } | 367 | } |
368 | tname: { /* identifier or reserved word */ | 368 | tname: { /* identifier or reserved word */ |
369 | size_t l = readname(LS); | 369 | size_t l = readname(LS); |
370 | TString *ts = luaS_newlstr(LS->L, LS->L->Mbuffer, l); | 370 | TString *ts = luaS_newlstr(LS->L, G(LS->L)->Mbuffer, l); |
371 | if (ts->marked >= RESERVEDMARK) /* reserved word? */ | 371 | if (ts->marked >= RESERVEDMARK) /* reserved word? */ |
372 | return ts->marked-RESERVEDMARK+FIRST_RESERVED; | 372 | return ts->marked-RESERVEDMARK+FIRST_RESERVED; |
373 | seminfo->ts = ts; | 373 | seminfo->ts = ts; |