first draft of synthetic validation
This commit is contained in:
parent
ec38bcdc8c
commit
4c9659271b
|
@ -167,8 +167,10 @@ pub fn run(src: &'static str) {
|
|||
|
||||
pub fn main() {
|
||||
let src = "
|
||||
box foo = 42
|
||||
foo
|
||||
match foo with {
|
||||
:a -> :b
|
||||
:c -> :d
|
||||
}
|
||||
";
|
||||
run(src);
|
||||
// struct_scalpel::print_dissection_info::<value::Value>()
|
||||
|
|
|
@ -256,7 +256,41 @@ 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) => {
|
||||
todo!()
|
||||
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();
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
for term in rest {
|
||||
let (expr, span) = term;
|
||||
self.ast = expr;
|
||||
self.span = *span;
|
||||
self.validate();
|
||||
}
|
||||
}
|
||||
Ast::When(clauses) => {
|
||||
// let tailpos = self.status.tail_position;
|
||||
|
|
Loading…
Reference in New Issue
Block a user