Added let-exprs to grammar, and fixed patterns

This commit is contained in:
Brandon Dyck 2023-06-29 10:55:13 -06:00
parent 138508732f
commit df0c370059

View File

@ -3,7 +3,7 @@ expression ->
// | apply
| unary
| binary
// | let
| let
| compound
| control
| field
@ -17,16 +17,19 @@ binary -> expression operator expression ;
operator ->
| "==" | "!=" | "<" | "<=" | ">" | ">="
| "+" | "-" | "*" | "/"
// | "|>" | "<|" | ">>" | "<<"
| "|>" | "<|" | ">>" | "<<"
| "++" ;
pattern -> "_" | record_pattern | variant_pattern | identifier ;
record_pattern -> "{" ( identifier ( "=" pattern )? ( "," identifier ( "=" pattern )? )* ) ( "|" identifier ) "}"
variant_pattern -> "`" identifier ( "(" ( "_" | compound_pattern | identifier ) ")" )? ;
let -> "let" pattern "=" expression ( "and" pattern "=" expression )* "in" expression ;
control ->
| if
| when
if -> "if" expression "then" expression "else" expression ;
variant_pattern -> "`" identifier ( "(" ( ( "_" | identifier ) ( "," ( "_" | identifier )* )? ) ")" )? ;
when -> "when" expression "is" ( variant_pattern "=>" expression )+ ;
when -> "when" expression "is" ( pattern "=>" expression )+ ;
compound -> variant | record | list ;
variant -> "`" identifier ( "(" ( expression ( "," expression)* )? ")" )? ;
variant -> "`" identifier ( "(" expression ")" )? ;
base_record -> expression ( "with" identifier "=" expression ( "," "with" identifier "=" expression )* )?
record ->
"{" ( identifier ("=" expression)? ( "," identifier ("=" expression)? )* )? ( "|" base_record )* "}" ;