support all C character escape sequences

This commit is contained in:
Josh Holtrop 2018-04-11 21:29:18 -04:00
parent 4ffc67919e
commit 81614c41ab

View File

@ -110,11 +110,13 @@ sizeof return TOK_SIZEOF;
L?'[^\\]' return TOK_CHAR_CONST;
L?'\\.' return TOK_CHAR_CONST;
L?'\\n' (void)'\n'; return TOK_CHAR_CONST;
L?'\\t' (void)'\t'; return TOK_CHAR_CONST;
L?'\\r' (void)'\r'; return TOK_CHAR_CONST;
L?'\\a' (void)'\a'; return TOK_CHAR_CONST;
L?'\\b' (void)'\b'; return TOK_CHAR_CONST;
L?'\\f' (void)'\f'; return TOK_CHAR_CONST;
L?'\\n' (void)'\n'; return TOK_CHAR_CONST;
L?'\\r' (void)'\r'; return TOK_CHAR_CONST;
L?'\\t' (void)'\t'; return TOK_CHAR_CONST;
L?'\\v' (void)'\v'; return TOK_CHAR_CONST;
[0-9]+([uU][lL]?[lL]?)? return TOK_INT_CONST;
0[xX][0-9a-fA-F]+([uU][lL]?[lL]?)? return TOK_INT_CONST;
([0-9]+\.[0-9]*|\.[0-9]+)([eE][-+]?[0-9]+)?[fFlL]? return TOK_FLOAT_CONST;
@ -139,11 +141,13 @@ L?'\\f' (void)'\f'; return TOK_CHAR_CONST;
char v[2] = {(char)val, '\0'};
String_concat(build_string, v);
}
\\n String_concat(build_string, "\n");
\\t String_concat(build_string, "\t");
\\r String_concat(build_string, "\r");
\\a String_concat(build_string, "\a");
\\b String_concat(build_string, "\b");
\\f String_concat(build_string, "\f");
\\n String_concat(build_string, "\n");
\\r String_concat(build_string, "\r");
\\t String_concat(build_string, "\t");
\\v String_concat(build_string, "\v");
\\. String_concat(build_string, &yytext[1]);
[^\\\"]+ String_concat(build_string, yytext);
}