feat(lexer): comment handling + healthy changes

This commit is contained in:
Matteo Flebus 2026-01-21 18:43:17 +01:00
parent 03e5305b56
commit 306b13308b
4 changed files with 28 additions and 14 deletions

View file

@ -162,11 +162,11 @@ void free_token(struct token **tok)
*tok = NULL;
}
char *stream_init(struct lexer_context *ctx)
void stream_init(struct lexer_context *ctx)
{
char *stream;
if (ctx->previous_token == NULL) // at the begining
if (ctx->remaining_chars == 0) // at the begining
{
ctx->remaining_chars = stream_read(&stream);
}
@ -177,7 +177,12 @@ char *stream_init(struct lexer_context *ctx)
char *trimed_stream = trim_blank_left(stream);
ctx->remaining_chars -= trimed_stream - stream;
stream = trimed_stream;
return stream;
ctx->end_previous_token = trimed_stream;
}
void get_next_stream(struct lexer_context *ctx)
{
ctx->remaining_chars = 0;
stream_init(ctx);
}