From 2a990d69669c2a2cd16134e8ebbd2750060f8071 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 27 May 2021 16:32:35 -0700 Subject: stage1: rework tokenizer to match stage2 * Extracts AstGen logic from ir.cpp into astgen.cpp. Reduces the largest file of stage1 from 33,551 lines to 25,510. * tokenizer: rework it completely to match the stage2 tokenizer logic. They can now be maintained together; when one is changed, the other can be changed in the same way. - Each token now takes up 13 bytes instead of 64 bytes. The tokenizer does not parse char literals, string literals, integer literals, etc into meaningful data. Instead, that happens during parsing or astgen. - no longer store line offsets. Error messages scan source files to find the line/column as needed (same as stage2). - main loop: instead of checking the loop, handle a null byte explicitly in the switch statements. This is a nice improvement that we may want to backport to stage2. - delete some dead tokens, artifacts of past syntax that no longer exists. * Parser: fix a TODO by parsing builtin functions as tokens rather than `@` as a separate token. This is how stage2 does it. * Remove some debugging infrastructure. These will need to be redone, if at all, as the code migrates to match stage2. - remove the ast_render code. - remove the IR debugging stuff - remove teh token printing code --- src/stage1/bigfloat.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/stage1/bigfloat.cpp') diff --git a/src/stage1/bigfloat.cpp b/src/stage1/bigfloat.cpp index 840cdccc8b..56bf2637e3 100644 --- a/src/stage1/bigfloat.cpp +++ b/src/stage1/bigfloat.cpp @@ -69,7 +69,7 @@ void bigfloat_init_bigint(BigFloat *dest, const BigInt *op) { } } -Error bigfloat_init_buf(BigFloat *dest, const uint8_t *buf_ptr, size_t buf_len) { +Error bigfloat_init_buf(BigFloat *dest, const uint8_t *buf_ptr) { char *str_begin = (char *)buf_ptr; char *str_end; @@ -79,7 +79,6 @@ Error bigfloat_init_buf(BigFloat *dest, const uint8_t *buf_ptr, size_t buf_len) return ErrorOverflow; } - assert(str_end <= ((char*)buf_ptr) + buf_len); return ErrorNone; } -- cgit v1.2.3