aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-01-14 10:25:37 +0100
committerdec05eba <dec05eba@protonmail.com>2020-01-14 10:25:37 +0100
commit1d69979eef57e313ca35b3610cfedf84ca39ae63 (patch)
tree51742ab87777b55f75030e714e02c9f520b52bbc /src
parent42b86b43f54d23541b23c6e830a1225079bc7ad4 (diff)
bla
Diffstat (limited to 'src')
-rw-r--r--src/parser.c6
-rw-r--r--src/tokenizer.c6
2 files changed, 11 insertions, 1 deletions
diff --git a/src/parser.c b/src/parser.c
index 5e07f0e..3f9c030 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -5,6 +5,8 @@ typedef struct {
TslTokenizer tokenizer;
} TslParser;
+static int tsl_parser_parse_rhs(TslParser *self);
+
static void tsl_parser_init(TslParser *self, const char *code, size_t code_size) {
tsl_tokenizer_init(&self->tokenizer, code, code_size);
}
@@ -13,6 +15,8 @@ static int tsl_parser_parse_map(TslParser *self) {
#define parse_map_element_separator \
if(!tsl_tokenizer_accept(&self->tokenizer, TSL_TOKEN_COLON)) \
return -1; \
+ if(tsl_parser_parse_rhs(self) != 0) \
+ return -1; \
token = tsl_tokenizer_next(&self->tokenizer); \
if(token == TSL_TOKEN_COMMA) { \
continue; \
@@ -85,7 +89,7 @@ static int tsl_parser_parse_list(TslParser *self) {
}
}
-static int tsl_parser_parse_rhs(TslParser *self) {
+int tsl_parser_parse_rhs(TslParser *self) {
TslToken token = tsl_tokenizer_next(&self->tokenizer);
if(token == TSL_TOKEN_NUM) {
printf("rhs num: %ld\n", self->tokenizer.number_value);
diff --git a/src/tokenizer.c b/src/tokenizer.c
index 99ffce5..b310aae 100644
--- a/src/tokenizer.c
+++ b/src/tokenizer.c
@@ -183,6 +183,12 @@ TslToken tsl_tokenizer_next(TslTokenizer *self) {
} else if(c == ']') {
++self->code_index;
return TSL_TOKEN_RBRACKET;
+ } else if(c == ',') {
+ ++self->code_index;
+ return TSL_TOKEN_COMMA;
+ } else if(c == ':') {
+ ++self->code_index;
+ return TSL_TOKEN_COLON;
} else if(c == '\0') {
return TSL_TOKEN_END_OF_FILE;
} else {