Compare commits

..

No commits in common. "e9b52e14882e149588d27e58772df18bdd843234" and "ec38bcdc8c6fecdb4c9eae7e9cd76499a8a9ea09" have entirely different histories.

2 changed files with 5 additions and 53 deletions

View File

@ -167,7 +167,8 @@ pub fn run(src: &'static str) {
pub fn main() {
let src = "
do 42 > recur ()
box foo = 42
foo
";
run(src);
// struct_scalpel::print_dissection_info::<value::Value>()

View File

@ -256,43 +256,7 @@ impl<'a> Validator<'a> {
// check arity is 1 if first term is keyword
// check arity against fn info if first term is word and second term is args
Ast::Synthetic(first, second, rest) => {
match (&first.0, &second.0) {
(Ast::Word(_), Ast::Keyword(_)) => {
let (expr, span) = first.as_ref();
self.ast = expr;
self.span = *span;
self.validate();
}
(Ast::Keyword(_), Ast::Arguments(args)) => {
if args.len() != 1 {
self.err("called keywords may only take one argument".to_string())
}
let (expr, span) = second.as_ref();
self.ast = expr;
self.span = *span;
self.validate();
}
(Ast::Word(_), Ast::Arguments(_)) => {
let (expr, span) = first.as_ref();
self.ast = expr;
self.span = *span;
self.validate();
let (expr, span) = second.as_ref();
self.ast = expr;
self.span = *span;
self.validate();
//TODO: check arity of call
}
_ => unreachable!(),
}
for term in rest {
let (expr, span) = term;
self.ast = expr;
self.span = *span;
self.validate();
}
todo!()
}
Ast::When(clauses) => {
// let tailpos = self.status.tail_position;
@ -391,25 +355,13 @@ impl<'a> Validator<'a> {
self.validate();
self.status.tail_position = tailpos;
}
// TODO: fix the tail call here?
Ast::Do(terms) => {
if terms.len() < 2 {
return self.err("do expressions must have at least two terms".to_string());
}
for term in terms.iter().take(terms.len() - 1) {
for term in terms {
let (expr, span) = term;
self.ast = expr;
self.span = *span;
self.validate();
}
let (expr, span) = terms.last().unwrap();
self.ast = expr;
self.span = *span;
if matches!(expr, Ast::Recur(_)) {
self.err("`recur` may not be used in `do` forms".to_string());
}
self.validate();
}
Ast::Repeat(times, body) => {
self.status.tail_position = false;
@ -441,8 +393,7 @@ impl<'a> Validator<'a> {
}
Ast::Recur(args) => {
if !self.status.in_loop {
self.err("you may only use `recur` in a `loop` form".to_string());
return;
self.err("you may only use `recur` in a loop form".to_string());
}
if !self.status.tail_position {
self.err("you may only use `recur` in tail position".to_string());