From d3ac7075a25a28d2968efd5600041dddcdb8a9d2 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 23 Dec 1998 12:06:57 -0200 Subject: [PATCH] better error message --- lparser.c | 12 +++++++++--- ltm.c | 8 +++++--- 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 @@ /* -** $Id: lparser.c,v 1.4 1998/07/24 18:02:38 roberto Exp roberto $ +** $Id: lparser.c,v 1.5 1998/08/11 13:28:05 roberto Exp roberto $ ** LL(1) Parser and code generator for Lua ** See Copyright Notice in lua.h */ @@ -586,6 +586,12 @@ static void error_expected (LexState *ls, int token) { luaX_error(ls, buff); } + +static void error_unexpected (LexState *ls) { + luaX_error(ls, "unexpected token"); +} + + static void error_unmatched (LexState *ls, int what, int who, int where) { if (where == ls->linenumber) error_expected(ls, what); @@ -759,7 +765,7 @@ static int stat (LexState *ls) { return 0; default: - luaX_error(ls, " expected"); + error_unexpected(ls); return 0; /* to avoid warnings */ } } @@ -1252,7 +1258,7 @@ static void part (LexState *ls, constdesc *cd) { code_string(ls, ls->fs->localvar[v.info]); break; default: - luaX_error(ls, "`=' unexpected"); + error_unexpected(ls); } next(ls); exp1(ls); diff --git a/ltm.c b/ltm.c index 94e3d041..9b1faf09 100644 --- a/ltm.c +++ b/ltm.c @@ -1,5 +1,5 @@ /* -** $Id: ltm.c,v 1.16 1998/06/18 16:57:03 roberto Exp roberto $ +** $Id: ltm.c,v 1.17 1998/08/21 17:43:44 roberto Exp roberto $ ** Tag methods ** See Copyright Notice in lua.h */ @@ -148,8 +148,10 @@ void luaT_settagmethod (int t, char *event, TObject *func) int e = luaI_checkevent(event, luaT_eventname); checktag(t); if (!validevent(t, e)) - luaL_verror("settagmethod: cannot change tag method `%.20s' for tag %d", - luaT_eventname[e], t); + luaL_verror("cannot change tag method `%.20s' for type `%.20s'%.20s", + luaT_eventname[e], luaO_typenames[-t], + (t == LUA_T_ARRAY || t == LUA_T_USERDATA) ? " with default tag" + : ""); *func = *luaT_getim(t,e); *luaT_getim(t, e) = temp; }