diff options
Diffstat (limited to 'llex.c')
-rw-r--r-- | llex.c | 28 |
1 files changed, 14 insertions, 14 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llex.c,v 1.69 2000/09/11 17:38:42 roberto Exp roberto $ | 2 | ** $Id: llex.c,v 1.70 2000/09/11 20:29:27 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 | */ |
@@ -58,7 +58,7 @@ void luaX_checklimit (LexState *ls, int val, int limit, const char *msg) { | |||
58 | void luaX_syntaxerror (LexState *ls, const char *s, const char *token) { | 58 | void luaX_syntaxerror (LexState *ls, const char *s, const char *token) { |
59 | char buff[MAXSRC]; | 59 | char buff[MAXSRC]; |
60 | luaO_chunkid(buff, ls->source->str, sizeof(buff)); | 60 | luaO_chunkid(buff, ls->source->str, sizeof(buff)); |
61 | luaO_verror(ls->L, "%.100s;\n last token read: `%.50s' at line %d in %.80s", | 61 | luaO_verror(ls->L, "%.99s;\n last token read: `%.50s' at line %d in %.80s", |
62 | s, token, ls->linenumber, buff); | 62 | s, token, ls->linenumber, buff); |
63 | } | 63 | } |
64 | 64 | ||
@@ -146,7 +146,7 @@ static const char *readname (LexState *LS) { | |||
146 | 146 | ||
147 | 147 | ||
148 | /* LUA_NUMBER */ | 148 | /* LUA_NUMBER */ |
149 | static void read_number (LexState *LS, int comma) { | 149 | static void read_number (LexState *LS, int comma, SemInfo *seminfo) { |
150 | lua_State *L = LS->L; | 150 | lua_State *L = LS->L; |
151 | size_t l = 0; | 151 | size_t l = 0; |
152 | checkbuffer(L, 10, l); | 152 | checkbuffer(L, 10, l); |
@@ -178,12 +178,12 @@ static void read_number (LexState *LS, int comma) { | |||
178 | } | 178 | } |
179 | } | 179 | } |
180 | save(L, '\0', l); | 180 | save(L, '\0', l); |
181 | if (!luaO_str2d(L->Mbuffer, &LS->t.seminfo.r)) | 181 | if (!luaO_str2d(L->Mbuffer, &seminfo->r)) |
182 | luaX_error(LS, "malformed number", TK_NUMBER); | 182 | luaX_error(LS, "malformed number", TK_NUMBER); |
183 | } | 183 | } |
184 | 184 | ||
185 | 185 | ||
186 | static void read_long_string (LexState *LS) { | 186 | static void read_long_string (LexState *LS, SemInfo *seminfo) { |
187 | lua_State *L = LS->L; | 187 | lua_State *L = LS->L; |
188 | int cont = 0; | 188 | int cont = 0; |
189 | size_t l = 0; | 189 | size_t l = 0; |
@@ -222,11 +222,11 @@ static void read_long_string (LexState *LS) { | |||
222 | } endloop: | 222 | } endloop: |
223 | save_and_next(L, LS, l); /* skip the second ']' */ | 223 | save_and_next(L, LS, l); /* skip the second ']' */ |
224 | save(L, '\0', l); | 224 | save(L, '\0', l); |
225 | LS->t.seminfo.ts = luaS_newlstr(L, L->Mbuffer+2, l-5); | 225 | seminfo->ts = luaS_newlstr(L, L->Mbuffer+2, l-5); |
226 | } | 226 | } |
227 | 227 | ||
228 | 228 | ||
229 | static void read_string (LexState *LS, int del) { | 229 | static void read_string (LexState *LS, int del, SemInfo *seminfo) { |
230 | lua_State *L = LS->L; | 230 | lua_State *L = LS->L; |
231 | size_t l = 0; | 231 | size_t l = 0; |
232 | checkbuffer(L, 10, l); | 232 | checkbuffer(L, 10, l); |
@@ -274,11 +274,11 @@ static void read_string (LexState *LS, int del) { | |||
274 | } | 274 | } |
275 | save_and_next(L, LS, l); /* skip delimiter */ | 275 | save_and_next(L, LS, l); /* skip delimiter */ |
276 | save(L, '\0', l); | 276 | save(L, '\0', l); |
277 | LS->t.seminfo.ts = luaS_newlstr(L, L->Mbuffer+1, l-3); | 277 | seminfo->ts = luaS_newlstr(L, L->Mbuffer+1, l-3); |
278 | } | 278 | } |
279 | 279 | ||
280 | 280 | ||
281 | int luaX_lex (LexState *LS) { | 281 | int luaX_lex (LexState *LS, SemInfo *seminfo) { |
282 | for (;;) { | 282 | for (;;) { |
283 | switch (LS->current) { | 283 | switch (LS->current) { |
284 | 284 | ||
@@ -304,7 +304,7 @@ int luaX_lex (LexState *LS) { | |||
304 | next(LS); | 304 | next(LS); |
305 | if (LS->current != '[') return '['; | 305 | if (LS->current != '[') return '['; |
306 | else { | 306 | else { |
307 | read_long_string(LS); | 307 | read_long_string(LS, seminfo); |
308 | return TK_STRING; | 308 | return TK_STRING; |
309 | } | 309 | } |
310 | 310 | ||
@@ -330,7 +330,7 @@ int luaX_lex (LexState *LS) { | |||
330 | 330 | ||
331 | case '"': | 331 | case '"': |
332 | case '\'': | 332 | case '\'': |
333 | read_string(LS, LS->current); | 333 | read_string(LS, LS->current, seminfo); |
334 | return TK_STRING; | 334 | return TK_STRING; |
335 | 335 | ||
336 | case '.': | 336 | case '.': |
@@ -345,13 +345,13 @@ int luaX_lex (LexState *LS) { | |||
345 | } | 345 | } |
346 | else if (!isdigit(LS->current)) return '.'; | 346 | else if (!isdigit(LS->current)) return '.'; |
347 | else { | 347 | else { |
348 | read_number(LS, 1); | 348 | read_number(LS, 1, seminfo); |
349 | return TK_NUMBER; | 349 | return TK_NUMBER; |
350 | } | 350 | } |
351 | 351 | ||
352 | case '0': case '1': case '2': case '3': case '4': | 352 | case '0': case '1': case '2': case '3': case '4': |
353 | case '5': case '6': case '7': case '8': case '9': | 353 | case '5': case '6': case '7': case '8': case '9': |
354 | read_number(LS, 0); | 354 | read_number(LS, 0, seminfo); |
355 | return TK_NUMBER; | 355 | return TK_NUMBER; |
356 | 356 | ||
357 | case EOZ: | 357 | case EOZ: |
@@ -371,7 +371,7 @@ int luaX_lex (LexState *LS) { | |||
371 | TString *ts = luaS_new(LS->L, readname(LS)); | 371 | TString *ts = luaS_new(LS->L, readname(LS)); |
372 | if (ts->marked >= RESERVEDMARK) /* reserved word? */ | 372 | if (ts->marked >= RESERVEDMARK) /* reserved word? */ |
373 | return ts->marked-RESERVEDMARK+FIRST_RESERVED; | 373 | return ts->marked-RESERVEDMARK+FIRST_RESERVED; |
374 | LS->t.seminfo.ts = ts; | 374 | seminfo->ts = ts; |
375 | return TK_NAME; | 375 | return TK_NAME; |
376 | } | 376 | } |
377 | } | 377 | } |