More work on if matching
This commit is contained in:
parent
88b617de52
commit
34c2b43371
@ -135,7 +135,9 @@ impl Expression {
|
|||||||
fn reduce_if_expression(discriminator: &Discriminator, body: &IfExpressionBody, symbol_table: &SymbolTable) -> Expr {
|
fn reduce_if_expression(discriminator: &Discriminator, body: &IfExpressionBody, symbol_table: &SymbolTable) -> Expr {
|
||||||
let cond = Box::new(match *discriminator {
|
let cond = Box::new(match *discriminator {
|
||||||
Discriminator::Simple(ref expr) => expr.reduce(symbol_table),
|
Discriminator::Simple(ref expr) => expr.reduce(symbol_table),
|
||||||
_ => panic!(),
|
Discriminator::BinOp(ref expr, ref binop) => {
|
||||||
|
panic!()
|
||||||
|
}
|
||||||
});
|
});
|
||||||
match *body {
|
match *body {
|
||||||
IfExpressionBody::SimpleConditional(ref then_clause, ref else_clause) => {
|
IfExpressionBody::SimpleConditional(ref then_clause, ref else_clause) => {
|
||||||
@ -190,13 +192,14 @@ fn reduce_if_expression(discriminator: &Discriminator, body: &IfExpressionBody,
|
|||||||
},
|
},
|
||||||
IfExpressionBody::GuardList(ref guard_arms) => {
|
IfExpressionBody::GuardList(ref guard_arms) => {
|
||||||
let alternatives = guard_arms.iter().map(|arm| {
|
let alternatives = guard_arms.iter().map(|arm| {
|
||||||
Alternative {
|
let (tag, bound_vars) = match arm.guard {
|
||||||
tag: Some(0),
|
_ => (Some(0), vec![]),
|
||||||
bound_vars: vec![],
|
};
|
||||||
item: arm.body.iter().map(|expr| expr.reduce(symbol_table)).collect(),
|
|
||||||
}
|
let item = arm.body.iter().map(|expr| expr.reduce(symbol_table)).collect();
|
||||||
});
|
Alternative { tag, bound_vars, item }
|
||||||
Expr::UnimplementedSigilValue
|
}).collect();
|
||||||
|
Expr::CaseMatch { cond, alternatives }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user