summaryrefslogtreecommitdiff
path: root/llex.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-09-22 11:02:00 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-09-22 11:02:00 -0300
commitb2820f39a23bad2bc568623dbb2d56cd5697efa4 (patch)
tree391d1493ab523cee3f29323c493e228ced8ef2a3 /llex.c
parent8b5bb6056ba944bfbb4489492a5698a2285fa81a (diff)
downloadlua-b2820f39a23bad2bc568623dbb2d56cd5697efa4.tar.gz
lua-b2820f39a23bad2bc568623dbb2d56cd5697efa4.tar.bz2
lua-b2820f39a23bad2bc568623dbb2d56cd5697efa4.zip
long string delimiter changed from `[*[' to `[=['
Diffstat (limited to 'llex.c')
-rw-r--r--llex.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/llex.c b/llex.c
index 61490f9b..71b52510 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.c,v 2.2 2004/03/12 19:53:56 roberto Exp roberto $ 2** $Id: llex.c,v 2.3 2004/04/30 20:13:38 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*/
@@ -181,12 +181,12 @@ static void read_numeral (LexState *ls, SemInfo *seminfo) {
181} 181}
182 182
183 183
184static int skip_ast (LexState *ls) { 184static int skip_sep (LexState *ls) {
185 int count = 0; 185 int count = 0;
186 int s = ls->current; 186 int s = ls->current;
187 lua_assert(s == '[' || s == ']'); 187 lua_assert(s == '[' || s == ']');
188 save_and_next(ls); 188 save_and_next(ls);
189 while (ls->current == '*') { 189 while (ls->current == '=') {
190 save_and_next(ls); 190 save_and_next(ls);
191 count++; 191 count++;
192 } 192 }
@@ -194,7 +194,7 @@ static int skip_ast (LexState *ls) {
194} 194}
195 195
196 196
197static void read_long_string (LexState *ls, SemInfo *seminfo, int ast) { 197static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) {
198 int cont = 0; 198 int cont = 0;
199 save_and_next(ls); /* skip 2nd `[' */ 199 save_and_next(ls); /* skip 2nd `[' */
200 if (currIsNewline(ls)) /* string starts with a newline? */ 200 if (currIsNewline(ls)) /* string starts with a newline? */
@@ -206,13 +206,13 @@ static void read_long_string (LexState *ls, SemInfo *seminfo, int ast) {
206 "unfinished long comment", TK_EOS); 206 "unfinished long comment", TK_EOS);
207 break; /* to avoid warnings */ 207 break; /* to avoid warnings */
208 case '[': 208 case '[':
209 if (skip_ast(ls) == ast) { 209 if (skip_sep(ls) == sep) {
210 save_and_next(ls); /* skip 2nd `[' */ 210 save_and_next(ls); /* skip 2nd `[' */
211 cont++; 211 cont++;
212 } 212 }
213 continue; 213 continue;
214 case ']': 214 case ']':
215 if (skip_ast(ls) == ast) { 215 if (skip_sep(ls) == sep) {
216 save_and_next(ls); /* skip 2nd `]' */ 216 save_and_next(ls); /* skip 2nd `]' */
217 if (cont-- == 0) goto endloop; 217 if (cont-- == 0) goto endloop;
218 } 218 }
@@ -229,8 +229,8 @@ static void read_long_string (LexState *ls, SemInfo *seminfo, int ast) {
229 } 229 }
230 } endloop: 230 } endloop:
231 if (seminfo) 231 if (seminfo)
232 seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + ast), 232 seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep),
233 luaZ_bufflen(ls->buff) - 2*(2 + ast)); 233 luaZ_bufflen(ls->buff) - 2*(2 + sep));
234} 234}
235 235
236 236
@@ -305,10 +305,10 @@ int luaX_lex (LexState *ls, SemInfo *seminfo) {
305 /* else is a comment */ 305 /* else is a comment */
306 next(ls); 306 next(ls);
307 if (ls->current == '[') { 307 if (ls->current == '[') {
308 int ast = skip_ast(ls); 308 int sep = skip_sep(ls);
309 luaZ_resetbuffer(ls->buff); /* `skip_ast' may dirty the buffer */ 309 luaZ_resetbuffer(ls->buff); /* `skip_sep' may dirty the buffer */
310 if (ast >= 0) { 310 if (sep >= 0) {
311 read_long_string(ls, NULL, ast); /* long comment */ 311 read_long_string(ls, NULL, sep); /* long comment */
312 luaZ_resetbuffer(ls->buff); 312 luaZ_resetbuffer(ls->buff);
313 continue; 313 continue;
314 } 314 }
@@ -319,12 +319,12 @@ int luaX_lex (LexState *ls, SemInfo *seminfo) {
319 continue; 319 continue;
320 } 320 }
321 case '[': { 321 case '[': {
322 int ast = skip_ast(ls); 322 int sep = skip_sep(ls);
323 if (ast >= 0) { 323 if (sep >= 0) {
324 read_long_string(ls, seminfo, ast); 324 read_long_string(ls, seminfo, sep);
325 return TK_STRING; 325 return TK_STRING;
326 } 326 }
327 else if (ast == -1) return '['; 327 else if (sep == -1) return '[';
328 else luaX_lexerror(ls, "invalid long string delimiter", TK_STRING); 328 else luaX_lexerror(ls, "invalid long string delimiter", TK_STRING);
329 } 329 }
330 case '=': { 330 case '=': {