From 138508732f59c8a3a6a86602517e5372fbcac1e7 Mon Sep 17 00:00:00 2001 From: Brandon Dyck Date: Thu, 29 Jun 2023 10:10:41 -0600 Subject: [PATCH] Added when expressions to grammar --- grammar.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/grammar.txt b/grammar.txt index dea4e6a..73af91c 100644 --- a/grammar.txt +++ b/grammar.txt @@ -21,8 +21,10 @@ operator -> | "++" ; control -> | if -// | when + | when if -> "if" expression "then" expression "else" expression ; +variant_pattern -> "`" identifier ( "(" ( ( "_" | identifier ) ( "," ( "_" | identifier )* )? ) ")" )? ; +when -> "when" expression "is" ( variant_pattern "=>" expression )+ ; compound -> variant | record | list ; variant -> "`" identifier ( "(" ( expression ( "," expression)* )? ")" )? ; base_record -> expression ( "with" identifier "=" expression ( "," "with" identifier "=" expression )* )?