aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorc+12023-05-03 17:16:38 -0400
committerc+12023-05-03 17:16:38 -0400
commit2ac46b8b73896603f6b14d3e52500761c49a3262 (patch)
tree15b18854bcb525dfe1f08d00b713c7fe5af2b1bc /src
parent7ced4218e9b8317b9d7d9e8489cf24d0f406cc5d (diff)
whoa
Diffstat (limited to 'src')
-rw-r--r--src/lexer.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lexer.c b/src/lexer.c
index 3a5f557..35e9fde 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -2,6 +2,7 @@
#include "include/token.h"
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
lexer_T* lexer_init(char* content) {
lexer_T* lexer = calloc(1, sizeof(struct LEXER_STRUC));
@@ -120,7 +121,18 @@ token_T* lexer_get_string(lexer_T* lexer) {
}
token_T* lexer_get_id(lexer_T* lexer) {
+ char* str_so_far = calloc(1, sizeof(char));
+ str_so_far[0] = '\0';
+
+ while (isalnum(lexer->c)) {
+ char* current = lexer_get_c_as_string(lexer);
+ str_so_far = realloc(str_so_far, (strlen(str_so_far) + strlen(current) * sizeof(char)));
+ strcat(str_so_far, current);
+
+ lexer_next(lexer);
+ }
+ return token_init(TOKEN_ID, str_so_far);
}
token_T* lexer_next_token(lexer_T* lexer, token_T* token) {