From 722dc4b477b202cb143b70d821618753a9a7a491 Mon Sep 17 00:00:00 2001 From: Kasey White Date: Sat, 1 Oct 2022 20:36:16 -0400 Subject: [PATCH] work on adding when clause --- crates/lang/src/expr.rs | 4 +-- crates/lang/src/parser.rs | 46 ++++++++++++++++++++++++++------- crates/lang/src/tests/parser.rs | 10 ++++--- 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/crates/lang/src/expr.rs b/crates/lang/src/expr.rs index 1fb24b8d..fbfa66b7 100644 --- a/crates/lang/src/expr.rs +++ b/crates/lang/src/expr.rs @@ -227,7 +227,7 @@ pub enum UntypedExpr { annotation: Option, }, - Case { + When { location: Span, subjects: Vec, clauses: Vec>, @@ -327,7 +327,7 @@ impl UntypedExpr { | Self::Var { location, .. } | Self::Int { location, .. } | Self::Todo { location, .. } - | Self::Case { location, .. } + | Self::When { location, .. } | Self::Call { location, .. } | Self::List { location, .. } | Self::Float { location, .. } diff --git a/crates/lang/src/parser.rs b/crates/lang/src/parser.rs index 2e3e8ce2..9a9e664e 100644 --- a/crates/lang/src/parser.rs +++ b/crates/lang/src/parser.rs @@ -323,17 +323,43 @@ pub fn expr_parser() -> impl Parser impl Parser 3 + 1 | 2 -> 5 + 3 if a == 3 -> 9 + _ -> 4 + } } "#; let len = code.chars().count();