start debugging full prelude
This commit is contained in:
parent
6a01089973
commit
7431cbf380
|
@ -1,5 +1,7 @@
|
||||||
& this file, uniquely, gets `base` loaded as context. See src/base.janet for exports
|
& this file, uniquely, gets `base` loaded as context. See src/base.janet for exports
|
||||||
|
|
||||||
|
let base = base
|
||||||
|
|
||||||
& some forward declarations
|
& some forward declarations
|
||||||
& TODO: fix this so that we don't need (as many of) them
|
& TODO: fix this so that we don't need (as many of) them
|
||||||
fn and
|
fn and
|
||||||
|
|
17
src/main.rs
17
src/main.rs
|
@ -16,7 +16,7 @@
|
||||||
// * [ ] write parsing errors
|
// * [ ] write parsing errors
|
||||||
// * [ ] wire up Ariadne parsing errors
|
// * [ ] wire up Ariadne parsing errors
|
||||||
// * [ ] add stack traces and code locations to panics
|
// * [ ] add stack traces and code locations to panics
|
||||||
// * [ ] validation
|
// * [x] validation
|
||||||
// * [x] break this out into multiple files
|
// * [x] break this out into multiple files
|
||||||
// * [x] write a tree-walk VM
|
// * [x] write a tree-walk VM
|
||||||
// - [x] learn how to deal with lifetimes
|
// - [x] learn how to deal with lifetimes
|
||||||
|
@ -28,10 +28,10 @@
|
||||||
// * [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
|
||||||
// * [x] `loop` and `recur`
|
// * [x] `loop` and `recur`
|
||||||
// * [ ] string patterns
|
// * [x] string patterns
|
||||||
// * [x] string interpolation
|
// * [x] string interpolation
|
||||||
// * [x] docstrings
|
// * [x] docstrings
|
||||||
// * [~] write `base` in Rust
|
// * [x] write `base` in Rust
|
||||||
// * [ ] turn this into a library function
|
// * [ ] turn this into a library function
|
||||||
// * [ ] compile this into WASM
|
// * [ ] compile this into WASM
|
||||||
// * [ ] perf testing
|
// * [ ] perf testing
|
||||||
|
@ -64,7 +64,7 @@ use crate::process::*;
|
||||||
struct Asset;
|
struct Asset;
|
||||||
|
|
||||||
pub fn prelude<'src>() -> Process<'src> {
|
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
|
// we know for sure Prelude should live through the whole run of the program
|
||||||
let leaked = Box::leak(Box::new(prelude));
|
let leaked = Box::leak(Box::new(prelude));
|
||||||
let prelude = std::str::from_utf8(leaked).unwrap();
|
let prelude = std::str::from_utf8(leaked).unwrap();
|
||||||
|
@ -176,16 +176,7 @@ pub fn run(src: &'static str) {
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let src = "
|
let src = "
|
||||||
fn fib {
|
|
||||||
(1) -> 1
|
|
||||||
(2) -> 1
|
|
||||||
(n) -> add (
|
|
||||||
fib (dec (n))
|
|
||||||
fib (sub (n, 2))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fib (25)
|
|
||||||
";
|
";
|
||||||
run(src);
|
run(src);
|
||||||
// struct_scalpel::print_dissection_info::<value::Value>()
|
// struct_scalpel::print_dissection_info::<value::Value>()
|
||||||
|
|
|
@ -609,14 +609,18 @@ impl<'a> Validator<'a> {
|
||||||
}
|
}
|
||||||
match splatted.as_ref() {
|
match splatted.as_ref() {
|
||||||
(PlaceholderPattern, _) => (),
|
(PlaceholderPattern, _) => (),
|
||||||
(Word(name), span) => match self.bound(name) {
|
(WordPattern(name), span) => match self.bound(name) {
|
||||||
Some(_) => {
|
Some(_) => {
|
||||||
self.span = *span;
|
self.span = *span;
|
||||||
self.err(format!("name `{name}` is already bound"))
|
self.err(format!("name `{name}` is already bound"))
|
||||||
}
|
}
|
||||||
None => self.bind(name.to_string()),
|
None => self.bind(name.to_string()),
|
||||||
},
|
},
|
||||||
_ => unreachable!(),
|
_ => {
|
||||||
|
println!("internal Ludus error: unexpected splat pattern");
|
||||||
|
dbg!(splatted);
|
||||||
|
unreachable!()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TuplePattern(terms) | ListPattern(terms) | DictPattern(terms) => {
|
TuplePattern(terms) | ListPattern(terms) | DictPattern(terms) => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user