From 5f9b4a2fb66354bc0cd3658453bbde9b5809b6ec Mon Sep 17 00:00:00 2001 From: Brandon Dyck Date: Sun, 2 Jul 2023 11:39:37 -0600 Subject: [PATCH] Allow trailing comma in list and record grammars --- grammar.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grammar.txt b/grammar.txt index ac928fd..50292be 100644 --- a/grammar.txt +++ b/grammar.txt @@ -28,10 +28,10 @@ control -> if -> "if" expression "then" expression "else" expression ; when -> "when" expression "is" ( ( identifier | pattern ) "=>" expression )+ ; variant -> "`" identifier ( "(" expression ")" )? ; -base_record -> expression ( "with" identifier "=" expression ( "," "with" identifier "=" expression )* )? +base_record -> expression ( "with" identifier "=" expression ( "," identifier "=" expression )* ","? )? record -> - "{" ( identifier ("=" expression)? ( "," identifier ("=" expression)? )* )? ( "|" base_record )* "}" ; -list -> "[" ( expression ( "," expression )* )? "]" ; + "{" ( identifier ("=" expression)? ( "," identifier ("=" expression)? )* )? ( "|" base_record )? "}" ; +list -> "[" ( expression ( "," expression )* ","? )? "]" ; identifier -> IDENTIFIER | "@" STRING ; operand -> ( NUMBER | STRING | identifier | "(" expression ")" | record | variant | list) ; selector -> "." identifier ;