Added partial draft of grammar doc

This commit is contained in:
Brandon Dyck 2023-06-28 15:52:39 -06:00
parent 36a7b4dba3
commit 3fbe0f482f

33
grammar.txt Normal file
View File

@ -0,0 +1,33 @@
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 ")" ;