scan.l cleanup

This commit is contained in:
Yuichi Nishiwaki 2014-02-28 22:35:38 +09:00
parent 22dd97fd44
commit e781a063f8
1 changed files with 18 additions and 12 deletions

View File

@ -23,7 +23,9 @@
#define YY_EXIT_FAILURE ( (void)yyscanner, 2 ) #define YY_EXIT_FAILURE ( (void)yyscanner, 2 )
%} %}
%option noyyalloc noyyrealloc noyyfree %option noyyalloc
%option noyyrealloc
%option noyyfree
%option reentrant %option reentrant
%option noinput %option noinput
%option nounput %option nounput
@ -114,16 +116,18 @@ infnan "+inf.0"|"-inf.0"|"+nan.0"|"-nan.0"
return tSYMBOL; return tSYMBOL;
} }
"\"" BEGIN(STRING);
<STRING>{
[^\\"]* yymore();
"\"" { "\"" {
BEGIN(STRING);
}
<STRING>[^\\"]* {
yymore();
}
<STRING>"\"" {
yytext[yyleng-1] = '\0'; yytext[yyleng-1] = '\0';
yylvalp->cstr = pic_strdup(yyextra->pic, yytext); yylvalp->cstr = pic_strdup(yyextra->pic, yytext);
BEGIN(INITIAL); BEGIN(INITIAL);
return tSTRING; return tSTRING;
} }
}
#\\ { #\\ {
BEGIN(CHAR); BEGIN(CHAR);
@ -145,7 +149,9 @@ infnan "+inf.0"|"-inf.0"|"+nan.0"|"-nan.0"
yylvalp->blob.capa = 10; yylvalp->blob.capa = 10;
yylvalp->blob.dat = calloc(10, 1); yylvalp->blob.dat = calloc(10, 1);
} }
<BYTEVECTOR>[ \r\n\t] <BYTEVECTOR>[ \r\n\t] {
/* skip whitespace */
}
<BYTEVECTOR>{uinteger} { <BYTEVECTOR>{uinteger} {
int i = atoi(yytext); int i = atoi(yytext);
if (0 > i || i > 255) if (0 > i || i > 255)