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/error.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/stage1/error.cpp') diff --git a/src/stage1/error.cpp b/src/stage1/error.cpp index d8bb4ac8a2..e77632e8f2 100644 --- a/src/stage1/error.cpp +++ b/src/stage1/error.cpp @@ -88,6 +88,8 @@ const char *err_str(Error err) { case ErrorZigIsTheCCompiler: return "Zig was not provided with libc installation information, and so it does not know where the libc paths are on the system. Zig attempted to use the system C compiler to find out where the libc paths are, but discovered that Zig is being used as the system C compiler."; case ErrorFileBusy: return "file is busy"; case ErrorLocked: return "file is locked by another process"; + case ErrorInvalidCharacter: return "invalid character"; + case ErrorUnicodePointTooLarge: return "unicode codepoint too large"; } return "(invalid error)"; } -- cgit v1.2.3