Finished specifying record grammar

This commit is contained in:
Brandon Dyck 2023-06-29 09:55:45 -06:00
parent c0767bc386
commit e508d06b1a

View File

@ -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 ")" ;