diff options
Diffstat (limited to 'c_compiler/src/c_lexer.flex')
-rw-r--r-- | c_compiler/src/c_lexer.flex | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/c_compiler/src/c_lexer.flex b/c_compiler/src/c_lexer.flex index 8dcef35..8365a5b 100644 --- a/c_compiler/src/c_lexer.flex +++ b/c_compiler/src/c_lexer.flex @@ -16,9 +16,9 @@ DECIMALCONSTANT ([1-9][0-9]*) OCTALCONSTANT ([0][0-7]*) HEXCONSTANT ([0][xX][0-9A-Fa-f]+) -CHARCONSTANT ('(([\\]['])|([^']))+') +CHARCONSTANT (['](([\\]['])|([^']))*[']) -STRINGLITERAL ["](([\\]["])|([^"]))*["] +STRINGLITERAL (["](([\\]["])|([^"]))*["]) WHITESPACE [ \t\r\n]+ @@ -54,6 +54,15 @@ ALL . (default) { return T_DEFAULT; } (switch) { return T_SWITCH; } +{STRINGLITERAL} { std::string tmp(yytext); yylval.string = new std::string(tmp.substr(1, yyleng-2)); + return T_STRINGLITERAL; } +L{STRINGLITERAL} { std::string tmp(yytext); yylval.string = new std::string(tmp.substr(2, yyleng-3)); + return T_STRINGLITERAL;} + +{CHARCONSTANT} { yylval.number = yytext[1]; return T_INT_CONST; } +L{CHARCONSTANT} { yylval.number = yytext[2]; return T_INT_CONST; } + + [.][.][.] { return T_ELLIPSIS; } [;] { return T_SC; } [,] { return T_CMA; } |