summaryrefslogtreecommitdiff
path: root/src/llex.c
diff options
context:
space:
mode:
authorLua Team <team@lua.org>2005-05-20 12:00:00 +0000
committerrepogen <>2005-05-20 12:00:00 +0000
commitbf6b5550cdfbc0c4a3a4577776ad76628d80718e (patch)
treed714ef8ac5581536c0f8bb2c8e90e2b8207799b1 /src/llex.c
parente6ddfd3b09c0a3727afc773029c323a3defe50fa (diff)
downloadlua-github-5.1-work6.tar.gz
Lua 5.1-work65.1-work6
Diffstat (limited to 'src/llex.c')
-rw-r--r--src/llex.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/llex.c b/src/llex.c
index 3940b955..b663b432 100644
--- a/src/llex.c
+++ b/src/llex.c
@@ -1,5 +1,5 @@
/*
-** $Id: llex.c,v 2.9 2004/12/03 20:54:12 roberto Exp $
+** $Id: llex.c,v 2.12 2005/05/17 19:49:15 roberto Exp $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
@@ -102,7 +102,7 @@ void luaX_lexerror (LexState *ls, const char *msg, int token) {
luaO_chunkid(buff, getstr(ls->source), MAXSRC);
msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg);
if (token)
- luaO_pushfstring(ls->L, "%s near `%s'", msg, txtToken(ls, token));
+ luaO_pushfstring(ls->L, "%s near " LUA_QS, msg, txtToken(ls, token));
luaD_throw(ls->L, LUA_ERRSYNTAX);
}
@@ -202,6 +202,7 @@ static int skip_sep (LexState *ls) {
static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) {
int cont = 0;
+ (void)(cont); /* avoid warnings when `cont' is not used */
save_and_next(ls); /* skip 2nd `[' */
if (currIsNewline(ls)) /* string starts with a newline? */
inclinenumber(ls); /* skip it */
@@ -211,27 +212,41 @@ static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) {
luaX_lexerror(ls, (seminfo) ? "unfinished long string" :
"unfinished long comment", TK_EOS);
break; /* to avoid warnings */
- case '[':
+#if defined(LUA_COMPAT_LSTR)
+ case '[': {
if (skip_sep(ls) == sep) {
save_and_next(ls); /* skip 2nd `[' */
cont++;
+#if LUA_COMPAT_LSTR == 1
+ if (sep == 0)
+ luaX_lexerror(ls, "nesting of [[...]] is deprecated", '[');
+#endif
}
- continue;
- case ']':
+ break;
+ }
+#endif
+ case ']': {
if (skip_sep(ls) == sep) {
save_and_next(ls); /* skip 2nd `]' */
- if (cont-- == 0) goto endloop;
+#if defined(LUA_COMPAT_LSTR) && LUA_COMPAT_LSTR == 2
+ cont--;
+ if (sep == 0 && cont >= 0) break;
+#endif
+ goto endloop;
}
- continue;
+ break;
+ }
case '\n':
- case '\r':
+ case '\r': {
save(ls, '\n');
inclinenumber(ls);
if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */
- continue;
- default:
+ break;
+ }
+ default: {
if (seminfo) save_and_next(ls);
else next(ls);
+ }
}
} endloop:
if (seminfo)