diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2007-10-25 14:45:47 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2007-10-25 14:45:47 -0200 |
commit | 3138afbe2e16f5a9ac3c40757e30b9563b23256b (patch) | |
tree | 77817f0b12f833188b9439fa90d057bc0178ac87 | |
parent | 4eef0aaad19cb442fc7b103eda9a249aa4c0ecef (diff) | |
download | lua-3138afbe2e16f5a9ac3c40757e30b9563b23256b.tar.gz lua-3138afbe2e16f5a9ac3c40757e30b9563b23256b.tar.bz2 lua-3138afbe2e16f5a9ac3c40757e30b9563b23256b.zip |
parser should not call 'luaX_lexerror'
-rw-r--r-- | llex.c | 25 | ||||
-rw-r--r-- | llex.h | 3 | ||||
-rw-r--r-- | lparser.c | 4 |
3 files changed, 17 insertions, 15 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llex.c,v 2.26 2007/08/09 20:29:15 roberto Exp roberto $ | 2 | ** $Id: llex.c,v 2.27 2007/09/14 13:27:04 roberto Exp roberto $ |
3 | ** Lexical Analyzer | 3 | ** Lexical Analyzer |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -47,12 +47,15 @@ static const char *const luaX_tokens [] = { | |||
47 | #define save_and_next(ls) (save(ls, ls->current), next(ls)) | 47 | #define save_and_next(ls) (save(ls, ls->current), next(ls)) |
48 | 48 | ||
49 | 49 | ||
50 | static void lexerror (LexState *ls, const char *msg, int token); | ||
51 | |||
52 | |||
50 | static void save (LexState *ls, int c) { | 53 | static void save (LexState *ls, int c) { |
51 | Mbuffer *b = ls->buff; | 54 | Mbuffer *b = ls->buff; |
52 | if (b->n + 1 > b->buffsize) { | 55 | if (b->n + 1 > b->buffsize) { |
53 | size_t newsize; | 56 | size_t newsize; |
54 | if (b->buffsize >= MAX_SIZET/2) | 57 | if (b->buffsize >= MAX_SIZET/2) |
55 | luaX_lexerror(ls, "lexical element too long", 0); | 58 | lexerror(ls, "lexical element too long", 0); |
56 | newsize = b->buffsize * 2; | 59 | newsize = b->buffsize * 2; |
57 | luaZ_resizebuffer(ls->L, b, newsize); | 60 | luaZ_resizebuffer(ls->L, b, newsize); |
58 | } | 61 | } |
@@ -103,7 +106,7 @@ static const char *txtToken (LexState *ls, int token) { | |||
103 | } | 106 | } |
104 | 107 | ||
105 | 108 | ||
106 | void luaX_lexerror (LexState *ls, const char *msg, int token) { | 109 | static void lexerror (LexState *ls, const char *msg, int token) { |
107 | char buff[MAXSRC]; | 110 | char buff[MAXSRC]; |
108 | luaO_chunkid(buff, getstr(ls->source), MAXSRC); | 111 | luaO_chunkid(buff, getstr(ls->source), MAXSRC); |
109 | msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg); | 112 | 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) { | |||
114 | 117 | ||
115 | 118 | ||
116 | void luaX_syntaxerror (LexState *ls, const char *msg) { | 119 | void luaX_syntaxerror (LexState *ls, const char *msg) { |
117 | luaX_lexerror(ls, msg, ls->t.token); | 120 | lexerror(ls, msg, ls->t.token); |
118 | } | 121 | } |
119 | 122 | ||
120 | 123 | ||
@@ -193,7 +196,7 @@ static void trydecpoint (LexState *ls, SemInfo *seminfo) { | |||
193 | if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) { | 196 | if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) { |
194 | /* format error with correct decimal point: no more options */ | 197 | /* format error with correct decimal point: no more options */ |
195 | buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */ | 198 | buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */ |
196 | luaX_lexerror(ls, "malformed number", TK_NUMBER); | 199 | lexerror(ls, "malformed number", TK_NUMBER); |
197 | } | 200 | } |
198 | } | 201 | } |
199 | 202 | ||
@@ -235,8 +238,8 @@ static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) { | |||
235 | for (;;) { | 238 | for (;;) { |
236 | switch (ls->current) { | 239 | switch (ls->current) { |
237 | case EOZ: | 240 | case EOZ: |
238 | luaX_lexerror(ls, (seminfo) ? "unfinished long string" : | 241 | lexerror(ls, (seminfo) ? "unfinished long string" : |
239 | "unfinished long comment", TK_EOS); | 242 | "unfinished long comment", TK_EOS); |
240 | break; /* to avoid warnings */ | 243 | break; /* to avoid warnings */ |
241 | case ']': { | 244 | case ']': { |
242 | if (skip_sep(ls) == sep) { | 245 | if (skip_sep(ls) == sep) { |
@@ -269,11 +272,11 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) { | |||
269 | while (ls->current != del) { | 272 | while (ls->current != del) { |
270 | switch (ls->current) { | 273 | switch (ls->current) { |
271 | case EOZ: | 274 | case EOZ: |
272 | luaX_lexerror(ls, "unfinished string", TK_EOS); | 275 | lexerror(ls, "unfinished string", TK_EOS); |
273 | continue; /* to avoid warnings */ | 276 | continue; /* to avoid warnings */ |
274 | case '\n': | 277 | case '\n': |
275 | case '\r': | 278 | case '\r': |
276 | luaX_lexerror(ls, "unfinished string", TK_STRING); | 279 | lexerror(ls, "unfinished string", TK_STRING); |
277 | continue; /* to avoid warnings */ | 280 | continue; /* to avoid warnings */ |
278 | case '\\': { | 281 | case '\\': { |
279 | int c; | 282 | int c; |
@@ -300,7 +303,7 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) { | |||
300 | next(ls); | 303 | next(ls); |
301 | } while (++i<3 && isdigit(ls->current)); | 304 | } while (++i<3 && isdigit(ls->current)); |
302 | if (c > UCHAR_MAX) | 305 | if (c > UCHAR_MAX) |
303 | luaX_lexerror(ls, "escape sequence too large", TK_STRING); | 306 | lexerror(ls, "escape sequence too large", TK_STRING); |
304 | save(ls, c); | 307 | save(ls, c); |
305 | } | 308 | } |
306 | continue; | 309 | continue; |
@@ -355,7 +358,7 @@ static int llex (LexState *ls, SemInfo *seminfo) { | |||
355 | return TK_STRING; | 358 | return TK_STRING; |
356 | } | 359 | } |
357 | else if (sep == -1) return '['; | 360 | else if (sep == -1) return '['; |
358 | else luaX_lexerror(ls, "invalid long string delimiter", TK_STRING); | 361 | else lexerror(ls, "invalid long string delimiter", TK_STRING); |
359 | } | 362 | } |
360 | case '=': { | 363 | case '=': { |
361 | next(ls); | 364 | next(ls); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llex.h,v 1.59 2007/02/07 17:49:18 roberto Exp roberto $ | 2 | ** $Id: llex.h,v 1.60 2007/05/11 17:28:56 roberto Exp roberto $ |
3 | ** Lexical Analyzer | 3 | ** Lexical Analyzer |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -69,7 +69,6 @@ LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, | |||
69 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); | 69 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); |
70 | LUAI_FUNC void luaX_next (LexState *ls); | 70 | LUAI_FUNC void luaX_next (LexState *ls); |
71 | LUAI_FUNC int luaX_lookahead (LexState *ls); | 71 | LUAI_FUNC int luaX_lookahead (LexState *ls); |
72 | LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token); | ||
73 | LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s); | 72 | LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s); |
74 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); | 73 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); |
75 | 74 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 2.54 2007/07/31 19:39:52 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 2.55 2007/10/18 11:01:52 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 | */ |
@@ -75,7 +75,7 @@ static void errorlimit (FuncState *fs, int limit, const char *what) { | |||
75 | luaO_pushfstring(fs->L, "function at line %d", fs->f->linedefined); | 75 | luaO_pushfstring(fs->L, "function at line %d", fs->f->linedefined); |
76 | msg = luaO_pushfstring(fs->L, "too many %s (limit is %d) in %s", | 76 | msg = luaO_pushfstring(fs->L, "too many %s (limit is %d) in %s", |
77 | what, limit, where); | 77 | what, limit, where); |
78 | luaX_lexerror(fs->ls, msg, fs->ls->t.token); | 78 | luaX_syntaxerror(fs->ls, msg); |
79 | } | 79 | } |
80 | 80 | ||
81 | 81 | ||