hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 1e82efdec742a39d80d179076236a677c32e7124
parent 17d72b50c8fb614dd12fcec11dd2cd8754be0ebe
Author: Drew DeVault <sir@cmpwn.com>
Date:   Thu,  2 Sep 2021 12:34:12 +0200

cmd/harec: partially implement compound exprs

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

Diffstat:
Mcmd/harec/gen.ha | 14+++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/cmd/harec/gen.ha b/cmd/harec/gen.ha @@ -78,12 +78,20 @@ fn gen_func(ctx: *context, decl: *unit::decl) void = { }; fn gen_expr(ctx: *context, expr: *unit::expr) value = { - match (expr.expr) { - unit::compound_expr => abort(), // TODO - unit::constant_expr => return gen_expr_const(ctx, expr), + return match (expr.expr) { + unit::compound_expr => gen_expr_compound(ctx, expr), + unit::constant_expr => gen_expr_const(ctx, expr), }; }; +fn gen_expr_compound(ctx: *context, expr: *unit::expr) value = { + const compound = expr.expr as unit::compound_expr; + for (let i = 0z; i < len(compound); i += 1) { + gen_expr(ctx, compound[i]); + }; + return vvoid; // TODO +}; + fn gen_expr_const(ctx: *context, expr: *unit::expr) value = { const constexpr = expr.expr as unit::constant_expr; const val: qval = match (constexpr) {