pass file into flex instead of content buffer
This commit is contained in:
@@ -8,8 +8,7 @@ void lexer(LexerState state) {
|
||||
|
||||
yyset_extra(&state, scanner);
|
||||
|
||||
void* buffer = yy_scan_string(state.content, scanner);
|
||||
yy_switch_to_buffer(buffer, scanner);
|
||||
yyset_in(state.file, scanner);
|
||||
|
||||
int token;
|
||||
while ((token = yylex(scanner)) != 0) {
|
||||
@@ -26,7 +25,5 @@ void lexer(LexerState state) {
|
||||
state.current_column += yyget_leng(scanner);
|
||||
}
|
||||
}
|
||||
|
||||
yy_delete_buffer(buffer, scanner);
|
||||
yylex_destroy(scanner);
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
#include "token.h"
|
||||
#include "../list/list.h"
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct {
|
||||
const char *path;
|
||||
const char *content;
|
||||
FILE *file;
|
||||
int current_column;
|
||||
LinkedList* tokens;
|
||||
// add more fields as needed
|
||||
|
||||
Reference in New Issue
Block a user