From e508d06b1a35e863db72b1c60f9542ff6f00bba4 Mon Sep 17 00:00:00 2001 From: Brandon Dyck Date: Thu, 29 Jun 2023 09:55:45 -0600 Subject: [PATCH] Finished specifying record grammar --- grammar.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/grammar.txt b/grammar.txt index f26d7a9..dea4e6a 100644 --- a/grammar.txt +++ b/grammar.txt @@ -8,10 +8,9 @@ expression -> | control | field | index -// | identifier + | identifier | primary -identifier -> IDENTIFIER | "@" STRING ; grouping -> "(" expression ")" ; unary -> ( "-" | "!" ) expression ; binary -> expression operator expression ; @@ -26,9 +25,11 @@ control -> if -> "if" expression "then" expression "else" expression ; compound -> variant | record | list ; variant -> "`" identifier ( "(" ( expression ( "," expression)* )? ")" )? ; +base_record -> expression ( "with" identifier "=" expression ( "," "with" identifier "=" expression )* )? record -> - "{" ( identifier "=" expression ( "," identifier "=" expression )* )? "}" ; + "{" ( identifier ("=" expression)? ( "," identifier ("=" expression)? )* )? ( "|" base_record )* "}" ; list -> "[" ( expression ( "," expression )* )? "]" ; field -> expression "." identifier ; index -> expression "[" expression "]" ; -primary -> NUMBER | STRING | "(" expression ")" ; +identifier -> IDENTIFIER | "@" STRING ; +primary -> NUMBER | STRING | identifier | "(" expression ")" ;