aboutsummaryrefslogtreecommitdiffstats
path: root/c_compiler/src/c_lexer.flex
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-03-27 02:28:29 +0100
committerYann Herklotz <ymherklotz@gmail.com>2017-03-27 02:28:29 +0100
commita7c5f260391da944bd0779e8ac6efb2f0f6b5a6b (patch)
treec64a6d0096a1dc4ee3a0a3fff7649ae1df52dff8 /c_compiler/src/c_lexer.flex
parente9657092063e786a52fefcfa4c528bac07472908 (diff)
downloadCompiler-a7c5f260391da944bd0779e8ac6efb2f0f6b5a6b.tar.gz
Compiler-a7c5f260391da944bd0779e8ac6efb2f0f6b5a6b.zip
Working even more
Diffstat (limited to 'c_compiler/src/c_lexer.flex')
-rw-r--r--c_compiler/src/c_lexer.flex13
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; }