start implimenting a parser

This commit is contained in:
2025-05-27 17:19:09 +01:00
parent 3dedd7f348
commit 43bc7663fc
14 changed files with 241 additions and 195 deletions

20
src/parser/parser.c Normal file
View File

@@ -0,0 +1,20 @@
#include "parser.h"
TaggedValue parse_token(TokenStruct * tokenStruct, int *index) {
Token token = tokenStruct->tokens[*index];
switch (token.type) {
case TOKEN_STRING:
index++;
return parse_string(token);
default:
perror("unreachable");
exit(0);
}
}
void parser(TaggedValueStruct * taggedValueStruct, TokenStruct * tokenStruct, bool inline_flag) {
int index = 0;
while (index < tokenStruct->count) {
TaggedValueStruct_append(taggedValueStruct, parse_token(tokenStruct, &index));
}
}