summaryrefslogtreecommitdiff
path: root/comp/lucas-standen-NEA/code2/tokenizer.c
blob: 3b7e394fa0ea2fd76fa86777674540cc296c91f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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;
}