interpret loop & recur

This commit is contained in:
Scott Richmond 2024-11-21 17:02:54 -05:00
parent 423f43b7fd
commit ad076622aa
2 changed files with 4 additions and 3 deletions

View File

@ -27,7 +27,7 @@
// * [x] `as` patterns // * [x] `as` patterns
// * [x] splat patterns in tuples, lists, dicts // * [x] splat patterns in tuples, lists, dicts
// * [x] splats in list and dict literals // * [x] splats in list and dict literals
// * [ ] `loop` and `recur` // * [x] `loop` and `recur`
// * [ ] string patterns // * [ ] string patterns
// * [ ] string interpolation // * [ ] string interpolation
// * [~] write `base` in Rust // * [~] write `base` in Rust
@ -57,10 +57,10 @@ use crate::base::*;
pub fn main() { pub fn main() {
let src = " let src = "
let foo = :foo let foo = false
loop (foo) with { loop (foo) with {
(:foo) -> :done (:foo) -> :done
(x as :bool) -> recur (:bar) (x as :boolean) -> recur (:bar)
(x as :number) -> recur (:foo) (x as :number) -> recur (:foo)
(x as :keyword) -> recur (:foo) (x as :keyword) -> recur (:foo)
} }

View File

@ -142,6 +142,7 @@ impl<'src> Value<'src> {
Value::Placeholder => unreachable!(), Value::Placeholder => unreachable!(),
Value::Args(_) => unreachable!(), Value::Args(_) => unreachable!(),
Value::Base(_) => Value::Keyword("fn"), Value::Base(_) => Value::Keyword("fn"),
Value::Recur(..) => unreachable!(),
} }
} }
} }