|
1 | 1 | // use this to test, and this must pass at all times |
2 | 2 | // https://bnfplayground.pauliankline.com/ |
3 | 3 | <all> ::= (<top_decl>)* |
4 | | -<top_decl> ::= "pub "? ("const " | "let " | "type " | "impl ") <ident> (":" <signature>)? " = " (<trait> | <fn> | <struct> | <tag> | <import> | <error> | <reassign> | <expr> | <enum>) |
| 4 | +<top_decl> ::= "pub "? ("const " | "let " | "type " | "impl ") <destructure> (":" <signature>)? " = " (<trait> | <fn> | <struct> | <tag> | <import> | <error> | <reassign> | <expr> | <enum>) |
5 | 5 | <import> ::= "import " <chars> |
6 | | -<trait> ::= "trait " "{ " (<top_decl)* " }" |
| 6 | +<trait> ::= "trait " "{ " (<top_decl>)* " }" |
7 | 7 | <signature> ::= <val_type> | ("&" | "*")? ("[" <signature> "]" | <ident> ("." <ident>)* | <fn_type>) |
8 | 8 | <fn_type> ::= "fn" "(" <type_args> ")" ("void" | <signature>) |
9 | 9 | <type_args> ::= (<type_arg> ("," <type_arg>)*)? |
|
15 | 15 | <for> ::= "for " "(" <expr> ")" (<fn> | <block>) |
16 | 16 | <while> ::= "while " "(" <expr> ")" (<fn> | <block>) |
17 | 17 | <match> ::= "match " "(" <expr> ")" "{ " <arm>+ "}" |
18 | | -<arm> ::= <expr> "=> " (<fn> | <block>) |
| 18 | +<arm> ::= <expr> "=> " (<fn> | <block> | <or>) |
19 | 19 | <tag> ::= "tag " ("| " <ident> (":" <signature>)?)+ |
20 | 20 | <enum> ::= "enum" "(" <val_type> ")" ("| " <ident> ("=" <expr>)?)+ |
21 | 21 | <declarators> ::= (<declarator>)* |
22 | 22 | <declarator> ::= "pub "? <ident> (":" <signature>)? |
| 23 | +<destructure> ::= ("{ " <ident> ("," <ident>)* " }") | <ident> |
23 | 24 | <args> ::= (<arg> ("," <arg>)*)? |
24 | 25 | <arg> ::= ("self " (": " <signature>)?) | <ident> (":" <signature>)? |
25 | | -<inner_decl> ::= ( "const " | "let ") <ident> (":" <signature>)? "= " <expr> |
| 26 | +<inner_decl> ::= ( "const " | "let ") <destructure> (":" <signature>)? "= " <expr> |
26 | 27 | <reassign> ::= <access> ("= " <expr>)? |
27 | 28 | <block> ::= "{ " (<inner_decl> | <for> | <while> | <if> | <reassign>)* (<return> | <break>)? "}" |
28 | 29 | <return> ::= "return " <expr>? |
|
0 commit comments