diff options
| -rw-r--r-- | llex.c | 7 | ||||
| -rw-r--r-- | llex.h | 6 | ||||
| -rw-r--r-- | lparser.c | 10 |
3 files changed, 12 insertions, 11 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: llex.c,v 1.71 2000/09/27 17:41:58 roberto Exp roberto $ | 2 | ** $Id: llex.c,v 1.72 2000/10/20 16:39:03 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 | */ |
| @@ -38,6 +38,7 @@ void luaX_init (lua_State *L) { | |||
| 38 | int i; | 38 | int i; |
| 39 | for (i=0; i<NUM_RESERVED; i++) { | 39 | for (i=0; i<NUM_RESERVED; i++) { |
| 40 | TString *ts = luaS_new(L, token2string[i]); | 40 | TString *ts = luaS_new(L, token2string[i]); |
| 41 | LUA_ASSERT(strlen(token2string[i])+1 <= TOKEN_LEN, "incorrect token_len"); | ||
| 41 | ts->marked = (unsigned char)(RESERVEDMARK+i); /* reserved word */ | 42 | ts->marked = (unsigned char)(RESERVEDMARK+i); /* reserved word */ |
| 42 | } | 43 | } |
| 43 | } | 44 | } |
| @@ -48,8 +49,8 @@ void luaX_init (lua_State *L) { | |||
| 48 | 49 | ||
| 49 | void luaX_checklimit (LexState *ls, int val, int limit, const char *msg) { | 50 | void luaX_checklimit (LexState *ls, int val, int limit, const char *msg) { |
| 50 | if (val > limit) { | 51 | if (val > limit) { |
| 51 | char buff[100]; | 52 | char buff[90]; |
| 52 | sprintf(buff, "too many %.50s (limit=%d)", msg, limit); | 53 | sprintf(buff, "too many %.40s (limit=%d)", msg, limit); |
| 53 | luaX_error(ls, buff, ls->t.token); | 54 | luaX_error(ls, buff, ls->t.token); |
| 54 | } | 55 | } |
| 55 | } | 56 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: llex.h,v 1.31 2000/09/27 17:41:58 roberto Exp roberto $ | 2 | ** $Id: llex.h,v 1.32 2000/12/04 18:33:40 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 | */ |
| @@ -13,8 +13,8 @@ | |||
| 13 | 13 | ||
| 14 | #define FIRST_RESERVED 257 | 14 | #define FIRST_RESERVED 257 |
| 15 | 15 | ||
| 16 | /* maximum length of a reserved word (+1 for final 0) */ | 16 | /* maximum length of a reserved word */ |
| 17 | #define TOKEN_LEN 15 | 17 | #define TOKEN_LEN (sizeof("function")) |
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | /* | 20 | /* |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lparser.c,v 1.120 2000/12/26 18:46:09 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 1.121 2000/12/28 12:55:41 roberto Exp roberto $ |
| 3 | ** LL(1) Parser and code generator for Lua | 3 | ** LL(1) Parser and code generator for Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -71,9 +71,9 @@ static void lookahead (LexState *ls) { | |||
| 71 | 71 | ||
| 72 | 72 | ||
| 73 | static void error_expected (LexState *ls, int token) { | 73 | static void error_expected (LexState *ls, int token) { |
| 74 | char buff[100], t[TOKEN_LEN]; | 74 | char buff[30], t[TOKEN_LEN]; |
| 75 | luaX_token2str(token, t); | 75 | luaX_token2str(token, t); |
| 76 | sprintf(buff, "`%.20s' expected", t); | 76 | sprintf(buff, "`%.10s' expected", t); |
| 77 | luaK_error(ls, buff); | 77 | luaK_error(ls, buff); |
| 78 | } | 78 | } |
| 79 | 79 | ||
| @@ -104,11 +104,11 @@ static void check_match (LexState *ls, int what, int who, int where) { | |||
| 104 | if (where == ls->linenumber) | 104 | if (where == ls->linenumber) |
| 105 | error_expected(ls, what); | 105 | error_expected(ls, what); |
| 106 | else { | 106 | else { |
| 107 | char buff[100]; | 107 | char buff[70]; |
| 108 | char t_what[TOKEN_LEN], t_who[TOKEN_LEN]; | 108 | char t_what[TOKEN_LEN], t_who[TOKEN_LEN]; |
| 109 | luaX_token2str(what, t_what); | 109 | luaX_token2str(what, t_what); |
| 110 | luaX_token2str(who, t_who); | 110 | luaX_token2str(who, t_who); |
| 111 | sprintf(buff, "`%.20s' expected (to close `%.20s' at line %d)", | 111 | sprintf(buff, "`%.10s' expected (to close `%.10s' at line %d)", |
| 112 | t_what, t_who, where); | 112 | t_what, t_who, where); |
| 113 | luaK_error(ls, buff); | 113 | luaK_error(ls, buff); |
| 114 | } | 114 | } |
