2024-09-30 20:55:46 -04:00
|
|
|
#include "include/token.h"
|
2024-10-10 16:09:25 -04:00
|
|
|
#include <stdio.h>
|
2024-09-30 20:55:46 -04:00
|
|
|
|
|
|
|
Token* token_init(TokenType type, char* val) {
|
|
|
|
Token* t = malloc(sizeof(Token));
|
|
|
|
|
|
|
|
t->type = type;
|
|
|
|
t->val = val;
|
|
|
|
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
void token_destroy(Token* t) {
|
|
|
|
free(t->val);
|
|
|
|
free(t);
|
|
|
|
}
|
2024-10-07 11:48:53 -04:00
|
|
|
|
2024-10-10 16:09:25 -04:00
|
|
|
char* token_to_str(Token* token, unsigned int indent) {
|
|
|
|
char* title = malloc(sizeof("Token @ 0x000000000000\n"));
|
|
|
|
sprintf(title, "Token @%p\n", token);
|
|
|
|
return title;
|
2024-10-07 11:48:53 -04:00
|
|
|
}
|