aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-12-23 12:06:57 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-12-23 12:06:57 -0200
commitd3ac7075a25a28d2968efd5600041dddcdb8a9d2 (patch)
treea8e035bf0914cf166093e5526488231586ae0061
parent0c9080c7a9c2e0f9ee39a887bbde5385160b9747 (diff)
downloadlua-d3ac7075a25a28d2968efd5600041dddcdb8a9d2.tar.gz
lua-d3ac7075a25a28d2968efd5600041dddcdb8a9d2.tar.bz2
lua-d3ac7075a25a28d2968efd5600041dddcdb8a9d2.zip
better error message
-rw-r--r--lparser.c12
-rw-r--r--ltm.c8
2 files changed, 14 insertions, 6 deletions
diff --git a/lparser.c b/lparser.c
index 02fab35a..659d64d6 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 1.4 1998/07/24 18:02:38 roberto Exp roberto $ 2** $Id: lparser.c,v 1.5 1998/08/11 13:28:05 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*/
@@ -586,6 +586,12 @@ static void error_expected (LexState *ls, int token) {
586 luaX_error(ls, buff); 586 luaX_error(ls, buff);
587} 587}
588 588
589
590static void error_unexpected (LexState *ls) {
591 luaX_error(ls, "unexpected token");
592}
593
594
589static void error_unmatched (LexState *ls, int what, int who, int where) { 595static void error_unmatched (LexState *ls, int what, int who, int where) {
590 if (where == ls->linenumber) 596 if (where == ls->linenumber)
591 error_expected(ls, what); 597 error_expected(ls, what);
@@ -759,7 +765,7 @@ static int stat (LexState *ls) {
759 return 0; 765 return 0;
760 766
761 default: 767 default:
762 luaX_error(ls, "<statement> expected"); 768 error_unexpected(ls);
763 return 0; /* to avoid warnings */ 769 return 0; /* to avoid warnings */
764 } 770 }
765} 771}
@@ -1252,7 +1258,7 @@ static void part (LexState *ls, constdesc *cd) {
1252 code_string(ls, ls->fs->localvar[v.info]); 1258 code_string(ls, ls->fs->localvar[v.info]);
1253 break; 1259 break;
1254 default: 1260 default:
1255 luaX_error(ls, "`=' unexpected"); 1261 error_unexpected(ls);
1256 } 1262 }
1257 next(ls); 1263 next(ls);
1258 exp1(ls); 1264 exp1(ls);
diff --git a/ltm.c b/ltm.c
index 94e3d041..9b1faf09 100644
--- a/ltm.c
+++ b/ltm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltm.c,v 1.16 1998/06/18 16:57:03 roberto Exp roberto $ 2** $Id: ltm.c,v 1.17 1998/08/21 17:43:44 roberto Exp roberto $
3** Tag methods 3** Tag methods
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -148,8 +148,10 @@ void luaT_settagmethod (int t, char *event, TObject *func)
148 int e = luaI_checkevent(event, luaT_eventname); 148 int e = luaI_checkevent(event, luaT_eventname);
149 checktag(t); 149 checktag(t);
150 if (!validevent(t, e)) 150 if (!validevent(t, e))
151 luaL_verror("settagmethod: cannot change tag method `%.20s' for tag %d", 151 luaL_verror("cannot change tag method `%.20s' for type `%.20s'%.20s",
152 luaT_eventname[e], t); 152 luaT_eventname[e], luaO_typenames[-t],
153 (t == LUA_T_ARRAY || t == LUA_T_USERDATA) ? " with default tag"
154 : "");
153 *func = *luaT_getim(t,e); 155 *func = *luaT_getim(t,e);
154 *luaT_getim(t, e) = temp; 156 *luaT_getim(t, e) = temp;
155} 157}