mirror of https://github.com/rusefi/lua.git
parser should not call 'luaX_lexerror'
This commit is contained in:
parent
4eef0aaad1
commit
3138afbe2e
25
llex.c
25
llex.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: llex.c,v 2.26 2007/08/09 20:29:15 roberto Exp roberto $
|
** $Id: llex.c,v 2.27 2007/09/14 13:27:04 roberto Exp roberto $
|
||||||
** Lexical Analyzer
|
** Lexical Analyzer
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -47,12 +47,15 @@ static const char *const luaX_tokens [] = {
|
||||||
#define save_and_next(ls) (save(ls, ls->current), next(ls))
|
#define save_and_next(ls) (save(ls, ls->current), next(ls))
|
||||||
|
|
||||||
|
|
||||||
|
static void lexerror (LexState *ls, const char *msg, int token);
|
||||||
|
|
||||||
|
|
||||||
static void save (LexState *ls, int c) {
|
static void save (LexState *ls, int c) {
|
||||||
Mbuffer *b = ls->buff;
|
Mbuffer *b = ls->buff;
|
||||||
if (b->n + 1 > b->buffsize) {
|
if (b->n + 1 > b->buffsize) {
|
||||||
size_t newsize;
|
size_t newsize;
|
||||||
if (b->buffsize >= MAX_SIZET/2)
|
if (b->buffsize >= MAX_SIZET/2)
|
||||||
luaX_lexerror(ls, "lexical element too long", 0);
|
lexerror(ls, "lexical element too long", 0);
|
||||||
newsize = b->buffsize * 2;
|
newsize = b->buffsize * 2;
|
||||||
luaZ_resizebuffer(ls->L, b, newsize);
|
luaZ_resizebuffer(ls->L, b, newsize);
|
||||||
}
|
}
|
||||||
|
@ -103,7 +106,7 @@ static const char *txtToken (LexState *ls, int token) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void luaX_lexerror (LexState *ls, const char *msg, int token) {
|
static void lexerror (LexState *ls, const char *msg, int token) {
|
||||||
char buff[MAXSRC];
|
char buff[MAXSRC];
|
||||||
luaO_chunkid(buff, getstr(ls->source), MAXSRC);
|
luaO_chunkid(buff, getstr(ls->source), MAXSRC);
|
||||||
msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg);
|
msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg);
|
||||||
|
@ -114,7 +117,7 @@ void luaX_lexerror (LexState *ls, const char *msg, int token) {
|
||||||
|
|
||||||
|
|
||||||
void luaX_syntaxerror (LexState *ls, const char *msg) {
|
void luaX_syntaxerror (LexState *ls, const char *msg) {
|
||||||
luaX_lexerror(ls, msg, ls->t.token);
|
lexerror(ls, msg, ls->t.token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -193,7 +196,7 @@ static void trydecpoint (LexState *ls, SemInfo *seminfo) {
|
||||||
if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) {
|
if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) {
|
||||||
/* format error with correct decimal point: no more options */
|
/* format error with correct decimal point: no more options */
|
||||||
buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */
|
buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */
|
||||||
luaX_lexerror(ls, "malformed number", TK_NUMBER);
|
lexerror(ls, "malformed number", TK_NUMBER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,8 +238,8 @@ static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
switch (ls->current) {
|
switch (ls->current) {
|
||||||
case EOZ:
|
case EOZ:
|
||||||
luaX_lexerror(ls, (seminfo) ? "unfinished long string" :
|
lexerror(ls, (seminfo) ? "unfinished long string" :
|
||||||
"unfinished long comment", TK_EOS);
|
"unfinished long comment", TK_EOS);
|
||||||
break; /* to avoid warnings */
|
break; /* to avoid warnings */
|
||||||
case ']': {
|
case ']': {
|
||||||
if (skip_sep(ls) == sep) {
|
if (skip_sep(ls) == sep) {
|
||||||
|
@ -269,11 +272,11 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) {
|
||||||
while (ls->current != del) {
|
while (ls->current != del) {
|
||||||
switch (ls->current) {
|
switch (ls->current) {
|
||||||
case EOZ:
|
case EOZ:
|
||||||
luaX_lexerror(ls, "unfinished string", TK_EOS);
|
lexerror(ls, "unfinished string", TK_EOS);
|
||||||
continue; /* to avoid warnings */
|
continue; /* to avoid warnings */
|
||||||
case '\n':
|
case '\n':
|
||||||
case '\r':
|
case '\r':
|
||||||
luaX_lexerror(ls, "unfinished string", TK_STRING);
|
lexerror(ls, "unfinished string", TK_STRING);
|
||||||
continue; /* to avoid warnings */
|
continue; /* to avoid warnings */
|
||||||
case '\\': {
|
case '\\': {
|
||||||
int c;
|
int c;
|
||||||
|
@ -300,7 +303,7 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) {
|
||||||
next(ls);
|
next(ls);
|
||||||
} while (++i<3 && isdigit(ls->current));
|
} while (++i<3 && isdigit(ls->current));
|
||||||
if (c > UCHAR_MAX)
|
if (c > UCHAR_MAX)
|
||||||
luaX_lexerror(ls, "escape sequence too large", TK_STRING);
|
lexerror(ls, "escape sequence too large", TK_STRING);
|
||||||
save(ls, c);
|
save(ls, c);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -355,7 +358,7 @@ static int llex (LexState *ls, SemInfo *seminfo) {
|
||||||
return TK_STRING;
|
return TK_STRING;
|
||||||
}
|
}
|
||||||
else if (sep == -1) return '[';
|
else if (sep == -1) return '[';
|
||||||
else luaX_lexerror(ls, "invalid long string delimiter", TK_STRING);
|
else lexerror(ls, "invalid long string delimiter", TK_STRING);
|
||||||
}
|
}
|
||||||
case '=': {
|
case '=': {
|
||||||
next(ls);
|
next(ls);
|
||||||
|
|
3
llex.h
3
llex.h
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: llex.h,v 1.59 2007/02/07 17:49:18 roberto Exp roberto $
|
** $Id: llex.h,v 1.60 2007/05/11 17:28:56 roberto Exp roberto $
|
||||||
** Lexical Analyzer
|
** Lexical Analyzer
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -69,7 +69,6 @@ LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z,
|
||||||
LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l);
|
LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l);
|
||||||
LUAI_FUNC void luaX_next (LexState *ls);
|
LUAI_FUNC void luaX_next (LexState *ls);
|
||||||
LUAI_FUNC int luaX_lookahead (LexState *ls);
|
LUAI_FUNC int luaX_lookahead (LexState *ls);
|
||||||
LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token);
|
|
||||||
LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s);
|
LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s);
|
||||||
LUAI_FUNC const char *luaX_token2str (LexState *ls, int token);
|
LUAI_FUNC const char *luaX_token2str (LexState *ls, int token);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lparser.c,v 2.54 2007/07/31 19:39:52 roberto Exp roberto $
|
** $Id: lparser.c,v 2.55 2007/10/18 11:01:52 roberto Exp roberto $
|
||||||
** Lua Parser
|
** Lua Parser
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -75,7 +75,7 @@ static void errorlimit (FuncState *fs, int limit, const char *what) {
|
||||||
luaO_pushfstring(fs->L, "function at line %d", fs->f->linedefined);
|
luaO_pushfstring(fs->L, "function at line %d", fs->f->linedefined);
|
||||||
msg = luaO_pushfstring(fs->L, "too many %s (limit is %d) in %s",
|
msg = luaO_pushfstring(fs->L, "too many %s (limit is %d) in %s",
|
||||||
what, limit, where);
|
what, limit, where);
|
||||||
luaX_lexerror(fs->ls, msg, fs->ls->t.token);
|
luaX_syntaxerror(fs->ls, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue