diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-01-26 16:51:49 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-01-26 16:51:49 -0200 |
| commit | d6b9f49aaf735f7b17bd0dcafde65ba0f8c57bc7 (patch) | |
| tree | e832ab8740707bc2c979e39d29cddb2355737e8f | |
| parent | d83c2a84550221c30a48647fde9c433c65af1802 (diff) | |
| download | lua-d6b9f49aaf735f7b17bd0dcafde65ba0f8c57bc7.tar.gz lua-d6b9f49aaf735f7b17bd0dcafde65ba0f8c57bc7.tar.bz2 lua-d6b9f49aaf735f7b17bd0dcafde65ba0f8c57bc7.zip | |
only need to reset buffer for strings, numbers, and names.
| -rw-r--r-- | llex.c | 10 |
1 files changed, 7 insertions, 3 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: llex.c,v 1.48 1999/12/30 12:40:29 roberto Exp roberto $ | 2 | ** $Id: llex.c,v 1.49 2000/01/25 18:44:21 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 | */ |
| @@ -321,7 +321,6 @@ static void read_string (lua_State *L, LexState *LS, int del) { | |||
| 321 | 321 | ||
| 322 | int luaX_lex (LexState *LS) { | 322 | int luaX_lex (LexState *LS) { |
| 323 | lua_State *L = LS->L; | 323 | lua_State *L = LS->L; |
| 324 | luaL_resetbuffer(L); | ||
| 325 | for (;;) { | 324 | for (;;) { |
| 326 | switch (LS->current) { | 325 | switch (LS->current) { |
| 327 | 326 | ||
| @@ -340,6 +339,7 @@ int luaX_lex (LexState *LS) { | |||
| 340 | continue; | 339 | continue; |
| 341 | 340 | ||
| 342 | case '[': | 341 | case '[': |
| 342 | luaL_resetbuffer(L); | ||
| 343 | save_and_next(L, LS); | 343 | save_and_next(L, LS); |
| 344 | if (LS->current != '[') return '['; | 344 | if (LS->current != '[') return '['; |
| 345 | else { | 345 | else { |
| @@ -370,10 +370,12 @@ int luaX_lex (LexState *LS) { | |||
| 370 | 370 | ||
| 371 | case '"': | 371 | case '"': |
| 372 | case '\'': | 372 | case '\'': |
| 373 | luaL_resetbuffer(L); | ||
| 373 | read_string(L, LS, LS->current); | 374 | read_string(L, LS, LS->current); |
| 374 | return STRING; | 375 | return STRING; |
| 375 | 376 | ||
| 376 | case '.': | 377 | case '.': |
| 378 | luaL_resetbuffer(L); | ||
| 377 | save_and_next(L, LS); | 379 | save_and_next(L, LS); |
| 378 | if (LS->current == '.') { | 380 | if (LS->current == '.') { |
| 379 | next(LS); | 381 | next(LS); |
| @@ -384,10 +386,11 @@ int luaX_lex (LexState *LS) { | |||
| 384 | else return CONC; /* .. */ | 386 | else return CONC; /* .. */ |
| 385 | } | 387 | } |
| 386 | else if (!isdigit(LS->current)) return '.'; | 388 | else if (!isdigit(LS->current)) return '.'; |
| 387 | goto fraction; /* LS->current is a digit: goes through to number */ | 389 | else goto fraction; /* LS->current is a digit */ |
| 388 | 390 | ||
| 389 | case '0': case '1': case '2': case '3': case '4': | 391 | case '0': case '1': case '2': case '3': case '4': |
| 390 | case '5': case '6': case '7': case '8': case '9': | 392 | case '5': case '6': case '7': case '8': case '9': |
| 393 | luaL_resetbuffer(L); | ||
| 391 | do { | 394 | do { |
| 392 | save_and_next(L, LS); | 395 | save_and_next(L, LS); |
| 393 | } while (isdigit(LS->current)); | 396 | } while (isdigit(LS->current)); |
| @@ -431,6 +434,7 @@ int luaX_lex (LexState *LS) { | |||
| 431 | } | 434 | } |
| 432 | tname: { /* identifier or reserved word */ | 435 | tname: { /* identifier or reserved word */ |
| 433 | TaggedString *ts; | 436 | TaggedString *ts; |
| 437 | luaL_resetbuffer(L); | ||
| 434 | do { | 438 | do { |
| 435 | save_and_next(L, LS); | 439 | save_and_next(L, LS); |
| 436 | } while (isalnum(LS->current) || LS->current == '_'); | 440 | } while (isalnum(LS->current) || LS->current == '_'); |
