Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/include/token.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ token_T* token_init(const char* value, token_type_T type, lexer_T* lexer);
char* token_to_string(const token_T* token);
const char* token_type_to_string(token_type_T type);

char* token_value(const token_T* token);
int token_type(const token_T* token);

size_t token_sizeof(void);

token_T* token_copy(token_T* token);

void token_free(token_T* token);
Expand Down
16 changes: 2 additions & 14 deletions src/token.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@
#include <stdlib.h>
#include <string.h>

size_t token_sizeof(void) {
return sizeof(struct TOKEN_STRUCT);
}

token_T* token_init(const char* value, const token_type_T type, lexer_T* lexer) {
token_T* token = calloc(1, token_sizeof());
token_T* token = calloc(1, sizeof(token_T));

if (type == TOKEN_NEWLINE) {
lexer->current_line++;
Expand Down Expand Up @@ -119,18 +115,10 @@ char* token_to_string(const token_T* token) {
return string;
}

char* token_value(const token_T* token) {
return token->value;
}

int token_type(const token_T* token) {
return token->type;
}

token_T* token_copy(token_T* token) {
if (!token) { return NULL; }

token_T* new_token = calloc(1, token_sizeof());
token_T* new_token = calloc(1, sizeof(token_T));

if (!new_token) { return NULL; }

Expand Down
Loading