70 lines
2.6 KiB
EBNF
70 lines
2.6 KiB
EBNF
<program> ::= { DeclarationStart <declaration> }
|
|
|
|
<declaration> ::= Type Symbol [ <typeargs> ] { Symbol } Assign <variant_decl> { VBar <variant_decl> }
|
|
| Struct Symbol { Symbol } Assign { <def_field> }
|
|
| Trait Symbol [ <typeargs> ] [ On <composite_type> ] Needs { <def_field> }
|
|
| Impl Symbol [ <typerags> ] On <composite_type> Colon <impl> { <impl> }
|
|
| Symbol <def>
|
|
|
|
<variant_declaration> ::= Symbol { <grouped_type> }
|
|
|
|
<full_type> ::= <composite_type> [ { Comma <composite_type> } Aro <full_type> ]
|
|
|
|
<composite_type> ::= <simple_type> { <grouped_type> }
|
|
|
|
<grouped_type> ::= <simple_type>
|
|
| OpenParen <full_type> CloseParen
|
|
|
|
<simple_type> ::= Symbol [ OpenSquareBracket <domain> CloseSquareBracket ]
|
|
|
|
<domain> ::= Int Range Int
|
|
| Int
|
|
|
|
<def_field> ::= Dot Symbol Colon <full_type>
|
|
|
|
<typeargs> ::= OpenSouareBracket <typearg> { , <typearg> } CloseSquareBracket
|
|
<typearg> ::= Symbol Colon <full_type>
|
|
|
|
<impl> ::= Dot Symbol { Symbol } Assign <expr>
|
|
|
|
<def> ::= Colon <full_type>
|
|
| { Symbol } Assign <expr>
|
|
|
|
|
|
|
|
|
|
<expr> ::= <tightexpr> { <tightexpr> }
|
|
| If <expr> <ifblock>
|
|
| <let> { <let> } In <expr>
|
|
| <infix_expr>
|
|
<tightexpr> ::= Literal
|
|
| { <multisymbol> }
|
|
| OpenParen <expr> CloseParen
|
|
|
|
<multisymbol> ::= Symbol { Dot Symbol }
|
|
|
|
<let> ::= Let Symbol Assign <expr>
|
|
|
|
<ifblock> ::= Is <case> { Comma <case> } [ Comma ]
|
|
| Then <expr> Else <expr>
|
|
|
|
<case> ::= <binding_pattern> Aro <expr>
|
|
|
|
|
|
<infix_expr> ::= <infix_rank2_expr> { <infix_rank1_op> <infix_rank2_expr> }
|
|
<infix_rank2_expr> ::= <infix_rank3_expr> { <infix_rank2_op> <infix_rank3_expr> }
|
|
<infix_rank3_expr> ::= <infix_rank4_expr> { <infix_rank3_op> <infix_rank4_expr> }
|
|
<infix_rank4_expr> ::= <infix_rank5_expr> { <infix_rank4_op> <infix_rank5_expr> }
|
|
<infix_rank5_expr> ::= <tightexpr> { <infix_rank5_op> <tightexpr> }
|
|
<infix_rank1_op> ::= Mult | Div | Mod
|
|
<infix_rank2_op> ::= Add | Sub
|
|
<infix_rank3_op> ::= Eq | NEq | LessThan | GreaterThan
|
|
<infix_rank4_op> ::= LAnd
|
|
<infix_rank5_op> ::= LOr
|
|
|
|
<binding_pattern> ::= Symbol <bp_innards>
|
|
| Literal
|
|
<bp_innards> ::= { <bp_field> }
|
|
| { <binding_pattern }
|
|
<bp_field> ::= Dot Symbol Assign <binding_pattern>
|