More work on more patterns
-need to convert guard into a possibly-empty vec
This commit is contained in:
parent
dca9ad06c3
commit
e57d33eae7
@ -58,7 +58,7 @@ pub enum Expr {
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Alternative {
|
||||
pub tag: Option<usize>,
|
||||
pub guard: Option<Expr>,
|
||||
pub guard: Option<Expr>, //TODO should be a vec
|
||||
pub bound_vars: Vec<Option<Rc<String>>>, //remember that order matters here
|
||||
pub item: Vec<Stmt>,
|
||||
}
|
||||
@ -188,6 +188,10 @@ fn reduce_if_expression(discriminator: &Discriminator, body: &IfExpressionBody,
|
||||
}
|
||||
}
|
||||
}
|
||||
/* ig var pat
|
||||
* x is SomeBigOldEnum(_, x, Some(t))
|
||||
*/
|
||||
|
||||
|
||||
impl Pattern {
|
||||
fn to_alternative(&self, cond: &Box<Expr>, item: Vec<Stmt>, symbol_table: &SymbolTable) -> Alternative {
|
||||
@ -200,9 +204,18 @@ impl Pattern {
|
||||
};
|
||||
let bound_vars = subpatterns.iter().map(|p| match p {
|
||||
Literal(PatternLiteral::VarPattern(var)) => Some(var.clone()),
|
||||
Ignored => None,
|
||||
_ => None,
|
||||
}).collect();
|
||||
|
||||
/*
|
||||
let guard_equality_exprs: Vec<Expr> = subpatterns.iter().map(|p| match p {
|
||||
Literal(lit) => match lit {
|
||||
_ => unimplemented!()
|
||||
},
|
||||
_ => unimplemented!()
|
||||
}).collect();
|
||||
*/
|
||||
|
||||
Alternative {
|
||||
tag: Some(tag),
|
||||
guard: None,
|
||||
@ -216,7 +229,7 @@ impl Pattern {
|
||||
let symbol = symbol_table.lookup_by_name(name).expect(&format!("Symbol {} not found", name));
|
||||
handle_symbol(symbol, subpatterns, item)
|
||||
},
|
||||
TuplePattern(_items) => {
|
||||
TuplePattern(items) => {
|
||||
unimplemented!()
|
||||
},
|
||||
Record(_name, _pairs) => {
|
||||
|
Loading…
Reference in New Issue
Block a user