aboutsummaryrefslogtreecommitdiff
path: root/llex.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-02-08 14:39:42 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-02-08 14:39:42 -0200
commit74f1c3d025c6d8a714454470a953f383a1c6a641 (patch)
treecc89dfa109c64ed928217d777959ffc7ace12501 /llex.c
parent1f691a4fcd32b706c79e4c8cbff17c6ae985bc34 (diff)
downloadlua-74f1c3d025c6d8a714454470a953f383a1c6a641.tar.gz
lua-74f1c3d025c6d8a714454470a953f383a1c6a641.tar.bz2
lua-74f1c3d025c6d8a714454470a953f383a1c6a641.zip
small changes for "clean C"
Diffstat (limited to 'llex.c')
-rw-r--r--llex.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/llex.c b/llex.c
index b74186d1..19edb8f0 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.c,v 1.49 2000/01/25 18:44:21 roberto Exp roberto $ 2** $Id: llex.c,v 1.50 2000/01/26 18:51:49 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*/
@@ -31,15 +31,15 @@
31 31
32 32
33/* ORDER RESERVED */ 33/* ORDER RESERVED */
34static const char *const reserved [] = {"and", "do", "else", "elseif", "end", 34static const char *const token2string [] = {"and", "do", "else", "elseif", "end",
35 "function", "if", "local", "nil", "not", "or", "repeat", "return", "then", 35 "function", "if", "local", "nil", "not", "or", "repeat", "return", "then",
36 "until", "while", "", "..", "...", "==", ">=", "<=", "~=", "", "", ""}; 36 "until", "while", "", "..", "...", "==", ">=", "<=", "~=", "", "", "<eof>"};
37 37
38 38
39void luaX_init (lua_State *L) { 39void luaX_init (lua_State *L) {
40 unsigned int i; 40 unsigned int i;
41 for (i=0; i<(sizeof(reserved)/sizeof(reserved[0])); i++) { 41 for (i=0; i<NUM_RESERVED; i++) {
42 TaggedString *ts = luaS_new(L, reserved[i]); 42 TaggedString *ts = luaS_new(L, token2string[i]);
43 ts->marked = (unsigned char)(RESERVEDMARK+i); /* reserved word */ 43 ts->marked = (unsigned char)(RESERVEDMARK+i); /* reserved word */
44 } 44 }
45} 45}
@@ -50,8 +50,6 @@ void luaX_init (lua_State *L) {
50void luaX_syntaxerror (LexState *ls, const char *s, const char *token) { 50void luaX_syntaxerror (LexState *ls, const char *s, const char *token) {
51 char buff[MAXSRC]; 51 char buff[MAXSRC];
52 luaL_chunkid(buff, zname(ls->lex_z), sizeof(buff)); 52 luaL_chunkid(buff, zname(ls->lex_z), sizeof(buff));
53 if (token[0] == '\0')
54 token = "<eof>";
55 luaL_verror(ls->L, "%.100s;\n last token read: `%.50s' at line %d in %.80s", 53 luaL_verror(ls->L, "%.100s;\n last token read: `%.50s' at line %d in %.80s",
56 s, token, ls->linenumber, buff); 54 s, token, ls->linenumber, buff);
57} 55}
@@ -75,7 +73,7 @@ void luaX_token2str (int token, char *s) {
75 s[1] = '\0'; 73 s[1] = '\0';
76 } 74 }
77 else 75 else
78 strcpy(s, reserved[token-FIRST_RESERVED]); 76 strcpy(s, token2string[token-FIRST_RESERVED]);
79} 77}
80 78
81 79