From e57d33eae75aaf21925611f0c6b83985dcb962c4 Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 19 Oct 2018 17:27:06 -0700 Subject: [PATCH] More work on more patterns -need to convert guard into a possibly-empty vec --- schala-lang/language/src/reduced_ast.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/schala-lang/language/src/reduced_ast.rs b/schala-lang/language/src/reduced_ast.rs index 4ae50ae..a7c284e 100644 --- a/schala-lang/language/src/reduced_ast.rs +++ b/schala-lang/language/src/reduced_ast.rs @@ -58,7 +58,7 @@ pub enum Expr { #[derive(Debug, Clone)] pub struct Alternative { pub tag: Option, - pub guard: Option, + pub guard: Option, //TODO should be a vec pub bound_vars: Vec>>, //remember that order matters here pub item: Vec, } @@ -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, item: Vec, 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 = 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) => {