diff options
author | Preston Pan <preston@nullring.xyz> | 2023-01-04 18:22:24 -0800 |
---|---|---|
committer | Preston Pan <preston@nullring.xyz> | 2023-01-04 18:22:24 -0800 |
commit | 6fe77e2f20f045b89ed10c3952f8f088e9bd3d6c (patch) | |
tree | 37abb7d1b129a0a46bbff940aa1b728d4d4f0dbd /src/parser.c | |
parent | f1e455d2fa84067edda695cbba5ddb9e5b77235e (diff) |
fully functional parser (collisions might be a problem)
Diffstat (limited to 'src/parser.c')
-rw-r--r-- | src/parser.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/parser.c b/src/parser.c index 62e1c5f..16be8e1 100644 --- a/src/parser.c +++ b/src/parser.c @@ -127,15 +127,18 @@ ast_t *parse_function(parser_t *parser) { void parse_bind(parser_t *parser) { parser_move(parser); - parser_eat(parser, TOKEN_ID); - + if (parser->tokens[parser->i]->type != TOKEN_ID) + parser_error(parser); token_t *t = parser->tokens[parser->i]; char *name = t->value; parser_move(parser); ast_t *expr = parse_expr(parser); /* unevaluated expr will be evaluated when hash table transfers to visitor JIT */ - hash_table_add(parser->symbol_table, name, expr); + + parser_move(parser); + /* if (parser->tokens[parser->i]->type != TOKEN_RPAREN) */ + /* parser_error(parser); */ } ast_t *parse_list(parser_t *parser) { @@ -201,8 +204,11 @@ ast_t *parse_expr(parser_t *parser) { return parse_symbol(parser); else if (t->type == TOKEN_LPAREN) return parse_list(parser); - else + else { + printf("DEBUG\n"); + printf("%d", t->type); parser_error(parser); + } return NULL; } |