finn-lang/grammar.txt

35 lines
849 B
Plaintext
Raw Normal View History

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