diff --git a/src/compiler.rs b/src/compiler.rs index 7a31948..2427253 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -860,8 +860,27 @@ impl Compiler { _ => unreachable!(), } // TODO: implement longer synthetic expressions - for term in rest { - todo!() + for (term, _) in rest { + match term { + Keyword(str) => { + self.emit_constant(Value::Keyword(str)); + self.emit_op(Op::GetKey); + self.stack_depth -= 1; + } + Arguments(args) => { + self.emit_op(Op::Stash); + self.pop(); + let arity = args.len(); + for arg in args { + self.visit(arg); + } + self.emit_op(Op::Load); + self.emit_op(Op::Call); + self.emit_byte(arity); + self.stack_depth -= arity; + } + _ => unreachable!(), + } } } When(clauses) => { diff --git a/src/main.rs b/src/main.rs index 7e9bde6..1841443 100644 --- a/src/main.rs +++ b/src/main.rs @@ -76,16 +76,9 @@ pub fn run(src: &'static str) { pub fn main() { env::set_var("RUST_BACKTRACE", "1"); let src = " -fn foo () -> { - let x = :foo - let y = :bar - (x, y) -} +fn foo () -> fn () -> fn () -> #{:foo :bar} -let a = foo () -let b = foo () - -(a, b) +foo () () () :foo "; run(src); }