2023-06-28 21:52:39 +00:00
|
|
|
expression ->
|
2023-06-28 23:18:31 +00:00
|
|
|
| sequence
|
2023-06-29 17:33:32 +00:00
|
|
|
| apply
|
2023-06-28 21:52:39 +00:00
|
|
|
| unary
|
|
|
|
| binary
|
2023-06-29 16:55:13 +00:00
|
|
|
| let
|
2023-06-28 23:18:31 +00:00
|
|
|
| compound
|
|
|
|
| control
|
2023-06-29 17:33:32 +00:00
|
|
|
| selector
|
2023-06-28 21:52:39 +00:00
|
|
|
| index
|
2023-06-29 15:55:45 +00:00
|
|
|
| identifier
|
2023-06-28 23:18:31 +00:00
|
|
|
| primary
|
2023-06-28 21:52:39 +00:00
|
|
|
|
|
|
|
grouping -> "(" expression ")" ;
|
|
|
|
unary -> ( "-" | "!" ) expression ;
|
|
|
|
binary -> expression operator expression ;
|
|
|
|
operator ->
|
|
|
|
| "==" | "!=" | "<" | "<=" | ">" | ">="
|
|
|
|
| "+" | "-" | "*" | "/"
|
2023-06-29 16:55:13 +00:00
|
|
|
| "|>" | "<|" | ">>" | "<<"
|
2023-06-28 21:52:39 +00:00
|
|
|
| "++" ;
|
2023-06-29 17:33:32 +00:00
|
|
|
pattern -> "_" | record_pattern | variant_pattern ;
|
2023-06-29 16:55:13 +00:00
|
|
|
record_pattern -> "{" ( identifier ( "=" pattern )? ( "," identifier ( "=" pattern )? )* ) ( "|" identifier ) "}"
|
|
|
|
variant_pattern -> "`" identifier ( "(" ( "_" | compound_pattern | identifier ) ")" )? ;
|
2023-06-29 17:33:32 +00:00
|
|
|
parameters -> "(" ( identifier ( "," identifier )* )?")"
|
|
|
|
let -> "let" ( identifier parameters? | pattern ) "=" expression ( "and" ( identifier parameters? | pattern ) "=" expression )* "in" expression ;
|
2023-06-28 23:18:31 +00:00
|
|
|
control ->
|
|
|
|
| if
|
2023-06-29 16:10:41 +00:00
|
|
|
| when
|
2023-06-28 21:52:39 +00:00
|
|
|
if -> "if" expression "then" expression "else" expression ;
|
2023-06-29 17:33:32 +00:00
|
|
|
when -> "when" expression "is" ( ( identifier | pattern ) "=>" expression )+ ;
|
2023-06-28 23:18:31 +00:00
|
|
|
compound -> variant | record | list ;
|
2023-06-29 16:55:13 +00:00
|
|
|
variant -> "`" identifier ( "(" expression ")" )? ;
|
2023-06-29 15:55:45 +00:00
|
|
|
base_record -> expression ( "with" identifier "=" expression ( "," "with" identifier "=" expression )* )?
|
2023-06-28 21:52:39 +00:00
|
|
|
record ->
|
2023-06-29 15:55:45 +00:00
|
|
|
"{" ( identifier ("=" expression)? ( "," identifier ("=" expression)? )* )? ( "|" base_record )* "}" ;
|
2023-06-28 21:52:39 +00:00
|
|
|
list -> "[" ( expression ( "," expression )* )? "]" ;
|
2023-06-29 15:55:45 +00:00
|
|
|
identifier -> IDENTIFIER | "@" STRING ;
|
2023-06-29 17:33:32 +00:00
|
|
|
operand -> ( NUMBER | STRING | identifier | "(" expression ")" ) ;
|
|
|
|
selector -> "." identifier ;
|
|
|
|
index -> "[" expression "]" ;
|
|
|
|
arguments -> "(" ( "_" | expression ( "," ( "_" | expression ) )* )? ")" ;
|
|
|
|
primary -> operand ( selector | index | arguments ) ;
|