Refactor Token to use Location struct
This commit is contained in:
+6
-5
@@ -95,10 +95,11 @@ static Token create_token(TokenStream* ts, TokenType type, const char* text, siz
|
||||
t.token = type;
|
||||
t.text = (char*)text;
|
||||
t.text_length = length;
|
||||
t.line = line;
|
||||
t.column = column;
|
||||
t.line_text = (char*)line_start;
|
||||
t.line_text_length = get_line_length(line_start);
|
||||
t.location.filename = (char*)ts->filename;
|
||||
t.location.line = line;
|
||||
t.location.column = column;
|
||||
t.location.line_text = (char*)line_start;
|
||||
t.location.line_text_length = get_line_length(line_start);
|
||||
return t;
|
||||
}
|
||||
|
||||
@@ -191,6 +192,6 @@ Token tokenstream_next(TokenStream* ts) {
|
||||
|
||||
/* Unknown character */
|
||||
Token t = create_token(ts, TOKEN_UNKNOWN, start_text, 1, start_line, start_column, line_start);
|
||||
log_on_line(ts->filename, t.line_text, t.line, t.column, t.column, "unexpected token '%c'", c);
|
||||
log_on_line(ts->filename, t.location.line_text, t.location.line, t.location.column, t.location.column, "unexpected token '%c'", c);
|
||||
return t;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user