update lexer to just return the number and then do the other logic somewhere else

This commit is contained in:
2025-05-30 02:12:51 +01:00
parent 626445a906
commit 68341db0b0
13 changed files with 165 additions and 350 deletions

View File

@@ -11,7 +11,21 @@ void lexer(LexerState state) {
void* buffer = yy_scan_string(state.content, scanner);
yy_switch_to_buffer(buffer, scanner);
yylex(scanner);
int token;
while ((token = yylex(scanner)) != 0) {
Token * token_struct = create_token(
token,
yyget_lineno(scanner),
state.current_column,
yyget_text(scanner)
);
append(state.tokens, token_struct);
if (token == TOKEN_NEW_LINE) {
state.current_column = 0;
} else {
state.current_column += yyget_leng(scanner);
}
}
yy_delete_buffer(buffer, scanner);
yylex_destroy(scanner);