start debugging full prelude

This commit is contained in:
Scott Richmond 2024-12-11 17:32:31 -05:00
parent 6a01089973
commit 7431cbf380
3 changed files with 12 additions and 15 deletions

View File

@ -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

View File

@ -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::<value::Value>()

View File

@ -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) => {