From e781a063f83b2c0315a4fc5900be717b419f3f9b Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Fri, 28 Feb 2014 22:35:38 +0900 Subject: [PATCH] scan.l cleanup --- src/scan.l | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/scan.l b/src/scan.l index cd90d65d..b7d4b456 100644 --- a/src/scan.l +++ b/src/scan.l @@ -23,7 +23,9 @@ #define YY_EXIT_FAILURE ( (void)yyscanner, 2 ) %} -%option noyyalloc noyyrealloc noyyfree +%option noyyalloc +%option noyyrealloc +%option noyyfree %option reentrant %option noinput %option nounput @@ -114,15 +116,17 @@ infnan "+inf.0"|"-inf.0"|"+nan.0"|"-nan.0" return tSYMBOL; } -"\"" BEGIN(STRING); -{ - [^\\"]* yymore(); - "\"" { - yytext[yyleng-1] = '\0'; - yylvalp->cstr = pic_strdup(yyextra->pic, yytext); - BEGIN(INITIAL); - return tSTRING; - } +"\"" { + BEGIN(STRING); +} +[^\\"]* { + yymore(); +} +"\"" { + yytext[yyleng-1] = '\0'; + yylvalp->cstr = pic_strdup(yyextra->pic, yytext); + BEGIN(INITIAL); + return tSTRING; } #\\ { @@ -135,7 +139,7 @@ infnan "+inf.0"|"-inf.0"|"+nan.0"|"-nan.0" newline { yylvalp->c = '\n'; BEGIN(INITIAL); return tCHAR; } null { yylvalp->c = '\0'; BEGIN(INITIAL); return tCHAR; } return { yylvalp->c = '\r'; BEGIN(INITIAL); return tCHAR; } -space { yylvalp->c = ' '; BEGIN(INITIAL); return tCHAR; } +space { yylvalp->c = ' '; BEGIN(INITIAL); return tCHAR; } tab { yylvalp->c = '\t'; BEGIN(INITIAL); return tCHAR; } . { yylvalp->c = yytext[0]; BEGIN(INITIAL); return tCHAR; } @@ -145,7 +149,9 @@ infnan "+inf.0"|"-inf.0"|"+nan.0"|"-nan.0" yylvalp->blob.capa = 10; yylvalp->blob.dat = calloc(10, 1); } -[ \r\n\t] +[ \r\n\t] { + /* skip whitespace */ +} {uinteger} { int i = atoi(yytext); if (0 > i || i > 255)