Refactor Token to use Location struct
This commit is contained in:
+6
-15
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user