diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-07-30 19:00:50 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-07-30 19:00:50 -0300 |
| commit | 0892f0e5b75c51f1fee07276a3ba13301b83409e (patch) | |
| tree | 9f3b9ec92f26c05a85c826ffc5f803fda2f48867 /lex.c | |
| parent | 1d7857bc635c0bfe7c5b1f325d31feb7660e9a5a (diff) | |
| download | lua-0892f0e5b75c51f1fee07276a3ba13301b83409e.tar.gz lua-0892f0e5b75c51f1fee07276a3ba13301b83409e.tar.bz2 lua-0892f0e5b75c51f1fee07276a3ba13301b83409e.zip | |
BIG CHANGE: functions have their own "constant table".
Diffstat (limited to 'lex.c')
| -rw-r--r-- | lex.c | 17 |
1 files changed, 8 insertions, 9 deletions
| @@ -1,4 +1,4 @@ | |||
| 1 | char *rcs_lex = "$Id: lex.c,v 3.6 1997/07/01 19:32:41 roberto Exp roberto $"; | 1 | char *rcs_lex = "$Id: lex.c,v 3.7 1997/07/29 13:33:15 roberto Exp roberto $"; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | #include <ctype.h> | 4 | #include <ctype.h> |
| @@ -62,7 +62,7 @@ void lua_setinput (ZIO *z) | |||
| 62 | static void luaI_auxsyntaxerror (char *s) | 62 | static void luaI_auxsyntaxerror (char *s) |
| 63 | { | 63 | { |
| 64 | luaL_verror("%s;\n> at line %d in file %s", | 64 | luaL_verror("%s;\n> at line %d in file %s", |
| 65 | s, lua_linenumber, lua_parsedfile); | 65 | s, lua_linenumber, lua_parsedfile->str); |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | static void luaI_auxsynterrbf (char *s, char *token) | 68 | static void luaI_auxsynterrbf (char *s, char *token) |
| @@ -70,7 +70,7 @@ static void luaI_auxsynterrbf (char *s, char *token) | |||
| 70 | if (token[0] == 0) | 70 | if (token[0] == 0) |
| 71 | token = "<eof>"; | 71 | token = "<eof>"; |
| 72 | luaL_verror("%s;\n> last token read: \"%s\" at line %d in file %s", | 72 | luaL_verror("%s;\n> last token read: \"%s\" at line %d in file %s", |
| 73 | s, token, lua_linenumber, lua_parsedfile); | 73 | s, token, lua_linenumber, lua_parsedfile->str); |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | void luaI_syntaxerror (char *s) | 76 | void luaI_syntaxerror (char *s) |
| @@ -110,7 +110,7 @@ void luaI_addReserved (void) | |||
| 110 | int i; | 110 | int i; |
| 111 | for (i=0; i<RESERVEDSIZE; i++) | 111 | for (i=0; i<RESERVEDSIZE; i++) |
| 112 | { | 112 | { |
| 113 | TaggedString *ts = lua_createstring(reserved[i].name); | 113 | TaggedString *ts = luaI_createstring(reserved[i].name); |
| 114 | ts->marked = reserved[i].token; /* reserved word (always > 255) */ | 114 | ts->marked = reserved[i].token; /* reserved word (always > 255) */ |
| 115 | } | 115 | } |
| 116 | } | 116 | } |
| @@ -273,7 +273,7 @@ static int read_long_string (char *yytext, int buffsize) | |||
| 273 | } endloop: | 273 | } endloop: |
| 274 | save_and_next(); /* pass the second ']' */ | 274 | save_and_next(); /* pass the second ']' */ |
| 275 | yytext[tokensize-2] = 0; /* erases ']]' */ | 275 | yytext[tokensize-2] = 0; /* erases ']]' */ |
| 276 | luaY_lval.vWord = luaI_findconstantbyname(yytext+2); | 276 | luaY_lval.pTStr = luaI_createtempstring(yytext+2); |
| 277 | yytext[tokensize-2] = ']'; /* restores ']]' */ | 277 | yytext[tokensize-2] = ']'; /* restores ']]' */ |
| 278 | save(0); | 278 | save(0); |
| 279 | return STRING; | 279 | return STRING; |
| @@ -368,7 +368,7 @@ int luaY_lex (void) | |||
| 368 | } | 368 | } |
| 369 | next(); /* skip delimiter */ | 369 | next(); /* skip delimiter */ |
| 370 | save(0); | 370 | save(0); |
| 371 | luaY_lval.vWord = luaI_findconstantbyname(yytext+1); | 371 | luaY_lval.pTStr = luaI_createtempstring(yytext+1); |
| 372 | tokensize--; | 372 | tokensize--; |
| 373 | save(del); save(0); /* restore delimiter */ | 373 | save(del); save(0); /* restore delimiter */ |
| 374 | return STRING; | 374 | return STRING; |
| @@ -454,11 +454,10 @@ int luaY_lex (void) | |||
| 454 | save_and_next(); | 454 | save_and_next(); |
| 455 | } while (isalnum((unsigned char)current) || current == '_'); | 455 | } while (isalnum((unsigned char)current) || current == '_'); |
| 456 | save(0); | 456 | save(0); |
| 457 | ts = lua_createstring(yytext); | 457 | ts = luaI_createtempstring(yytext); |
| 458 | if (ts->marked > 2) | 458 | if (ts->marked > 255) |
| 459 | return ts->marked; /* reserved word */ | 459 | return ts->marked; /* reserved word */ |
| 460 | luaY_lval.pTStr = ts; | 460 | luaY_lval.pTStr = ts; |
| 461 | ts->marked = 2; /* avoid GC */ | ||
| 462 | return NAME; | 461 | return NAME; |
| 463 | } | 462 | } |
| 464 | } | 463 | } |
