attempt to parse let
This commit is contained in:
parent
60359ec9b0
commit
3c5039134f
|
@ -382,9 +382,30 @@ pub fn expr_unit_parser() -> impl Parser<Token, expr::UntypedExpr, Error = Parse
|
|||
location: span,
|
||||
label,
|
||||
}),
|
||||
just(Token::Let)
|
||||
.then(assignment_parser())
|
||||
.map(|(_, assign)| assign),
|
||||
))
|
||||
}
|
||||
|
||||
fn assignment_parser() -> impl Parser<Token, expr::UntypedExpr, Error = ParseError> {
|
||||
recursive(|_r| {
|
||||
pattern_parser()
|
||||
.then(just(Token::Colon).ignore_then(type_parser()).or_not())
|
||||
.then_ignore(just(Token::Equal))
|
||||
.then(expr_parser())
|
||||
.map_with_span(
|
||||
|((pattern, annotation), value), span| expr::UntypedExpr::Assignment {
|
||||
location: span,
|
||||
value: Box::new(value),
|
||||
pattern,
|
||||
kind: ast::AssignmentKind::Let,
|
||||
annotation,
|
||||
},
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn type_parser() -> impl Parser<Token, ast::Annotation, Error = ParseError> {
|
||||
recursive(|r| {
|
||||
choice((
|
||||
|
|
Loading…
Reference in New Issue