diff --git a/assets/prelude.ld b/assets/prelude.ld index 8139895..fe73448 100644 --- a/assets/prelude.ld +++ b/assets/prelude.ld @@ -1,5 +1,7 @@ & this file, uniquely, gets `base` loaded as context. See src/base.janet for exports +let base = base + & some forward declarations & TODO: fix this so that we don't need (as many of) them fn and diff --git a/src/main.rs b/src/main.rs index 1273882..5c8b0da 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,7 +16,7 @@ // * [ ] write parsing errors // * [ ] wire up Ariadne parsing errors // * [ ] add stack traces and code locations to panics -// * [ ] validation +// * [x] validation // * [x] break this out into multiple files // * [x] write a tree-walk VM // - [x] learn how to deal with lifetimes @@ -28,10 +28,10 @@ // * [x] splat patterns in tuples, lists, dicts // * [x] splats in list and dict literals // * [x] `loop` and `recur` -// * [ ] string patterns +// * [x] string patterns // * [x] string interpolation // * [x] docstrings -// * [~] write `base` in Rust +// * [x] write `base` in Rust // * [ ] turn this into a library function // * [ ] compile this into WASM // * [ ] perf testing @@ -64,7 +64,7 @@ use crate::process::*; struct Asset; pub fn prelude<'src>() -> Process<'src> { - let prelude = Asset::get("test_prelude.ld").unwrap().data.into_owned(); + let prelude = Asset::get("prelude.ld").unwrap().data.into_owned(); // we know for sure Prelude should live through the whole run of the program let leaked = Box::leak(Box::new(prelude)); let prelude = std::str::from_utf8(leaked).unwrap(); @@ -176,16 +176,7 @@ pub fn run(src: &'static str) { pub fn main() { let src = " -fn fib { - (1) -> 1 - (2) -> 1 - (n) -> add ( - fib (dec (n)) - fib (sub (n, 2)) - ) -} -fib (25) "; run(src); // struct_scalpel::print_dissection_info::() diff --git a/src/validator.rs b/src/validator.rs index f05cee7..cb433ae 100644 --- a/src/validator.rs +++ b/src/validator.rs @@ -609,14 +609,18 @@ impl<'a> Validator<'a> { } match splatted.as_ref() { (PlaceholderPattern, _) => (), - (Word(name), span) => match self.bound(name) { + (WordPattern(name), span) => match self.bound(name) { Some(_) => { self.span = *span; self.err(format!("name `{name}` is already bound")) } None => self.bind(name.to_string()), }, - _ => unreachable!(), + _ => { + println!("internal Ludus error: unexpected splat pattern"); + dbg!(splatted); + unreachable!() + } } } TuplePattern(terms) | ListPattern(terms) | DictPattern(terms) => {