diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-07-10 17:02:22 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-07-10 17:02:22 -0300 |
| commit | a3d03ff6b68a9ba5351d88225283fcad9e80be60 (patch) | |
| tree | 0db7fcf01b02f57267aeef0db688bca69be2e82d | |
| parent | 654b16e83aad64643d524295300cf29677b7f2ba (diff) | |
| download | lua-a3d03ff6b68a9ba5351d88225283fcad9e80be60.tar.gz lua-a3d03ff6b68a9ba5351d88225283fcad9e80be60.tar.bz2 lua-a3d03ff6b68a9ba5351d88225283fcad9e80be60.zip | |
bug: error message for `%a' gave wrong line number
| -rw-r--r-- | bugs | 6 | ||||
| -rw-r--r-- | lparser.c | 21 |
2 files changed, 20 insertions, 7 deletions
| @@ -264,3 +264,9 @@ Fri Feb 2 14:06:40 EDT 2001 | |||
| 264 | Tue Feb 6 11:57:13 EDT 2001 | 264 | Tue Feb 6 11:57:13 EDT 2001 |
| 265 | >> ESC (which starts precompiled code) in C is \33, not \27 | 265 | >> ESC (which starts precompiled code) in C is \33, not \27 |
| 266 | (by Edgar Toernig and lhf; since 4.0b) | 266 | (by Edgar Toernig and lhf; since 4.0b) |
| 267 | |||
| 268 | ** lparser.c | ||
| 269 | Tue Jul 10 16:59:18 EST 2001 | ||
| 270 | >> error message for `%a' gave wrong line number | ||
| 271 | (by Leonardo Constantino; since 4.0) | ||
| 272 | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lparser.c,v 1.150 2001/06/20 21:07:57 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 1.151 2001/06/28 14:57:17 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 | */ |
| @@ -121,11 +121,8 @@ static void check_match (LexState *ls, int what, int who, int where) { | |||
| 121 | 121 | ||
| 122 | 122 | ||
| 123 | static TString *str_checkname (LexState *ls) { | 123 | static TString *str_checkname (LexState *ls) { |
| 124 | TString *ts; | ||
| 125 | check_condition(ls, (ls->t.token == TK_NAME), l_s("<name> expected")); | 124 | check_condition(ls, (ls->t.token == TK_NAME), l_s("<name> expected")); |
| 126 | ts = ls->t.seminfo.ts; | 125 | return ls->t.seminfo.ts; |
| 127 | next(ls); | ||
| 128 | return ts; | ||
| 129 | } | 126 | } |
| 130 | 127 | ||
| 131 | 128 | ||
| @@ -141,7 +138,10 @@ static void codestring (LexState *ls, expdesc *e, TString *s) { | |||
| 141 | } | 138 | } |
| 142 | 139 | ||
| 143 | 140 | ||
| 144 | #define checkname(ls,e) codestring(ls,e,str_checkname(ls)) | 141 | static void checkname(LexState *ls, expdesc *e) { |
| 142 | codestring(ls, e, str_checkname(ls)); | ||
| 143 | next(ls); | ||
| 144 | } | ||
| 145 | 145 | ||
| 146 | 146 | ||
| 147 | static int luaI_registerlocalvar (LexState *ls, TString *varname) { | 147 | static int luaI_registerlocalvar (LexState *ls, TString *varname) { |
| @@ -641,11 +641,13 @@ static void primaryexp (LexState *ls, expdesc *v) { | |||
| 641 | } | 641 | } |
| 642 | case TK_NAME: { | 642 | case TK_NAME: { |
| 643 | singlevar(ls, str_checkname(ls), v); | 643 | singlevar(ls, str_checkname(ls), v); |
| 644 | next(ls); | ||
| 644 | return; | 645 | return; |
| 645 | } | 646 | } |
| 646 | case l_c('%'): { | 647 | case l_c('%'): { |
| 647 | next(ls); /* skip `%' */ | 648 | next(ls); /* skip `%' */ |
| 648 | codeupvalue(ls, v, str_checkname(ls)); | 649 | codeupvalue(ls, v, str_checkname(ls)); |
| 650 | next(ls); | ||
| 649 | break; | 651 | break; |
| 650 | } | 652 | } |
| 651 | default: { | 653 | default: { |
| @@ -960,6 +962,7 @@ static void forlist (LexState *ls, TString *indexname) { | |||
| 960 | TString *valname; | 962 | TString *valname; |
| 961 | check(ls, l_c(',')); | 963 | check(ls, l_c(',')); |
| 962 | valname = str_checkname(ls); | 964 | valname = str_checkname(ls); |
| 965 | next(ls); /* skip var name */ | ||
| 963 | check(ls, TK_IN); | 966 | check(ls, TK_IN); |
| 964 | exp1(ls); /* table */ | 967 | exp1(ls); /* table */ |
| 965 | new_localvarstr(ls, l_s("(table)"), 0); | 968 | new_localvarstr(ls, l_s("(table)"), 0); |
| @@ -979,6 +982,7 @@ static void forstat (LexState *ls, int line) { | |||
| 979 | enterbreak(fs, &bl); | 982 | enterbreak(fs, &bl); |
| 980 | next(ls); /* skip `for' */ | 983 | next(ls); /* skip `for' */ |
| 981 | varname = str_checkname(ls); /* first variable name */ | 984 | varname = str_checkname(ls); /* first variable name */ |
| 985 | next(ls); /* skip var name */ | ||
| 982 | switch (ls->t.token) { | 986 | switch (ls->t.token) { |
| 983 | case l_c('='): fornum(ls, varname); break; | 987 | case l_c('='): fornum(ls, varname); break; |
| 984 | case l_c(','): forlist(ls, varname); break; | 988 | case l_c(','): forlist(ls, varname); break; |
| @@ -1030,6 +1034,7 @@ static void localstat (LexState *ls) { | |||
| 1030 | do { | 1034 | do { |
| 1031 | next(ls); /* skip LOCAL or `,' */ | 1035 | next(ls); /* skip LOCAL or `,' */ |
| 1032 | new_localvar(ls, str_checkname(ls), nvars++); | 1036 | new_localvar(ls, str_checkname(ls), nvars++); |
| 1037 | next(ls); /* skip var name */ | ||
| 1033 | } while (ls->t.token == l_c(',')); | 1038 | } while (ls->t.token == l_c(',')); |
| 1034 | if (optional(ls, l_c('='))) | 1039 | if (optional(ls, l_c('='))) |
| 1035 | nexps = explist1(ls, &e); | 1040 | nexps = explist1(ls, &e); |
| @@ -1046,6 +1051,7 @@ static int funcname (LexState *ls, expdesc *v) { | |||
| 1046 | /* funcname -> NAME {field} [`:' NAME] */ | 1051 | /* funcname -> NAME {field} [`:' NAME] */ |
| 1047 | int needself = 0; | 1052 | int needself = 0; |
| 1048 | singlevar(ls, str_checkname(ls), v); | 1053 | singlevar(ls, str_checkname(ls), v); |
| 1054 | next(ls); /* skip var name */ | ||
| 1049 | while (ls->t.token == l_c('.')) { | 1055 | while (ls->t.token == l_c('.')) { |
| 1050 | luaY_field(ls, v); | 1056 | luaY_field(ls, v); |
| 1051 | } | 1057 | } |
| @@ -1188,10 +1194,11 @@ static void parlist (LexState *ls) { | |||
| 1188 | if (ls->t.token != l_c(')')) { /* is `parlist' not empty? */ | 1194 | if (ls->t.token != l_c(')')) { /* is `parlist' not empty? */ |
| 1189 | do { | 1195 | do { |
| 1190 | switch (ls->t.token) { | 1196 | switch (ls->t.token) { |
| 1191 | case TK_DOTS: next(ls); dots = 1; break; | 1197 | case TK_DOTS: dots = 1; break; |
| 1192 | case TK_NAME: new_localvar(ls, str_checkname(ls), nparams++); break; | 1198 | case TK_NAME: new_localvar(ls, str_checkname(ls), nparams++); break; |
| 1193 | default: luaK_error(ls, l_s("<name> or `...' expected")); | 1199 | default: luaK_error(ls, l_s("<name> or `...' expected")); |
| 1194 | } | 1200 | } |
| 1201 | next(ls); | ||
| 1195 | } while (!dots && optional(ls, l_c(','))); | 1202 | } while (!dots && optional(ls, l_c(','))); |
| 1196 | } | 1203 | } |
| 1197 | code_params(ls, nparams, dots); | 1204 | code_params(ls, nparams, dots); |
