aboutsummaryrefslogtreecommitdiffhomepage
path: root/main.c
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-07-13 20:07:10 +0900
committernsfisis <nsfisis@gmail.com>2025-08-15 10:04:20 +0900
commit88d01cd637ae2b7d6c7c2e721eb98a72160c44e2 (patch)
tree0c46c8b032715d6f9132be8e2667882e4ef678b9 /main.c
parent286a9b6254e88ac5ee6537ef3a11db8060ce06c5 (diff)
downloadducc-88d01cd637ae2b7d6c7c2e721eb98a72160c44e2.tar.gz
ducc-88d01cd637ae2b7d6c7c2e721eb98a72160c44e2.tar.zst
ducc-88d01cd637ae2b7d6c7c2e721eb98a72160c44e2.zip
feat: implement some of escape sequences
Diffstat (limited to 'main.c')
-rw-r--r--main.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/main.c b/main.c
index ac5484d..b996615 100644
--- a/main.c
+++ b/main.c
@@ -319,13 +319,8 @@ void pp_tokenize_all(Preprocessor* pp) {
}
} else if (c == '\'') {
start = pp->pos - 1;
- ch = pp->src[pp->pos];
- if (ch == '\\') {
+ if (pp->src[pp->pos] == '\\') {
++pp->pos;
- ch = pp->src[pp->pos];
- if (ch == 'n') {
- ch = '\n';
- }
}
pp->pos += 2;
tok->kind = PpTokenKind_character_constant;
@@ -576,8 +571,20 @@ void tokenize_all(Lexer* l) {
ch = pp_tok->raw.data[1];
if (ch == '\\') {
ch = pp_tok->raw.data[2];
- if (ch == 'n') {
+ if (ch == 'a') {
+ ch = '\a';
+ } else if (ch == 'b') {
+ ch = '\b';
+ } else if (ch == 'f') {
+ ch = '\f';
+ } else if (ch == 'n') {
ch = '\n';
+ } else if (ch == 'r') {
+ ch = '\r';
+ } else if (ch == 't') {
+ ch = '\t';
+ } else if (ch == 'v') {
+ ch = '\v';
}
}
buf = calloc(4, sizeof(char));