feat 重构stream流API并适配lex_parse和lexer

This commit is contained in:
zzy
2025-12-08 23:04:11 +08:00
parent 1ab07a5815
commit 36bff64a91
17 changed files with 402 additions and 244 deletions

View File

@@ -63,9 +63,9 @@ int main(int argc, char *argv[]) {
}
smcc_lexer_t lexer;
core_mem_stream_t mem_stream = {0};
core_stream_t *stream =
core_mem_stream_init(&mem_stream, buffer, fsize, false);
core_mem_probe_stream_t mem_stream = {0};
core_probe_stream_t *stream =
core_mem_probe_stream_init(&mem_stream, buffer, fsize, false);
Assert(stream != null);
cstring_clear(&stream->name);
cstring_push_cstr(&stream->name, file_name, strlen(file_name));
@@ -78,7 +78,7 @@ int main(int argc, char *argv[]) {
break;
}
LOG_DEBUG("token `%s` at %s:%u:%u", get_tok_name(tok.type),
tok.loc.name, tok.loc.line, tok.loc.col);
cstring_as_cstr(&tok.loc.name), tok.loc.line, tok.loc.col);
Assert(tok.loc.offset <= fsize);
// LOG_DEBUG("%s", tok.val.str);
// printf("line: %d, column: %d, type: %3d, typename: %s\n",