More work on match expression

This commit is contained in:
greg 2017-09-20 21:05:08 -07:00
parent 6bff7aac0d
commit 8b83d982c0
1 changed files with 15 additions and 1 deletions

View File

@ -435,8 +435,18 @@ pub enum Expression {
indexers: Vec<Expression>,
},
IfExpression(Box<Expression>, Vec<Statement>, Option<Vec<Statement>>),
MatchExpression(Box<Expression>, Vec<MatchArm>)
}
#[derive(Debug, PartialEq)]
pub struct MatchArm {
pat: Pattern,
expr: Expression,
}
#[derive(Debug, PartialEq)]
pub struct Pattern(String);
#[derive(Debug, PartialEq)]
pub struct Operation(Rc<String>);
@ -717,7 +727,11 @@ impl Parser {
expect!(self, LCurlyBrace, "Expected '{'");
let body = self.match_body()?;
expect!(self, RCurlyBrace, "Expected '}'");
unimplementd!()
Ok(Expression::MatchExpression(Box::new(expr), body))
});
parse_method!(match_body(&mut self) -> ParseResult<Vec<MatchArm>> {
Ok(vec!())
});
parse_method!(identifier(&mut self) -> ParseResult<Rc<String>> {