Implement numeric pattern matching

This commit is contained in:
greg 2018-10-16 03:54:08 -07:00
parent 8619c94217
commit 501eaeee87
1 changed files with 20 additions and 3 deletions

View File

@ -226,13 +226,30 @@ impl<'a> State<'a> {
inner_state.values.insert(bv.clone(), ValueEntry::Binding { constant: true, val: val.clone() });
}
}
if let Some(guard_expr) = alt.guard {
let evaled_guard = inner_state.expression(guard_expr.to_node());
println!("EVALED GUARD: {:?}", evaled_guard);
//continue
}
return inner_state.block(alt.item)
}
}
return Err(format!("No matches found"));
return Err(format!("Failed pattern match"));
},
Node::PrimTuple { .. } => Err(format!("Tuples don't work")),
Node::Expr(e) => Err(format!("Exprs don't work {:?}", e))
Node::PrimTuple { .. } => Err(format!("Tuples not implemented")), //TODO make a distinction between not yet implemented and an actual runtime error
Node::Expr(e) => {
for alt in alternatives {
match alt.guard {
Some(ref guard_expr) if alt.tag.is_none() => {
return self.block(alt.item)
},
_ => ()
}
}
return Err(format!("Failed pattern match"));
}
},
UnimplementedSigilValue => Err(format!("Sigil value eval not implemented"))
}