From dff204069fc37b5515fd9cd3572fd55981771cc6 Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 18 Oct 2018 01:54:36 -0700 Subject: [PATCH] Starting to implement Ignored pattern --- schala-lang/language/src/reduced_ast.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/schala-lang/language/src/reduced_ast.rs b/schala-lang/language/src/reduced_ast.rs index 12613d7..99f80c3 100644 --- a/schala-lang/language/src/reduced_ast.rs +++ b/schala-lang/language/src/reduced_ast.rs @@ -63,6 +63,12 @@ pub struct Alternative { pub item: Vec, } +impl Alternative { + fn default(item: Vec) -> Alternative { + Alternative { tag: None, guard: None, bound_vars: vec![], item } + } +} + #[derive(Debug, Clone)] pub enum Lit { Nat(u64), @@ -156,12 +162,7 @@ fn reduce_if_expression(discriminator: &Discriminator, body: &IfExpressionBody, let alternatives = vec![ pat.to_alternative(&cond, then_clause, symbol_table), - Alternative { - tag: None, - guard: None, - bound_vars: vec![], - item: else_clause, - }, + Alternative::default(else_clause), ]; Expr::CaseMatch { @@ -217,7 +218,7 @@ impl Pattern { Record(_name, _pairs) => { unimplemented!() }, - Ignored => unimplemented!(), + Ignored => Alternative::default(item), Literal(lit) => match lit { PatternLiteral::NumPattern { neg, num } => { let comparison = Expr::Lit(match (neg, num) {