From 3c5039134fccfcc2c00c831129d0308f02d18ed8 Mon Sep 17 00:00:00 2001 From: Kasey White Date: Wed, 28 Sep 2022 04:03:37 -0400 Subject: [PATCH] attempt to parse let --- crates/lang/src/parser.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/crates/lang/src/parser.rs b/crates/lang/src/parser.rs index 5b968426..cca30599 100644 --- a/crates/lang/src/parser.rs +++ b/crates/lang/src/parser.rs @@ -382,9 +382,30 @@ pub fn expr_unit_parser() -> impl Parser impl Parser { + 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 { recursive(|r| { choice((