41 lines
1.4 KiB
Plaintext
41 lines
1.4 KiB
Plaintext
expression ->
|
|
| sequence
|
|
// | apply
|
|
| unary
|
|
| binary
|
|
| let
|
|
| compound
|
|
| control
|
|
| field
|
|
| index
|
|
| identifier
|
|
| primary
|
|
|
|
grouping -> "(" expression ")" ;
|
|
unary -> ( "-" | "!" ) expression ;
|
|
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 ;
|
|
when -> "when" expression "is" ( pattern "=>" expression )+ ;
|
|
compound -> variant | record | list ;
|
|
variant -> "`" identifier ( "(" expression ")" )? ;
|
|
base_record -> expression ( "with" identifier "=" expression ( "," "with" identifier "=" expression )* )?
|
|
record ->
|
|
"{" ( identifier ("=" expression)? ( "," identifier ("=" expression)? )* )? ( "|" base_record )* "}" ;
|
|
list -> "[" ( expression ( "," expression )* )? "]" ;
|
|
field -> expression "." identifier ;
|
|
index -> expression "[" expression "]" ;
|
|
identifier -> IDENTIFIER | "@" STRING ;
|
|
primary -> NUMBER | STRING | identifier | "(" expression ")" ;
|