diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-12-02 10:59:10 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-12-02 10:59:10 -0200 |
commit | e1c2fb6eed19f597e2f05ab2dec969d144d5e4bb (patch) | |
tree | 0df94b93204db2c9969b5da1e05ea5d846d98bc4 | |
parent | 12dacd3c0e2fe29542520101b19a43d98aea4081 (diff) | |
download | lua-e1c2fb6eed19f597e2f05ab2dec969d144d5e4bb.tar.gz lua-e1c2fb6eed19f597e2f05ab2dec969d144d5e4bb.tar.bz2 lua-e1c2fb6eed19f597e2f05ab2dec969d144d5e4bb.zip |
details
-rw-r--r-- | llex.c | 13 | ||||
-rw-r--r-- | llex.h | 6 | ||||
-rw-r--r-- | lopcodes.c | 7 | ||||
-rw-r--r-- | lopcodes.h | 4 |
4 files changed, 18 insertions, 12 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llex.c,v 2.5 2004/11/24 19:16:03 roberto Exp roberto $ | 2 | ** $Id: llex.c,v 2.6 2004/12/01 15:46:18 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 | */ |
@@ -32,13 +32,14 @@ | |||
32 | 32 | ||
33 | 33 | ||
34 | /* ORDER RESERVED */ | 34 | /* ORDER RESERVED */ |
35 | static const char *const token2string [] = { | 35 | const char *const luaX_tokens [] = { |
36 | "and", "break", "do", "else", "elseif", | 36 | "and", "break", "do", "else", "elseif", |
37 | "end", "false", "for", "function", "if", | 37 | "end", "false", "for", "function", "if", |
38 | "in", "local", "nil", "not", "or", "repeat", | 38 | "in", "local", "nil", "not", "or", "repeat", |
39 | "return", "then", "true", "until", "while", "*name", | 39 | "return", "then", "true", "until", "while", "*name", |
40 | "..", "...", "==", ">=", "<=", "~=", | 40 | "..", "...", "==", ">=", "<=", "~=", |
41 | "*number", "*string", "<eof>" | 41 | "*number", "*string", "<eof>", |
42 | NULL | ||
42 | }; | 43 | }; |
43 | 44 | ||
44 | 45 | ||
@@ -61,9 +62,9 @@ static void save (LexState *ls, int c) { | |||
61 | void luaX_init (lua_State *L) { | 62 | void luaX_init (lua_State *L) { |
62 | int i; | 63 | int i; |
63 | for (i=0; i<NUM_RESERVED; i++) { | 64 | for (i=0; i<NUM_RESERVED; i++) { |
64 | TString *ts = luaS_new(L, token2string[i]); | 65 | TString *ts = luaS_new(L, luaX_tokens[i]); |
65 | luaS_fix(ts); /* reserved words are never collected */ | 66 | luaS_fix(ts); /* reserved words are never collected */ |
66 | lua_assert(strlen(token2string[i])+1 <= TOKEN_LEN); | 67 | lua_assert(strlen(luaX_tokens[i])+1 <= TOKEN_LEN); |
67 | ts->tsv.reserved = cast(lu_byte, i+1); /* reserved word */ | 68 | ts->tsv.reserved = cast(lu_byte, i+1); /* reserved word */ |
68 | } | 69 | } |
69 | } | 70 | } |
@@ -79,7 +80,7 @@ const char *luaX_token2str (LexState *ls, int token) { | |||
79 | luaO_pushfstring(ls->L, "%c", token); | 80 | luaO_pushfstring(ls->L, "%c", token); |
80 | } | 81 | } |
81 | else | 82 | else |
82 | return token2string[token-FIRST_RESERVED]; | 83 | return luaX_tokens[token-FIRST_RESERVED]; |
83 | } | 84 | } |
84 | 85 | ||
85 | 86 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llex.h,v 1.49 2003/10/20 12:24:34 roberto Exp roberto $ | 2 | ** $Id: llex.h,v 1.50 2004/03/12 19:53: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 | */ |
@@ -36,6 +36,10 @@ enum RESERVED { | |||
36 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) | 36 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) |
37 | 37 | ||
38 | 38 | ||
39 | /* array with token `names' */ | ||
40 | extern const char *const luaX_tokens []; | ||
41 | |||
42 | |||
39 | typedef union { | 43 | typedef union { |
40 | lua_Number r; | 44 | lua_Number r; |
41 | TString *ts; | 45 | TString *ts; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lopcodes.c,v 1.28 2004/07/16 13:15:32 roberto Exp $ | 2 | ** $Id: lopcodes.c,v 1.29 2004/10/04 19:01:53 roberto Exp roberto $ |
3 | ** See Copyright Notice in lua.h | 3 | ** See Copyright Notice in lua.h |
4 | */ | 4 | */ |
5 | 5 | ||
@@ -15,7 +15,7 @@ | |||
15 | 15 | ||
16 | /* ORDER OP */ | 16 | /* ORDER OP */ |
17 | 17 | ||
18 | const char *const luaP_opnames[NUM_OPCODES] = { | 18 | const char *const luaP_opnames[NUM_OPCODES+1] = { |
19 | "MOVE", | 19 | "MOVE", |
20 | "LOADK", | 20 | "LOADK", |
21 | "LOADBOOL", | 21 | "LOADBOOL", |
@@ -51,7 +51,8 @@ const char *const luaP_opnames[NUM_OPCODES] = { | |||
51 | "SETLIST", | 51 | "SETLIST", |
52 | "CLOSE", | 52 | "CLOSE", |
53 | "CLOSURE", | 53 | "CLOSURE", |
54 | "VARARG" | 54 | "VARARG", |
55 | NULL | ||
55 | }; | 56 | }; |
56 | 57 | ||
57 | 58 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lopcodes.h,v 1.112 2004/10/04 19:01:53 roberto Exp roberto $ | 2 | ** $Id: lopcodes.h,v 1.113 2004/10/04 19:07:42 roberto Exp roberto $ |
3 | ** Opcodes for Lua virtual machine | 3 | ** Opcodes for Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -257,7 +257,7 @@ extern const lu_byte luaP_opmodes[NUM_OPCODES]; | |||
257 | #define testTMode(m) (luaP_opmodes[m] & (1 << 7)) | 257 | #define testTMode(m) (luaP_opmodes[m] & (1 << 7)) |
258 | 258 | ||
259 | 259 | ||
260 | extern const char *const luaP_opnames[NUM_OPCODES]; /* opcode names */ | 260 | extern const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */ |
261 | 261 | ||
262 | 262 | ||
263 | /* number of list items to accumulate before a SETLIST instruction */ | 263 | /* number of list items to accumulate before a SETLIST instruction */ |