Implement character escape sequences
This commit is contained in:
@@ -112,13 +112,50 @@ return {
|
||||
[0-9]+\.[0-9] {
|
||||
return yy::parser::make_FLOAT(strtof(yytext, NULL), this->location);
|
||||
}
|
||||
'[^']' {
|
||||
return yy::parser::make_CHARACTER(
|
||||
std::string(yytext, 1, strlen(yytext) - 2), this->location);
|
||||
'[[:print:]]' {
|
||||
if (yytext[1] == '\\')
|
||||
{
|
||||
REJECT;
|
||||
}
|
||||
else
|
||||
{
|
||||
return yy::parser::make_CHARACTER(std::string(yytext, 1, 1), this->location);
|
||||
}
|
||||
}
|
||||
'\\[0nabtfrv\\'"?]' {
|
||||
switch (yytext[2])
|
||||
{
|
||||
case 'n':
|
||||
return yy::parser::make_CHARACTER(std::string("\n"), this->location);
|
||||
case 'a':
|
||||
return yy::parser::make_CHARACTER(std::string("\a"), this->location);
|
||||
case 'b':
|
||||
return yy::parser::make_CHARACTER(std::string("\b"), this->location);
|
||||
case 't':
|
||||
return yy::parser::make_CHARACTER(std::string("\t"), this->location);
|
||||
case 'f':
|
||||
return yy::parser::make_CHARACTER(std::string("\f"), this->location);
|
||||
case 'r':
|
||||
return yy::parser::make_CHARACTER(std::string("\r"), this->location);
|
||||
case 'v':
|
||||
return yy::parser::make_CHARACTER(std::string("\v"), this->location);
|
||||
case '\\':
|
||||
return yy::parser::make_CHARACTER(std::string("\\"), this->location);
|
||||
case '\'':
|
||||
return yy::parser::make_CHARACTER(std::string("'"), this->location);
|
||||
case '"':
|
||||
return yy::parser::make_CHARACTER(std::string("\""), this->location);
|
||||
case '?':
|
||||
return yy::parser::make_CHARACTER(std::string("\?"), this->location);
|
||||
case '0':
|
||||
return yy::parser::make_CHARACTER(std::string("\0", 1), this->location);
|
||||
default:
|
||||
REJECT;
|
||||
}
|
||||
}
|
||||
\"[^\"]*\" {
|
||||
return yy::parser::make_STRING(
|
||||
std::string(yytext, 1, strlen(yytext) - 2), this->location);
|
||||
std::string(yytext, 1, strlen(yytext) - 2), this->location);
|
||||
}
|
||||
\( {
|
||||
return yy::parser::make_LEFT_PAREN(this->location);
|
||||
|
||||
Reference in New Issue
Block a user