Beginning of better API

This commit is contained in:
2024-09-02 12:34:48 +02:00
parent c8cd15456d
commit d9dfcc6354
3 changed files with 124 additions and 1 deletions

View File

@@ -500,6 +500,25 @@ scan_next_token :: (lexer : *Lexer) -> *Token {
}
lex :: (result : *Compile_Result) {
if result.had_error {
return;
}
for file : result.files {
lexer : Lexer;
init_lexer_from_string(*lexer, file.file.source);
token : *Token = scan_next_token(*lexer);
while token && token.kind != .TOKEN_EOF {
token = scan_next_token(*lexer);
}
// @Incomplete(nb): Temporary until we figure out a good way of passing this stuff around
copy_messages(lexer.result.messages, *result.messages);
}
}
lex :: (lexer : *Lexer, allocator : Allocator = context.allocator) -> Lexing_Result {
lexer.result.tokens.allocator = allocator;
token : *Token = scan_next_token(lexer);