diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-12-23 12:06:57 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-12-23 12:06:57 -0200 |
| commit | d3ac7075a25a28d2968efd5600041dddcdb8a9d2 (patch) | |
| tree | a8e035bf0914cf166093e5526488231586ae0061 /lparser.c | |
| parent | 0c9080c7a9c2e0f9ee39a887bbde5385160b9747 (diff) | |
| download | lua-d3ac7075a25a28d2968efd5600041dddcdb8a9d2.tar.gz lua-d3ac7075a25a28d2968efd5600041dddcdb8a9d2.tar.bz2 lua-d3ac7075a25a28d2968efd5600041dddcdb8a9d2.zip | |
better error message
Diffstat (limited to '')
| -rw-r--r-- | lparser.c | 12 |
1 files changed, 9 insertions, 3 deletions
| @@ -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 | |||
| 590 | static void error_unexpected (LexState *ls) { | ||
| 591 | luaX_error(ls, "unexpected token"); | ||
| 592 | } | ||
| 593 | |||
| 594 | |||
| 589 | static void error_unmatched (LexState *ls, int what, int who, int where) { | 595 | static 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); |
