summaryrefslogtreecommitdiff
path: root/comp/lucas-standen-NEA/code2/tokenizer.c
diff options
context:
space:
mode:
authorThing1 <thing1@seacrossedlovers.xyz>2024-08-27 10:36:18 +0100
committerThing1 <thing1@seacrossedlovers.xyz>2024-08-27 10:36:18 +0100
commitcfdd3c90877b59dc674cc9f68c0b7b4bb7c14ba8 (patch)
treeaae4a0d071df72947e8a50d88027071b3473bb12 /comp/lucas-standen-NEA/code2/tokenizer.c
parent7dad37effbeaf44ec12d2ae2fcf1643d4d4351b2 (diff)
rewrite
Diffstat (limited to 'comp/lucas-standen-NEA/code2/tokenizer.c')
-rw-r--r--comp/lucas-standen-NEA/code2/tokenizer.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/comp/lucas-standen-NEA/code2/tokenizer.c b/comp/lucas-standen-NEA/code2/tokenizer.c
new file mode 100644
index 0000000..3b7e394
--- /dev/null
+++ b/comp/lucas-standen-NEA/code2/tokenizer.c
@@ -0,0 +1,42 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include<string.h>
+
+#include "util.h"
+
+typedef struct astNode {
+ char *funcName;
+ char *args[8];
+ struct astNode *children[8];
+} astNode;
+
+astNode *tokenize(char *line){
+ astNode *head = malloc(sizeof(astNode));
+
+ int depth = 0;
+ int charCount = 0;
+ int argCount = 0;
+
+
+ for (int i = 0; i < strlen(line); i++){
+ switch (line[i]){
+ case ' ':
+ argCount++;
+ charCount = 0;
+ break;
+ case '(':
+ 1
+ default:
+ if (argCount >= 1){
+ head->args[argCount][charCount] = line[i];
+ charCount++;
+ }
+ else {
+ head->funcName[charCount] = line[i];
+ charCount++;
+ }
+ }
+ }
+
+ return NULL;
+}