Attempting to declutter the lexer and tokenizer by rereolling them into the 'Scanner' object.
This commit is contained in:
+20
@@ -0,0 +1,20 @@
|
||||
#include "../includes/token.h"
|
||||
|
||||
Token* CreateToken(TokenType type, char* value) {
|
||||
Token* token = calloc(1, sizeof(Token));
|
||||
|
||||
if (!token) return NULL;
|
||||
|
||||
token->type = type;
|
||||
token->value = value;
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
void FreeToken(Token* token) {
|
||||
if (!token) return;
|
||||
|
||||
if (token->value) free(token->value);
|
||||
|
||||
free(token);
|
||||
}
|
||||
Reference in New Issue
Block a user