mirror of https://github.com/rusefi/lua.git
small changes in goto-related error messages
This commit is contained in:
parent
e7a9c45a48
commit
0539f48661
23
lparser.c
23
lparser.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lparser.c,v 2.99 2011/02/07 17:14:50 roberto Exp roberto $
|
** $Id: lparser.c,v 2.100 2011/02/07 19:00:30 roberto Exp roberto $
|
||||||
** Lua Parser
|
** Lua Parser
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -68,6 +68,13 @@ static void anchor_token (LexState *ls) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* semantic error */
|
||||||
|
static void semerror (LexState *ls, const char *msg) {
|
||||||
|
ls->t.token = 0; /* remove 'near to' from final message */
|
||||||
|
luaX_syntaxerror(ls, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void error_expected (LexState *ls, int token) {
|
static void error_expected (LexState *ls, int token) {
|
||||||
luaX_syntaxerror(ls,
|
luaX_syntaxerror(ls,
|
||||||
luaO_pushfstring(ls->L, "%s expected", luaX_token2str(ls, token)));
|
luaO_pushfstring(ls->L, "%s expected", luaX_token2str(ls, token)));
|
||||||
|
@ -105,6 +112,7 @@ static void check (LexState *ls, int c) {
|
||||||
error_expected(ls, c);
|
error_expected(ls, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void checknext (LexState *ls, int c) {
|
static void checknext (LexState *ls, int c) {
|
||||||
check(ls, c);
|
check(ls, c);
|
||||||
luaX_next(ls);
|
luaX_next(ls);
|
||||||
|
@ -337,9 +345,9 @@ static void closegoto (LexState *ls, int g, Labeldesc *label) {
|
||||||
lua_assert(gt->name == label->name);
|
lua_assert(gt->name == label->name);
|
||||||
if (gt->nactvar < label->nactvar) {
|
if (gt->nactvar < label->nactvar) {
|
||||||
const char *msg = luaO_pushfstring(ls->L,
|
const char *msg = luaO_pushfstring(ls->L,
|
||||||
"<goto> at line %d attemps to jump into the scope of local " LUA_QS,
|
"<goto %s> at line %d jumps into the scope of local " LUA_QS,
|
||||||
gt->line, getstr(getlocvar(fs, gt->nactvar)->varname));;
|
getstr(gt->name), gt->line, getstr(getlocvar(fs, gt->nactvar)->varname));
|
||||||
luaX_syntaxerror(ls, msg);
|
semerror(ls, msg);
|
||||||
}
|
}
|
||||||
luaK_patchlist(fs, gt->pc, label->pc);
|
luaK_patchlist(fs, gt->pc, label->pc);
|
||||||
/* remove goto from pending list */
|
/* remove goto from pending list */
|
||||||
|
@ -360,8 +368,7 @@ static int findlabel (LexState *ls, int g) {
|
||||||
/* check labels in current block for a match */
|
/* check labels in current block for a match */
|
||||||
for (i = bl->firstlabel; i < dyd->label.n; i++) {
|
for (i = bl->firstlabel; i < dyd->label.n; i++) {
|
||||||
Labeldesc *lb = &dyd->label.arr[i];
|
Labeldesc *lb = &dyd->label.arr[i];
|
||||||
if (lb->name == gt->name) {
|
if (lb->name == gt->name) { /* correct label? */
|
||||||
lua_assert(lb->pc <= gt->pc);
|
|
||||||
if (gt->nactvar > lb->nactvar &&
|
if (gt->nactvar > lb->nactvar &&
|
||||||
(bl->upval || dyd->label.n > bl->firstlabel))
|
(bl->upval || dyd->label.n > bl->firstlabel))
|
||||||
luaK_patchclose(ls->fs, gt->pc, lb->nactvar);
|
luaK_patchclose(ls->fs, gt->pc, lb->nactvar);
|
||||||
|
@ -437,7 +444,7 @@ static void leaveblock (FuncState *fs) {
|
||||||
const char *msg = luaO_pushfstring(ls->L,
|
const char *msg = luaO_pushfstring(ls->L,
|
||||||
"label " LUA_QS " (<goto> at line %d) undefined",
|
"label " LUA_QS " (<goto> at line %d) undefined",
|
||||||
getstr(gt->name), gt->line);
|
getstr(gt->name), gt->line);
|
||||||
luaX_syntaxerror(ls, msg);
|
semerror(ls, msg);
|
||||||
}
|
}
|
||||||
if (bl->previous && bl->upval) {
|
if (bl->previous && bl->upval) {
|
||||||
/* create a 'jump to here' to close upvalues */
|
/* create a 'jump to here' to close upvalues */
|
||||||
|
@ -1162,7 +1169,7 @@ static void breakstat (LexState *ls) {
|
||||||
bl = bl->previous;
|
bl = bl->previous;
|
||||||
}
|
}
|
||||||
if (!bl)
|
if (!bl)
|
||||||
luaX_syntaxerror(ls, "no loop to break");
|
semerror(ls, "no loop to break");
|
||||||
luaK_concat(fs, &bl->breaklist, luaK_jump(fs));
|
luaK_concat(fs, &bl->breaklist, luaK_jump(fs));
|
||||||
if (upval ||
|
if (upval ||
|
||||||
(fs->nactvar > bl->nactvar &&
|
(fs->nactvar > bl->nactvar &&
|
||||||
|
|
Loading…
Reference in New Issue