diff --git a/schala-lang/src/reduced_ast.rs b/schala-lang/src/reduced_ast.rs index 3eb7bf2..966417a 100644 --- a/schala-lang/src/reduced_ast.rs +++ b/schala-lang/src/reduced_ast.rs @@ -58,8 +58,8 @@ pub enum Expr { #[derive(Debug, Clone)] pub struct Alternative { pub tag: Option, - pub guard: Option, - pub bound_vars: Vec>>, //remember that order matters here + pub guards: Vec, + pub bound_vars: Vec>>, //order here is iconic to order in a tuple-like type, None is equivalent to ignored pub item: Vec, } @@ -160,7 +160,7 @@ fn reduce_if_expression(discriminator: &Discriminator, body: &IfExpressionBody, pat.to_alternative(then_clause, symbol_table), Alternative { tag: None, - guard: None, + guards: vec![], bound_vars: vec![], item: else_clause, }, @@ -196,6 +196,12 @@ impl Pattern { SymbolSpec::DataConstructor { index, .. } => index.clone(), _ => panic!("Bad symbol"), }; + + let guards = patterns.iter().map(|p| match p { + + + }); + let bound_vars = subpatterns.iter().map(|p| match p { Literal(PatternLiteral::VarPattern(var)) => Some(var.clone()), Ignored => None, @@ -203,7 +209,7 @@ impl Pattern { }).collect(); Alternative { tag: Some(tag), - guard: None, + guards, bound_vars, item, }