From ad076622aa7db77ea812ba8c11164d5f78cb5c23 Mon Sep 17 00:00:00 2001 From: Scott Richmond Date: Thu, 21 Nov 2024 17:02:54 -0500 Subject: [PATCH] interpret loop & recur --- src/main.rs | 6 +++--- src/value.rs | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1be9130..23f48c9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,7 +27,7 @@ // * [x] `as` patterns // * [x] splat patterns in tuples, lists, dicts // * [x] splats in list and dict literals -// * [ ] `loop` and `recur` +// * [x] `loop` and `recur` // * [ ] string patterns // * [ ] string interpolation // * [~] write `base` in Rust @@ -57,10 +57,10 @@ use crate::base::*; pub fn main() { let src = " -let foo = :foo +let foo = false loop (foo) with { (:foo) -> :done - (x as :bool) -> recur (:bar) + (x as :boolean) -> recur (:bar) (x as :number) -> recur (:foo) (x as :keyword) -> recur (:foo) } diff --git a/src/value.rs b/src/value.rs index 1181719..6f5c2bf 100644 --- a/src/value.rs +++ b/src/value.rs @@ -142,6 +142,7 @@ impl<'src> Value<'src> { Value::Placeholder => unreachable!(), Value::Args(_) => unreachable!(), Value::Base(_) => Value::Keyword("fn"), + Value::Recur(..) => unreachable!(), } } }