aboutsummaryrefslogtreecommitdiff
path: root/src/token.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/token.c')
-rw-r--r--src/token.c34
1 files changed, 0 insertions, 34 deletions
diff --git a/src/token.c b/src/token.c
deleted file mode 100644
index 18ec034..0000000
--- a/src/token.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <token.h>
-
-void
-token_init(token_t *token, TokenType type, char *lexeme, unsigned int line)
-{
- token->type = type;
- token->lexeme = lexeme;
- token->line = line;
- token->string = NULL;
-}
-
-char *
-token_to_string(token_t *token)
-{
- unsigned int line_length = snprintf(NULL, 0, "%ul", token->line) - 1;
- /* 2: ": ", 1: "\0" */
- unsigned int final_size = strlen(token->lexeme) + line_length + 2 + 1;
-
- char *result = (char *) calloc(1, final_size);
- snprintf(result, final_size, "%d: %s", token->line, token->lexeme);
- token->string = result;
-
- return token->string;
-}
-
-void
-token_clean(token_t *token)
-{
- if (token->string != NULL)
- free(token->string);
-}