|
1 | 1 |
|
2 |
| -chunk ::= statement* EOF |
| 2 | +chunk ::= stmt* EOF |
3 | 3 |
|
4 |
| -statement ::= import_statement |
5 |
| - | variable_declaration ';' |
| 4 | +stmt ::= import_stmt |
| 5 | + | var_decl ';' |
6 | 6 | | assign_call ';'
|
7 |
| - | struct_declaration |
8 |
| - | function_declaration |
9 |
| - | delete_statement |
10 |
| - | if_statement |
11 |
| - | match_statement |
12 |
| - | loop_statement |
13 |
| - | while_statement |
14 |
| - | for_statement |
15 |
| - | break_statement |
16 |
| - | return_statement |
| 7 | + | struct_decl |
| 8 | + | fn_decl |
| 9 | + | del_stmt |
| 10 | + | if_stmt |
| 11 | + | match_stmt |
| 12 | + | loop_stmt |
| 13 | + | while_stmt |
| 14 | + | for_stmt |
| 15 | + | break_stmt |
| 16 | + | return_stmt |
17 | 17 | | block
|
18 | 18 |
|
19 |
| -import_statement ::= 'import' NAME ( 'as' NAME )? ';' |
| 19 | +import_stmt ::= 'import' NAME ( 'as' NAME )? ';' |
20 | 20 | | 'import' STRING 'as' NAME ';'
|
21 | 21 | | 'import' '{' NAME ( ',' NAME )* '}' 'from' ( NAME | STRING ) ';'
|
22 | 22 |
|
23 |
| -variable_declaration ::= 'let' NAME '=' expression |
24 |
| - | 'mut' NAME ( '=' expression )? |
25 |
| - | ( 'let' | 'mut' ) '[' '_' | NAME ( ',' '_' | NAME )* ']' '=' expression |
26 |
| - | ( 'let' | 'mut' ) '{' NAME ( ',' NAME )* '}' '=' expression |
| 23 | +var_decl ::= 'let' NAME '=' expr |
| 24 | + | 'var' NAME ( '=' expr )? |
| 25 | + | ( 'let' | 'var' ) '[' '_' | NAME ( ',' '_' | NAME )* ']' '=' expr |
| 26 | + | ( 'let' | 'var' ) '{' NAME ( ',' NAME )* '}' '=' expr |
27 | 27 |
|
28 |
| -assign_call ::= NAME subscript* assign_op expression |
29 |
| - | NAME subscript* ( '++' | '--' ) |
30 |
| - | NAME subscript* '[' ']' '=' expression |
31 |
| - | NAME subscript* subscript '=' expression |
32 |
| - | NAME ( subscript | call )* call |
| 28 | +assign_call ::= NAME subsc* assign_op expr |
| 29 | + | NAME subsc* ( '++' | '--' ) |
| 30 | + | NAME subsc* '[' ']' '=' expr |
| 31 | + | NAME subsc* subsc '=' expr |
| 32 | + | NAME ( subsc | call )* call |
33 | 33 |
|
34 |
| -struct_declaration ::= 'struct' NAME '{' ( string | NAME ( ',' string | NAME )* )? '}' |
| 34 | +struct_decl ::= 'struct' NAME '{' ( string | NAME ( ',' string | NAME )* )? '}' |
35 | 35 |
|
36 |
| -function_declaration ::= 'fn' NAME '(' ( 'mut'? NAME ( ',' 'mut'? NAME )* )? ')' ( '=>' expression ";" | block ) |
| 36 | +fn_decl ::= 'fn' NAME '(' ( NAME ( ',' NAME )* )? ')' ( '=>' expr ";" | block ) |
37 | 37 |
|
38 |
| -delete_statement ::= 'del' NAME subscript* '[' expression ']' ';' |
| 38 | +del_stmt ::= 'del' NAME subsc* '[' expr ']' ';' |
39 | 39 |
|
40 |
| -if_statement ::= ( 'if' | 'if!' ) '(' ( variable_declaration ';' )? expression ')' |
41 |
| - statement ( 'else' statement )? |
| 40 | +if_stmt ::= ( 'if' | 'if!' ) '(' ( var_decl ';' )? expr ')' |
| 41 | + stmt ( 'else' stmt )? |
42 | 42 |
|
43 |
| -match_statement ::= 'match' '(' ( variable_declaration ';' )? expression ')' |
44 |
| - '{' ( expression '=>' statement )+ ( '_' '=>' statement )? '}' |
| 43 | +match_stmt ::= 'match' '(' ( var_decl ';' )? expr ')' |
| 44 | + '{' ( expr '=>' stmt )+ ( '_' '=>' stmt )? '}' |
45 | 45 |
|
46 |
| -loop_statement ::= 'loop' statement |
| 46 | +loop_stmt ::= 'loop' stmt |
47 | 47 |
|
48 |
| -while_statement ::= ( 'while' | 'while!' ) '(' expression ')' statement |
49 |
| - | 'do' statement ( 'while' | 'while!' ) '(' expression ')' ';' |
| 48 | +while_stmt ::= ( 'while' | 'while!' ) '(' expr ')' stmt |
| 49 | + | 'do' stmt ( 'while' | 'while!' ) '(' expr ')' ';' |
50 | 50 |
|
51 |
| -for_statement ::= 'for' '(' ( variable_declaration | assign_call )? ';' expression? ';' assign_call? ')' statement |
52 |
| - | 'foreach' '(' NAME 'in' expression ')' statement |
| 51 | +for_stmt ::= 'for' '(' ( var_decl | assign_call )? ';' expr? |
| 52 | + ';' assign_call? ')' stmt |
| 53 | + | 'foreach' '(' NAME 'in' expr ')' stmt |
53 | 54 |
|
54 |
| -break_statement ::= ( 'break' | 'continue' ) ';' |
| 55 | +break_stmt ::= ( 'break' | 'continue' ) ';' |
55 | 56 |
|
56 |
| -return_statement ::= 'return' expression? ';' |
| 57 | +return_stmt ::= 'return' expr? ';' |
57 | 58 |
|
58 | 59 | block ::= '{' stmt* '}'
|
59 | 60 |
|
60 | 61 | assign_op ::= '=' | '|=' | '^=' | '&=' | '<<=' | '>>='
|
61 | 62 | | '+=' | '-=' | '*=' | '/=' | '~/=' | '%='
|
62 | 63 |
|
63 |
| -subscript ::= '[' expression ']' | '.' NAME |
| 64 | +subsc ::= '[' expr ']' | '.' NAME |
64 | 65 |
|
65 |
| -call ::= '(' ( expression ( ',' expression )* )? ')' |
| 66 | +call ::= '(' ( expr ( ',' expr )* )? ')' |
66 | 67 |
|
67 |
| -expression ::= and_expression ( '||' and_expression )* |
| 68 | +expr ::= and_expr ( '||' and_expr )* |
68 | 69 |
|
69 |
| -and_expression ::= equal_expression ( '&&' equal_expression )* |
| 70 | +and_expr ::= equal_expr ( '&&' equal_expr )* |
70 | 71 |
|
71 |
| -equal_expression ::= comp_expression ( ( '==' | '!=' ) comp_expression )* |
| 72 | +equal_expr ::= comp_expr ( ( '==' | '!=' ) comp_expr )* |
72 | 73 |
|
73 |
| -comp_expression ::= bor_expression ( ( '>' | '>=' | '<' | '<=' ) bor_expression )* |
| 74 | +comp_expr ::= bor_expr ( ( '>' | '>=' | '<' | '<=' ) bor_expr )* |
74 | 75 |
|
75 |
| -bor_expression ::= bxor_expression ( '|' bxor_expression )* |
| 76 | +bor_expr ::= bxor_expr ( '|' bxor_expr )* |
76 | 77 |
|
77 |
| -bxor_expression ::= band_expression ( '^' band_expression )* |
| 78 | +bxor_expr ::= band_expr ( '^' band_expr )* |
78 | 79 |
|
79 |
| -band_expression ::= shift_expression ( '&' shift_expression )* |
| 80 | +band_expr ::= shift_expr ( '&' shift_expr )* |
80 | 81 |
|
81 |
| -shift_expression ::= range_expression ( ( '<<' | '>>' ) range_expression )* |
| 82 | +shift_expr ::= range_expr ( ( '<<' | '>>' ) range_expr )* |
82 | 83 |
|
83 |
| -range_expression ::= add_expression ( '..' add_expression )? |
| 84 | +range_expr ::= add_expr ( '..' add_expr )? |
84 | 85 |
|
85 |
| -add_expression ::= mul_expression ( ( '+' | '-' ) mul_expression )* |
| 86 | +add_expr ::= mul_expr ( ( '+' | '-' ) mul_expr )* |
86 | 87 |
|
87 |
| -mul_expression ::= unary_expression ( ( '*' | '/' | '~/' | '%' ) unary_expression )* |
| 88 | +mul_expr ::= unary_expr ( ( '*' | '/' | '~/' | '%' ) unary_expr )* |
88 | 89 |
|
89 |
| -unary_expression ::= ( '-' | '!' | '~' ) unary_expression | primary_expression |
| 90 | +unary_expr ::= ( '-' | '!' | '~' ) unary_expr | primary_expr |
90 | 91 |
|
91 |
| -primary_expression ::= literal |
| 92 | +primary_expr ::= literal |
92 | 93 | | array_constructor
|
93 | 94 | | struct_constructor
|
94 | 95 | | anonymous_struct
|
95 |
| - | anonymous_function |
96 |
| - | if_expression |
97 |
| - | match_expression |
98 |
| - | subscript_call |
99 |
| - | group_expression |
| 96 | + | anonymous_fn |
| 97 | + | if_expr |
| 98 | + | match_expr |
| 99 | + | subsc_call |
| 100 | + | group_expr |
100 | 101 |
|
101 | 102 | literal ::= 'nil' | 'false' | 'true' | number | string
|
102 | 103 |
|
103 |
| -array_constructor ::= '[' ( expression ( ',' expression )* )? ']' |
| 104 | +array_constructor ::= '[' ( expr ( ',' expr )* )? ']' |
104 | 105 |
|
105 |
| -struct_constructor ::= '{' ( string | NAME ':' expression ( ',' string | NAME ':' expression )* )? '}' |
| 106 | +struct_constructor ::= '{' ( string | NAME ':' expr ( ',' string | NAME ':' expr )* )? '}' |
106 | 107 |
|
107 | 108 | anonymous_struct ::= 'struct' '{' ( string | NAME ( ',' string | NAME )* )? '}'
|
108 | 109 |
|
109 |
| -anonymous_function ::= '|' ( 'mut'? NAME ( ',' 'mut'? NAME )* )? '|' ( '=>' expression | block ) |
110 |
| - | '||' ( '=>' expression | block ) |
| 110 | +anonymous_fn ::= '|' ( NAME ( ',' NAME )* )? '|' ( '=>' expr | block ) |
| 111 | + | '||' ( '=>' expr | block ) |
111 | 112 |
|
112 |
| -if_expression ::= ( 'if' | 'if!' ) '(' expression ')' expression 'else' expression |
| 113 | +if_expr ::= ( 'if' | 'if!' ) '(' expr ')' expr 'else' expr |
113 | 114 |
|
114 |
| -match_expression ::= 'match' '(' expression ')' '{' expression '=>' expression ( ',' expression '=>' expression )* |
115 |
| - ',' '_' '=>' expression '}' |
| 115 | +match_expr ::= 'match' '(' expr ')' '{' expr '=>' expr ( ',' expr '=>' expr )* |
| 116 | + ',' '_' '=>' expr '}' |
116 | 117 |
|
117 |
| -subscript_call ::= NAME ( subscript | call )* ( '{' ( expression ( ',' expression )* )? '}' )? |
| 118 | +subsc_call ::= NAME ( subsc | call )* ( '{' ( expr ( ',' expr )* )? '}' )? |
118 | 119 |
|
119 |
| -group_expression ::= '(' expression ')' |
| 120 | +group_expr ::= '(' expr ')' |
0 commit comments