Refactor Token to use Location struct

This commit is contained in:
2026-04-24 22:07:00 +02:00
parent a89e61eedd
commit 26a1d0285e
4 changed files with 42 additions and 24 deletions
+6 -15
View File
@@ -4,7 +4,7 @@
#ifndef TOKEN_H
#define TOKEN_H
#include <stddef.h>
#include "location.h"
/**
* A list of all possible tokens.
@@ -37,27 +37,18 @@ typedef enum {
* Holds additional information about a token.
*/
typedef struct {
/// @brief The actual token.
TokenType token;
/// @brief The textual representation of a token.
/// Note that this is not necessarily null-terminated.
char* text;
/// @brief The entire line of text where the token was found.
char* line_text;
/// @brief The length of the `text` string.
size_t text_length;
/// @brief The length of the `line_text` string.
size_t line_text_length;
/// @brief The actual token.
TokenType token;
/// @brief The line number where the token was found.
int line;
/// @brief The column number where the token was found.
int column;
/// @brief The location of the token.
Location location;
} Token;
typedef struct TokenStream TokenStream;