finn-lang/grammar.txt

35 lines
875 B
Plaintext

expression ->
| sequence
// | apply
| unary
| binary
// | let
| compound
| control
| field
| index
// | identifier
| primary
identifier -> IDENTIFIER | "@" STRING ;
grouping -> "(" expression ")" ;
unary -> ( "-" | "!" ) expression ;
binary -> expression operator expression ;
operator ->
| "==" | "!=" | "<" | "<=" | ">" | ">="
| "+" | "-" | "*" | "/"
// | "|>" | "<|" | ">>" | "<<"
| "++" ;
control ->
| if
// | when
if -> "if" expression "then" expression "else" expression ;
compound -> variant | record | list ;
variant -> "`" identifier ( "(" ( expression ( "," expression)* )? ")" )? ;
record ->
"{" ( identifier "=" expression ( "," identifier "=" expression )* )? "}" ;
list -> "[" ( expression ( "," expression )* )? "]" ;
field -> expression "." identifier ;
index -> expression "[" expression "]" ;
primary -> NUMBER | STRING | "(" expression ")" ;