diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-02-28 14:19:47 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-02-28 14:19:47 -0300 |
commit | 6b6bc532a4f5e335540e6f19914cfe8435d064ed (patch) | |
tree | a7d456a86bf86ef6d6e1333d7372f17ad9562773 | |
parent | ea16ee41a8b0e6fe2c8f77e901a7d99173065beb (diff) | |
download | lua-6b6bc532a4f5e335540e6f19914cfe8435d064ed.tar.gz lua-6b6bc532a4f5e335540e6f19914cfe8435d064ed.tar.bz2 lua-6b6bc532a4f5e335540e6f19914cfe8435d064ed.zip |
better error message for (deprecated) "%global"
-rw-r--r-- | llex.c | 11 | ||||
-rw-r--r-- | llex.h | 3 | ||||
-rw-r--r-- | lparser.c | 16 |
3 files changed, 21 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llex.c,v 1.116 2002/10/23 19:08:13 roberto Exp roberto $ | 2 | ** $Id: llex.c,v 1.117 2002/12/04 17:38:31 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 | */ |
@@ -59,15 +59,20 @@ void luaX_checklimit (LexState *ls, int val, int limit, const char *msg) { | |||
59 | } | 59 | } |
60 | 60 | ||
61 | 61 | ||
62 | static void luaX_error (LexState *ls, const char *s, const char *token) { | 62 | void luaX_errorline (LexState *ls, const char *s, const char *token, int line) { |
63 | lua_State *L = ls->L; | 63 | lua_State *L = ls->L; |
64 | char buff[MAXSRC]; | 64 | char buff[MAXSRC]; |
65 | luaO_chunkid(buff, getstr(ls->source), MAXSRC); | 65 | luaO_chunkid(buff, getstr(ls->source), MAXSRC); |
66 | luaO_pushfstring(L, "%s:%d: %s near `%s'", buff, ls->linenumber, s, token); | 66 | luaO_pushfstring(L, "%s:%d: %s near `%s'", buff, line, s, token); |
67 | luaD_throw(L, LUA_ERRSYNTAX); | 67 | luaD_throw(L, LUA_ERRSYNTAX); |
68 | } | 68 | } |
69 | 69 | ||
70 | 70 | ||
71 | static void luaX_error (LexState *ls, const char *s, const char *token) { | ||
72 | luaX_errorline(ls, s, token, ls->linenumber); | ||
73 | } | ||
74 | |||
75 | |||
71 | void luaX_syntaxerror (LexState *ls, const char *msg) { | 76 | void luaX_syntaxerror (LexState *ls, const char *msg) { |
72 | const char *lasttoken; | 77 | const char *lasttoken; |
73 | switch (ls->t.token) { | 78 | switch (ls->t.token) { |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llex.h,v 1.45 2002/10/08 18:46:08 roberto Exp roberto $ | 2 | ** $Id: llex.h,v 1.46 2002/11/22 16:35:20 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 | */ |
@@ -68,6 +68,7 @@ void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source); | |||
68 | int luaX_lex (LexState *LS, SemInfo *seminfo); | 68 | int luaX_lex (LexState *LS, SemInfo *seminfo); |
69 | void luaX_checklimit (LexState *ls, int val, int limit, const char *msg); | 69 | void luaX_checklimit (LexState *ls, int val, int limit, const char *msg); |
70 | void luaX_syntaxerror (LexState *ls, const char *s); | 70 | void luaX_syntaxerror (LexState *ls, const char *s); |
71 | void luaX_errorline (LexState *ls, const char *s, const char *token, int line); | ||
71 | const char *luaX_token2str (LexState *ls, int token); | 72 | const char *luaX_token2str (LexState *ls, int token); |
72 | 73 | ||
73 | 74 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 1.205 2003/02/11 10:49:53 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 1.206 2003/02/18 16:02:56 roberto Exp roberto $ |
3 | ** Lua Parser | 3 | ** Lua Parser |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -240,8 +240,10 @@ static void singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) { | |||
240 | } | 240 | } |
241 | 241 | ||
242 | 242 | ||
243 | static void singlevar (LexState *ls, expdesc *var, int base) { | 243 | static TString *singlevar (LexState *ls, expdesc *var, int base) { |
244 | singlevaraux(ls->fs, str_checkname(ls), var, base); | 244 | TString *varname = str_checkname(ls); |
245 | singlevaraux(ls->fs, varname, var, base); | ||
246 | return varname; | ||
245 | } | 247 | } |
246 | 248 | ||
247 | 249 | ||
@@ -645,9 +647,13 @@ static void prefixexp (LexState *ls, expdesc *v) { | |||
645 | } | 647 | } |
646 | #ifdef LUA_COMPATUPSYNTAX | 648 | #ifdef LUA_COMPATUPSYNTAX |
647 | case '%': { /* for compatibility only */ | 649 | case '%': { /* for compatibility only */ |
650 | TString *varname; | ||
651 | int line = ls->linenumber; | ||
648 | next(ls); /* skip `%' */ | 652 | next(ls); /* skip `%' */ |
649 | singlevar(ls, v, 1); | 653 | varname = singlevar(ls, v, 1); |
650 | check_condition(ls, v->k == VUPVAL, "global upvalues are obsolete"); | 654 | if (v->k != VUPVAL) |
655 | luaX_errorline(ls, "global upvalues are obsolete", | ||
656 | getstr(varname), line); | ||
651 | return; | 657 | return; |
652 | } | 658 | } |
653 | #endif | 659 | #endif |