Add subpattern struct

This commit is contained in:
greg 2018-10-30 18:39:25 -07:00
parent b8df09e956
commit e88ed97b06

View File

@ -59,7 +59,7 @@ pub enum Expr {
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Alternative { pub struct Alternative {
pub tag: Option<usize>, pub tag: Option<usize>,
pub subpatterns: Vec<Alternative>, pub subpatterns: Vec<Option<Subpattern>>,
pub guard: Option<Expr>, 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>,
@ -71,6 +71,14 @@ impl Alternative {
} }
} }
#[derive(Debug, Clone)]
pub struct Subpattern {
pub tag: Option<usize>,
pub subpatterns: Vec<Subpattern>,
pub bound_vars: Vec<Option<Rc<String>>>,
pub guard: Option<Expr>,
}
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum Lit { pub enum Lit {
Nat(u64), Nat(u64),