diff options
Diffstat (limited to 'src/parse')
-rw-r--r-- | src/parse/parsetree.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/parse/parsetree.rs b/src/parse/parsetree.rs index 081489d..575afc9 100644 --- a/src/parse/parsetree.rs +++ b/src/parse/parsetree.rs @@ -202,6 +202,14 @@ fn parse_type(s: &str) -> IResult<&str, Type> { let absp = take_while1(|c| "ABCDEFGHIJKLMNOPQRSTUVWXYZ".contains(c)) .map(|s: &str| VarType(s.to_string())); + let sump = ( + tag("("), multispace0, + tag("Sum"), multispace1, + parse_type, multispace1, + parse_type, multispace0, + tag(")") + ).map(|tup| sumtype(tup.4, tup.6)); + alt(( tag("Int") .map(|_| Integer), tag("Bool") .map(|_| Boolean), @@ -210,6 +218,7 @@ fn parse_type(s: &str) -> IResult<&str, Type> { tag("Let") .map(|_| LetType), tag("Type") .map(|_| TypeLit), tag("Nil") .map(|_| NilType), + sump, arrp, vecp, listp, |