feat(lexer): comments done + operator WIP

This commit is contained in:
matteo 2026-01-23 15:56:21 +01:00
parent 82f35cfa08
commit 3cdba0ad9c
3 changed files with 60 additions and 9 deletions

View file

@ -133,13 +133,14 @@ struct token *peek_token(struct lexer_context *ctx)
i++;
}
struct token *tok = new_token(stream, i);
struct token *tok = new_token(stream, i, ctx->only_digits);
// if token is comment, we don't want it
if (tok->type == TOKEN_COMMENT)
{
// drop current stream
get_next_stream(ctx);
// Find next newline or EOF.
go_end_of_line(ctx);
free_token(&tok);
tok = peek_token(ctx);
}
@ -170,6 +171,9 @@ struct token *pop_token(struct lexer_context *ctx)
if (!update_lexing_mode(stream, i, &lexing_mode)
&& lexing_mode == LEXER_NORMAL)
{
// TODO call here a function
// it must check if is a spe char or an operator
// and sets i accordingly.
if (is_special_char(stream[i]))
{
if (i == 0) // where we create spe_char token
@ -195,7 +199,7 @@ struct token *pop_token(struct lexer_context *ctx)
// (this should never happen)
if (ctx->current_token == NULL)
{
ctx->current_token = new_token(stream, i);
ctx->current_token = new_token(stream, i, ctx->only_digits);
}
save_state(stream, i, ctx);