diff options
| author | Carson Fleming <cflems@cflems.net> | 2026-03-28 10:42:09 -1000 |
|---|---|---|
| committer | Carson Fleming <cflems@cflems.net> | 2026-03-28 10:42:09 -1000 |
| commit | 0dc409ab0967d9973f36c138825067462b9a216f (patch) | |
| tree | 0704d9f0a669a731907f26fac22249c1a25e17a4 /parser.c | |
| parent | 33d10c0a684eaacb59102e2e2c2494ef54113aa1 (diff) | |
| download | ccc-0dc409ab0967d9973f36c138825067462b9a216f.tar.gz | |
one step toward rehashing
Diffstat (limited to 'parser.c')
| -rw-r--r-- | parser.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -90,21 +90,24 @@ static void parse_var_ref(struct var_ref_node* p_node) { p_node->ident = tok.data.ident; } -static void parse_expr_assign(struct expr_node* p_node) { - peek_or_panic(); - if (tok.type != TK_ASSIGN) return; - - switch (p_node->type) { +static void expr_to_lval(struct lval_node* l_node, struct expr_node* e_node) { + switch (e_node->type) { case EXPR_VAR_REF: - p_node->as._assign.lval = (struct lval_node) { + *l_node = (struct lval_node) { .type = LVAL_VAR_REF, - .as._var_ref = p_node->as._var_ref, + .as._var_ref = e_node->as._var_ref, }; - break; + return; default: PARSER_PANIC("expression is not assignable"); } +} + +static void parse_expr_assign(struct expr_node* p_node) { + peek_or_panic(); + if (tok.type != TK_ASSIGN) return; + expr_to_lval(&p_node->as._assign.lval, p_node); p_node->type = EXPR_ASSIGN; p_node->as._assign.rval = protected_alloc(sizeof(struct expr_node)); |
