aboutsummaryrefslogtreecommitdiff
path: root/src/tokenizer.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-07-17 19:23:16 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-25 14:36:46 +0200
commit84e65c63e7482590d535e86f7660a00ae8a0cecb (patch)
treec79de87b7136e96b977003db85d43e5e676bbfc1 /src/tokenizer.c
parent85c654a102701958d3748e82ecac9c1bc4dbbcba (diff)
Start on amal program
Fix mutex issue in lhs expr which can cause a deadlock when a file has an error and throws and doesn't close the mutex and another thread waits for that mutex. The mutex can instead be removed and ignore race conditions which are uncommon. This should improve memory usage and performance.
Diffstat (limited to 'src/tokenizer.c')
-rw-r--r--src/tokenizer.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/tokenizer.c b/src/tokenizer.c
index bd57af7..bce386d 100644
--- a/src/tokenizer.c
+++ b/src/tokenizer.c
@@ -28,6 +28,11 @@ static int tokenizer_get_end_of_multiline_comment(Tokenizer *self, int index);
int tokenizer_init(Tokenizer *self, ScopedAllocator *allocator, BufferView code, BufferView code_name, const amal_compiler_options *compiler_options) {
assert(code.size <= INT_MAX);
assert(compiler_options);
+ /* Skip UTF-8 BOM */
+ if(code.size >= 3 && (u8)code.data[0] == 0xEF && (u8)code.data[1] == 0xBB && (u8)code.data[2] == 0xBF) {
+ code.data += 3;
+ code.size -= 3;
+ }
self->code = code;
self->index = 0;
self->prev_index = 0;
@@ -86,6 +91,7 @@ static CHECK_RESULT int find_end_of_string(BufferView buf, int index) {
}
/* TODO: Optimize string to integer and string to float */
+
#define I64_OVERFLOW_ERROR -1
static CHECK_RESULT int string_to_integer_unchecked(BufferView str, i64 *result) {
int i;