Amo/grammar-initial.ebnf
2022-04-06 09:23:46 -04:00

45 lines
1.8 KiB
EBNF

<program> ::= { DeclarationStart <declaration> }
<declaration> ::= Type Symbol Assign <variant_decl> { VBar <variant_decl> }
| Symbol Colon <full_type> DeclarationStart Symbol { Symbol } Assign <expr>
<variant_declaration> ::= Symbol { <grouped_type> }
<full_type> ::= <tight_type> [ Comma [ <additional_type> ] [ Aro <full_type> ] ]
<additional_type> ::= <tight_type> [ Comma [ <additional_type> ] ]
<tight_type> ::= OpenParen <full_type> CloseParen
| Symbol [ OpenSquareBracket <domain> CloseSquareBracket ]
<domain> ::= <expr> [ Comma [ <domain> ] ]
<expr> ::= If <expr> <ifblock>
| <let> { <let> } In <expr>
| <infix_expr>
<tightexpr> ::= Literal
| Symbol
| OpenParen <expr> CloseParen
<let> ::= Let Symbol Assign <expr>
<ifblock> ::= Is <case> { Comma <case> } [ Comma ]
| Then <expr> Else <expr>
<case> ::= <binding_pattern> Aro <expr>
<rank1_expr> ::= <rank2_expr> { <rank1_op> <rank2_expr> }
<rank2_expr> ::= <rank3_expr> { <rank2_op> <rank3_expr> }
<rank3_expr> ::= <rank4_expr> { <rank3_op> <rank4_expr> }
<rank4_expr> ::= <rank5_expr> { <rank5_expr> }
<rank5_expr> ::= <rank6_expr> { <rank5_op> <rank6_expr> }
<rank6_expr> ::= <rank7_expr> { <rank6_op> <rank7_expr> }
<rank7_expr> ::= <tightexpr> { <rank7_op> <tightexpr> }
<rank1_op> ::= LOr
<rank2_op> ::= LAnd
<rank3_op> ::= Eq | NEq | LessThan | GreaterThan
<rank5_op> ::= Range
<rank6_op> ::= Add | Sub
<rank7_op> ::= Mult | Div | Mod
<binding_pattern> ::= Symbol { <tight_binding_pattern> }
<tight_binding_pattern> ::= Literal
| Symbol
| OpenParen <binding_pattern> CloseParen