Some incomplete parse work
This commit is contained in:
parent
176d43e56f
commit
5a91957fa1
@ -715,7 +715,10 @@ impl Parser {
|
||||
Identifier(_) => {
|
||||
let id = self.identifier()?;
|
||||
match self.peek() {
|
||||
LCurlyBrace => { unimplemented!() },
|
||||
LCurlyBrace => {
|
||||
let members = delimited!(self, LCurlyBrace, record_pattern_entry, Comma, RCurlyBrace);
|
||||
Pattern::Record(id, members)
|
||||
},
|
||||
LParen => {
|
||||
let members = delimited!(self, LParen, pattern, Comma, RParen);
|
||||
Pattern::TupleStruct(id, members)
|
||||
@ -739,6 +742,10 @@ impl Parser {
|
||||
})
|
||||
});
|
||||
|
||||
parse_method!(record_pattern_entry(&mut self) -> ParseResult<(Rc<String>, Pattern)> {
|
||||
unimplemented!()
|
||||
});
|
||||
|
||||
parse_method!(block(&mut self) -> ParseResult<Block> {
|
||||
Ok(delimited!(self, LCurlyBrace, statement, Newline | Semicolon, RCurlyBrace, nonstrict))
|
||||
});
|
||||
@ -964,7 +971,7 @@ mod parse_tests {
|
||||
use ::std::rc::Rc;
|
||||
use super::{parse, tokenize};
|
||||
use builtin::{PrefixOp, BinOp};
|
||||
use ast::{AST, Expression, Statement, IfExpressionBody, Discriminator, TypeBody, Variant, Enumerator, ForBody};
|
||||
use ast::{AST, Expression, Statement, IfExpressionBody, Discriminator, Pattern, TypeBody, Variant, Enumerator, ForBody};
|
||||
use super::Statement::*;
|
||||
use super::Declaration::*;
|
||||
use super::Signature;
|
||||
@ -1393,4 +1400,17 @@ fn a(x) {
|
||||
})])
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn patterns() {
|
||||
parse_test! {
|
||||
"if x is Some(a) then { 4 } else { 9 }", AST(vec![
|
||||
exprstatement!(
|
||||
IfExpression {
|
||||
discriminator: Discriminator::Simple(ex!(Value("x"))),
|
||||
body: SimplePatternMatch(TupleStruct("Some", [Literal(VarPattern("a"))]), [ExpressionStatement(Expression(NatLiteral(4), None))], Some([ExpressionStatement(Expression(NatLiteral(9), None))])) }
|
||||
)
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user