add flex lexer

This commit is contained in:
2025-05-27 03:08:49 +01:00
parent a71071d858
commit 1540645759
10 changed files with 163 additions and 19 deletions

20
src/lexer/lexer.c Normal file
View File

@@ -0,0 +1,20 @@
#include "lex.yy.h"
#include "token.h"
int lexer() {
const char *input = "term.log\n";
void* buffer = yy_scan_string(input);
yy_switch_to_buffer(buffer);
yylex(); // This fills the token array
yy_delete_buffer(buffer);
for (int i = 0; i < token_count; i++) {
printf("Token(type=%d, value='%s')\n", tokens[i].type, tokens[i].value);
}
free_tokens();
return 0;
}