aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-03-20 11:18:18 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-03-20 11:18:18 -0300
commit21455162b5da29e5850bee1e16b85e226ae391b2 (patch)
tree87783285c54da06e9e003b58c7802c5ab74b41d1
parent99cc4b20f2c9e33600948fb0489c6d1d1c160518 (diff)
downloadlua-21455162b5da29e5850bee1e16b85e226ae391b2.tar.gz
lua-21455162b5da29e5850bee1e16b85e226ae391b2.tar.bz2
lua-21455162b5da29e5850bee1e16b85e226ae391b2.zip
details (and new escape sequences: \a, \b, ...)
-rw-r--r--llex.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/llex.c b/llex.c
index e8aec256..d1301463 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.c,v 1.16 1998/03/06 16:54:42 roberto Exp roberto $ 2** $Id: llex.c,v 1.17 1998/03/09 17:22:49 roberto Exp roberto $
3** Lexical Analizer 3** Lexical Analizer
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -323,11 +323,15 @@ int luaY_lex (YYSTYPE *l)
323 case '\\': 323 case '\\':
324 next(LS); /* do not save the '\' */ 324 next(LS); /* do not save the '\' */
325 switch (LS->current) { 325 switch (LS->current) {
326 case 'a': save('\a'); next(LS); break;
327 case 'b': save('\b'); next(LS); break;
328 case 'f': save('\f'); next(LS); break;
326 case 'n': save('\n'); next(LS); break; 329 case 'n': save('\n'); next(LS); break;
327 case 't': save('\t'); next(LS); break;
328 case 'r': save('\r'); next(LS); break; 330 case 'r': save('\r'); next(LS); break;
331 case 't': save('\t'); next(LS); break;
332 case 'v': save('\v'); next(LS); break;
329 case '\n': save('\n'); inclinenumber(LS); break; 333 case '\n': save('\n'); inclinenumber(LS); break;
330 case '\\': case '"': case '\'': { 334 case '\\': case '"': case '\'': case '?': {
331 save(LS->current); 335 save(LS->current);
332 next(LS); 336 next(LS);
333 break; 337 break;
@@ -338,9 +342,10 @@ int luaY_lex (YYSTYPE *l)
338 int i = 0; 342 int i = 0;
339 do { 343 do {
340 c = 10*c + (LS->current-'0'); 344 c = 10*c + (LS->current-'0');
341 i++;
342 next(LS); 345 next(LS);
343 } while (i<3 && isdigit(LS->current)); 346 } while (++i<3 && isdigit(LS->current));
347 if (c >= 256)
348 luaY_error("escape sequence too large");
344 save(c); 349 save(c);
345 } 350 }
346 else { 351 else {