lua

A copy of the Lua development repository
Log | Files | Refs | README

commit e1c2fb6eed19f597e2f05ab2dec969d144d5e4bb
parent 12dacd3c0e2fe29542520101b19a43d98aea4081
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Thu,  2 Dec 2004 10:58:48 -0200

details

Diffstat:
Mllex.c | 13+++++++------
Mllex.h | 6+++++-
Mlopcodes.c | 7++++---
Mlopcodes.h | 4++--
4 files changed, 18 insertions(+), 12 deletions(-)

diff --git 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", "<eof>" + "*number", "*string", "<eof>", + NULL }; @@ -61,9 +62,9 @@ static void save (LexState *ls, int c) { void luaX_init (lua_State *L) { int i; for (i=0; i<NUM_RESERVED; i++) { - TString *ts = luaS_new(L, token2string[i]); + TString *ts = luaS_new(L, luaX_tokens[i]); luaS_fix(ts); /* reserved words are never collected */ - lua_assert(strlen(token2string[i])+1 <= TOKEN_LEN); + lua_assert(strlen(luaX_tokens[i])+1 <= TOKEN_LEN); ts->tsv.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 @@ -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 @@ -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 @@ -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 */