start implimenting a parser
This commit is contained in:
20
src/parser/parser.c
Normal file
20
src/parser/parser.c
Normal 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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user