aboutsummaryrefslogtreecommitdiff
path: root/llex.c
diff options
context:
space:
mode:
Diffstat (limited to 'llex.c')
-rw-r--r--llex.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/llex.c b/llex.c
index 22734d13..4e4e7d37 100644
--- a/llex.c
+++ b/llex.c
@@ -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 */
35static const char *const token2string [] = { 35const 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) {
61void luaX_init (lua_State *L) { 62void 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