finn-lang/grammar.txt

34 lines
807 B
Plaintext
Raw Normal View History

2023-06-28 21:52:39 +00:00
expression ->
| literal
// | IDENTIFIER
// | sequence
| unary
| binary
// | let
// | when
| if
| variant
| record
| list
| field
| index
| grouping ;
literal -> NUMBER | 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 ")" ;