diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-06-12 01:15:26 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-06-12 01:15:26 +0200 |
commit | 3d058de9cc8e58081d6c0eda410183388e26b85c (patch) | |
tree | 4d455bc3e0852cc3bf6c276af94692e6dc3650fb /src | |
parent | c22e01c9e91864bad0210bfc90ba4952e91dba2a (diff) |
Strip U+0027 APOSTROPHE from integer literals
Diffstat (limited to 'src')
-rw-r--r-- | src/codegen.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/codegen.c b/src/codegen.c index 410f68e..7f5d010 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -106,7 +106,17 @@ codegenexpr(LLVMBuilderRef builder, struct ast ast, struct lexemes toks, case ASTNUMLIT: { /* TODO: Arbitrary precision? */ struct strview sv = toks.strs[ast.lexemes[i]]; - *v = LLVMConstIntOfStringAndSize(LLVMInt64Type(), sv.p, sv.len, 10); + + /* TODO: Temporary one-time-use allocator? */ + size_t len = 0; + char *p = bufalloc(NULL, sv.len, 1); + for (size_t i = 0; i < sv.len; i++) { + if (sv.p[i] != '\'') + p[len++] = sv.p[i]; + } + + *v = LLVMConstIntOfStringAndSize(LLVMInt64Type(), p, len, 10); + free(p); return i + 1; } } |