diff options
Diffstat (limited to 'src/tokenizer.c')
-rw-r--r-- | src/tokenizer.c | 6 |
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; |