diff options
-rw-r--r-- | lparser.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 2.126 2012/04/20 19:20:05 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 2.127 2012/05/08 13:53:33 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 | */ |
@@ -1202,6 +1202,13 @@ static void checkrepeated (FuncState *fs, Labellist *ll, TString *label) { | |||
1202 | } | 1202 | } |
1203 | 1203 | ||
1204 | 1204 | ||
1205 | /* skip no-op statements */ | ||
1206 | static void skipnoopstat (LexState *ls) { | ||
1207 | while (ls->t.token == ';' || ls->t.token == TK_DBCOLON) | ||
1208 | statement(ls); | ||
1209 | } | ||
1210 | |||
1211 | |||
1205 | static void labelstat (LexState *ls, TString *label, int line) { | 1212 | static void labelstat (LexState *ls, TString *label, int line) { |
1206 | /* label -> '::' NAME '::' */ | 1213 | /* label -> '::' NAME '::' */ |
1207 | FuncState *fs = ls->fs; | 1214 | FuncState *fs = ls->fs; |
@@ -1211,9 +1218,7 @@ static void labelstat (LexState *ls, TString *label, int line) { | |||
1211 | checknext(ls, TK_DBCOLON); /* skip double colon */ | 1218 | checknext(ls, TK_DBCOLON); /* skip double colon */ |
1212 | /* create new entry for this label */ | 1219 | /* create new entry for this label */ |
1213 | l = newlabelentry(ls, ll, label, line, fs->pc); | 1220 | l = newlabelentry(ls, ll, label, line, fs->pc); |
1214 | /* skip other no-op statements */ | 1221 | skipnoopstat(ls); /* skip other no-op statements */ |
1215 | while (ls->t.token == ';' || ls->t.token == TK_DBCOLON) | ||
1216 | statement(ls); | ||
1217 | if (block_follow(ls, 0)) { /* label is last no-op statement in the block? */ | 1222 | if (block_follow(ls, 0)) { /* label is last no-op statement in the block? */ |
1218 | /* assume that locals are already out of scope */ | 1223 | /* assume that locals are already out of scope */ |
1219 | ll->arr[l].nactvar = fs->bl->nactvar; | 1224 | ll->arr[l].nactvar = fs->bl->nactvar; |
@@ -1376,6 +1381,7 @@ static void test_then_block (LexState *ls, int *escapelist) { | |||
1376 | luaK_goiffalse(ls->fs, &v); /* will jump to label if condition is true */ | 1381 | luaK_goiffalse(ls->fs, &v); /* will jump to label if condition is true */ |
1377 | enterblock(fs, &bl, 0); /* must enter block before 'goto' */ | 1382 | enterblock(fs, &bl, 0); /* must enter block before 'goto' */ |
1378 | gotostat(ls, v.t); /* handle goto/break */ | 1383 | gotostat(ls, v.t); /* handle goto/break */ |
1384 | skipnoopstat(ls); /* skip other no-op statements */ | ||
1379 | if (block_follow(ls, 0)) { /* 'goto' is the entire block? */ | 1385 | if (block_follow(ls, 0)) { /* 'goto' is the entire block? */ |
1380 | leaveblock(fs); | 1386 | leaveblock(fs); |
1381 | return; /* and that is it */ | 1387 | return; /* and that is it */ |