finn-lang/grammar.txt

35 lines
849 B
Plaintext

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