diff --git a/grammar.txt b/grammar.txt new file mode 100644 index 0000000..7313f60 --- /dev/null +++ b/grammar.txt @@ -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 ")" ;