harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 9c2b9bc7f58e4d97b0b34768781ed50e577b9942
parent 6f3f80867f9957f37276170674758884163fd370
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sat, 31 Jul 2021 10:10:01 +0200

gen: expression lists

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Msrc/gen.c | 18++++++++++++++++++
1 file changed, 18 insertions(+), 0 deletions(-)

diff --git a/src/gen.c b/src/gen.c @@ -8,6 +8,9 @@ #include "types.h" #include "util.h" +static struct gen_value gen_expr(struct gen_context *ctx, + const struct expression *expr); + static struct gen_value gen_expr_const(struct gen_context *ctx, const struct expression *expr) { @@ -61,6 +64,19 @@ gen_expr_const(struct gen_context *ctx, const struct expression *expr) } static struct gen_value +gen_expr_list(struct gen_context *ctx, const struct expression *expr) +{ + for (const struct expressions *exprs = &expr->list.exprs; + true; exprs = exprs->next) { + if (!exprs->next) { + return gen_expr(ctx, exprs->expr); + } + gen_expr(ctx, exprs->expr); + } + abort(); // Unreachable +} + +static struct gen_value gen_expr(struct gen_context *ctx, const struct expression *expr) { switch (expr->type) { @@ -84,7 +100,9 @@ gen_expr(struct gen_context *ctx, const struct expression *expr) case EXPR_FREE: case EXPR_IF: case EXPR_INSERT: + assert(0); // TODO case EXPR_LIST: + return gen_expr_list(ctx, expr); case EXPR_MATCH: case EXPR_MEASURE: assert(0); // TODO