Subpattern field

This commit is contained in:
greg 2018-10-19 17:43:22 -07:00
parent e57d33eae7
commit fef66e345b

View File

@ -58,14 +58,15 @@ pub enum Expr {
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Alternative { pub struct Alternative {
pub tag: Option<usize>, pub tag: Option<usize>,
pub guard: Option<Expr>, //TODO should be a vec pub subpatterns: Vec<Alternative>,
pub guard: Option<Expr>,
pub bound_vars: Vec<Option<Rc<String>>>, //remember that order matters here pub bound_vars: Vec<Option<Rc<String>>>, //remember that order matters here
pub item: Vec<Stmt>, pub item: Vec<Stmt>,
} }
impl Alternative { impl Alternative {
fn default(item: Vec<Stmt>) -> Alternative { fn default(item: Vec<Stmt>) -> Alternative {
Alternative { tag: None, guard: None, bound_vars: vec![], item } Alternative { tag: None, subpatterns: vec![], guard: None, bound_vars: vec![], item }
} }
} }
@ -216,9 +217,13 @@ impl Pattern {
}).collect(); }).collect();
*/ */
let guard = None;
let subpatterns = vec![];
Alternative { Alternative {
tag: Some(tag), tag: Some(tag),
guard: None, subpatterns,
guard,
bound_vars, bound_vars,
item, item,
} }
@ -251,6 +256,7 @@ impl Pattern {
}); });
Alternative { Alternative {
tag: None, tag: None,
subpatterns: vec![],
guard, guard,
bound_vars: vec![], bound_vars: vec![],
item item
@ -268,6 +274,7 @@ impl Pattern {
}); });
Alternative { Alternative {
tag: None, tag: None,
subpatterns: vec![],
guard, guard,
bound_vars: vec![], bound_vars: vec![],
item item
@ -277,6 +284,7 @@ impl Pattern {
Some(symbol) => handle_symbol(symbol, &vec![], item), Some(symbol) => handle_symbol(symbol, &vec![], item),
None => Alternative { None => Alternative {
tag: None, tag: None,
subpatterns: vec![],
guard: None, guard: None,
bound_vars: vec![Some(var.clone())], bound_vars: vec![Some(var.clone())],
item item