diff --git a/llex.c b/llex.c index 22734d13..4e4e7d37 100644 --- a/llex.c +++ b/llex.c @@ -1,5 +1,5 @@ /* -** $Id: llex.c,v 2.5 2004/11/24 19:16:03 roberto Exp roberto $ +** $Id: llex.c,v 2.6 2004/12/01 15:46:18 roberto Exp roberto $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -32,13 +32,14 @@ /* ORDER RESERVED */ -static const char *const token2string [] = { +const char *const luaX_tokens [] = { "and", "break", "do", "else", "elseif", "end", "false", "for", "function", "if", "in", "local", "nil", "not", "or", "repeat", "return", "then", "true", "until", "while", "*name", "..", "...", "==", ">=", "<=", "~=", - "*number", "*string", "" + "*number", "*string", "", + NULL }; @@ -61,9 +62,9 @@ static void save (LexState *ls, int c) { void luaX_init (lua_State *L) { int i; for (i=0; itsv.reserved = cast(lu_byte, i+1); /* reserved word */ } } @@ -79,7 +80,7 @@ const char *luaX_token2str (LexState *ls, int token) { luaO_pushfstring(ls->L, "%c", token); } else - return token2string[token-FIRST_RESERVED]; + return luaX_tokens[token-FIRST_RESERVED]; } diff --git a/llex.h b/llex.h index deb9e74d..022e175d 100644 --- a/llex.h +++ b/llex.h @@ -1,5 +1,5 @@ /* -** $Id: llex.h,v 1.49 2003/10/20 12:24:34 roberto Exp roberto $ +** $Id: llex.h,v 1.50 2004/03/12 19:53:56 roberto Exp roberto $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -36,6 +36,10 @@ enum RESERVED { #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) +/* array with token `names' */ +extern const char *const luaX_tokens []; + + typedef union { lua_Number r; TString *ts; diff --git a/lopcodes.c b/lopcodes.c index dc5be46f..d4e8556e 100644 --- a/lopcodes.c +++ b/lopcodes.c @@ -1,5 +1,5 @@ /* -** $Id: lopcodes.c,v 1.28 2004/07/16 13:15:32 roberto Exp $ +** $Id: lopcodes.c,v 1.29 2004/10/04 19:01:53 roberto Exp roberto $ ** See Copyright Notice in lua.h */ @@ -15,7 +15,7 @@ /* ORDER OP */ -const char *const luaP_opnames[NUM_OPCODES] = { +const char *const luaP_opnames[NUM_OPCODES+1] = { "MOVE", "LOADK", "LOADBOOL", @@ -51,7 +51,8 @@ const char *const luaP_opnames[NUM_OPCODES] = { "SETLIST", "CLOSE", "CLOSURE", - "VARARG" + "VARARG", + NULL }; diff --git a/lopcodes.h b/lopcodes.h index 173e44c9..fa637e08 100644 --- a/lopcodes.h +++ b/lopcodes.h @@ -1,5 +1,5 @@ /* -** $Id: lopcodes.h,v 1.112 2004/10/04 19:01:53 roberto Exp roberto $ +** $Id: lopcodes.h,v 1.113 2004/10/04 19:07:42 roberto Exp roberto $ ** Opcodes for Lua virtual machine ** See Copyright Notice in lua.h */ @@ -257,7 +257,7 @@ extern const lu_byte luaP_opmodes[NUM_OPCODES]; #define testTMode(m) (luaP_opmodes[m] & (1 << 7)) -extern const char *const luaP_opnames[NUM_OPCODES]; /* opcode names */ +extern const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */ /* number of list items to accumulate before a SETLIST instruction */