Skip to content

Commit e8a5284

Browse files
committed
replaced mut by var
1 parent 562d83a commit e8a5284

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+294
-315
lines changed

benchmark/fib.hk

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ fn fib(n) =>
44

55
let n = to_int(args[0]);
66
let m = to_int(args[1]);
7-
for (mut i = 0; i < n; i++)
7+
for (var i = 0; i < n; i++)
88
println(fib(m));

docs/built-in.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ fn valid(it: iterator) -> bool;
649649
Example:
650650

651651
```rust
652-
mut it = iter(1..3);
652+
var it = iter(1..3);
653653
println(valid(it)); // true
654654
it = next(it);
655655
println(valid(it)); // true
@@ -670,7 +670,7 @@ fn current(it: iterator) -> any;
670670
Example:
671671

672672
```rust
673-
mut it = iter(1..3);
673+
var it = iter(1..3);
674674
println(current(it)); // 1
675675
it = next(it);
676676
println(current(it)); // 2
@@ -691,7 +691,7 @@ fn next(it: iterator) -> iterator;
691691
Example:
692692

693693
```rust
694-
mut it = iter(1..3);
694+
var it = iter(1..3);
695695
println(current(it)); // 1
696696
it = next(it);
697697
println(current(it)); // 2

docs/core-modules.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -1957,7 +1957,7 @@ fn len(list: userdata) -> number;
19571957
Example:
19581958

19591959
```rust
1960-
mut list = lists.new_linked_list();
1960+
var list = lists.new_linked_list();
19611961
list = lists.push_back(list, 1);
19621962
list = lists.push_back(list, 2);
19631963
list = lists.push_back(list, 3);
@@ -1990,7 +1990,7 @@ fn push_front(list: userdata, value: any) -> userdata;
19901990
Example:
19911991

19921992
```rust
1993-
mut list = lists.new_linked_list();
1993+
var list = lists.new_linked_list();
19941994
list = lists.push_front(list, 1);
19951995
list = lists.push_front(list, 2);
19961996
println(lists.front(list)); // 2
@@ -2009,7 +2009,7 @@ fn push_back(list: userdata, value: any) -> userdata;
20092009
Example:
20102010

20112011
```rust
2012-
mut list = lists.new_linked_list();
2012+
var list = lists.new_linked_list();
20132013
list = lists.push_back(list, 1);
20142014
list = lists.push_back(list, 2);
20152015
println(lists.front(list)); // 1
@@ -2027,7 +2027,7 @@ fn pop_front(list: userdata) -> userdata;
20272027
Example:
20282028

20292029
```rust
2030-
mut list1 = lists.new_linked_list();
2030+
var list1 = lists.new_linked_list();
20312031
list1 = lists.push_back(list1, 1);
20322032
list1 = lists.push_back(list1, 2);
20332033
let list2 = lists.pop_front(list1);
@@ -2045,7 +2045,7 @@ fn pop_back(list: userdata) -> userdata;
20452045
Example:
20462046

20472047
```rust
2048-
mut list1 = lists.new_linked_list();
2048+
var list1 = lists.new_linked_list();
20492049
list1 = lists.push_back(list1, 1);
20502050
list1 = lists.push_back(list1, 2);
20512051
let list2 = lists.pop_back(list1);
@@ -2063,7 +2063,7 @@ fn front(list: userdata) -> any;
20632063
Example:
20642064

20652065
```rust
2066-
mut list = lists.new_linked_list();
2066+
var list = lists.new_linked_list();
20672067
list = lists.push_back(list, 1);
20682068
list = lists.push_back(list, 2);
20692069
println(lists.front(list)); // 1
@@ -2080,7 +2080,7 @@ fn back(list: userdata) -> any;
20802080
Example:
20812081

20822082
```rust
2083-
mut list = lists.new_linked_list();
2083+
var list = lists.new_linked_list();
20842084
list = lists.push_back(list, 1);
20852085
list = lists.push_back(list, 2);
20862086
println(lists.back(list)); // 2

docs/grammar.ebnf

+67-66
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,120 @@
11
2-
chunk ::= statement* EOF
2+
chunk ::= stmt* EOF
33

4-
statement ::= import_statement
5-
| variable_declaration ';'
4+
stmt ::= import_stmt
5+
| var_decl ';'
66
| 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
1717
| block
1818

19-
import_statement ::= 'import' NAME ( 'as' NAME )? ';'
19+
import_stmt ::= 'import' NAME ( 'as' NAME )? ';'
2020
| 'import' STRING 'as' NAME ';'
2121
| 'import' '{' NAME ( ',' NAME )* '}' 'from' ( NAME | STRING ) ';'
2222

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
2727

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
3333

34-
struct_declaration ::= 'struct' NAME '{' ( string | NAME ( ',' string | NAME )* )? '}'
34+
struct_decl ::= 'struct' NAME '{' ( string | NAME ( ',' string | NAME )* )? '}'
3535

36-
function_declaration ::= 'fn' NAME '(' ( 'mut'? NAME ( ',' 'mut'? NAME )* )? ')' ( '=>' expression ";" | block )
36+
fn_decl ::= 'fn' NAME '(' ( NAME ( ',' NAME )* )? ')' ( '=>' expr ";" | block )
3737

38-
delete_statement ::= 'del' NAME subscript* '[' expression ']' ';'
38+
del_stmt ::= 'del' NAME subsc* '[' expr ']' ';'
3939

40-
if_statement ::= ( 'if' | 'if!' ) '(' ( variable_declaration ';' )? expression ')'
41-
statement ( 'else' statement )?
40+
if_stmt ::= ( 'if' | 'if!' ) '(' ( var_decl ';' )? expr ')'
41+
stmt ( 'else' stmt )?
4242

43-
match_statement ::= 'match' '(' ( variable_declaration ';' )? expression ')'
44-
'{' ( expression '=>' statement )+ ( '_' '=>' statement )? '}'
43+
match_stmt ::= 'match' '(' ( var_decl ';' )? expr ')'
44+
'{' ( expr '=>' stmt )+ ( '_' '=>' stmt )? '}'
4545

46-
loop_statement ::= 'loop' statement
46+
loop_stmt ::= 'loop' stmt
4747

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 ')' ';'
5050

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
5354

54-
break_statement ::= ( 'break' | 'continue' ) ';'
55+
break_stmt ::= ( 'break' | 'continue' ) ';'
5556

56-
return_statement ::= 'return' expression? ';'
57+
return_stmt ::= 'return' expr? ';'
5758

5859
block ::= '{' stmt* '}'
5960

6061
assign_op ::= '=' | '|=' | '^=' | '&=' | '<<=' | '>>='
6162
| '+=' | '-=' | '*=' | '/=' | '~/=' | '%='
6263

63-
subscript ::= '[' expression ']' | '.' NAME
64+
subsc ::= '[' expr ']' | '.' NAME
6465

65-
call ::= '(' ( expression ( ',' expression )* )? ')'
66+
call ::= '(' ( expr ( ',' expr )* )? ')'
6667

67-
expression ::= and_expression ( '||' and_expression )*
68+
expr ::= and_expr ( '||' and_expr )*
6869

69-
and_expression ::= equal_expression ( '&&' equal_expression )*
70+
and_expr ::= equal_expr ( '&&' equal_expr )*
7071

71-
equal_expression ::= comp_expression ( ( '==' | '!=' ) comp_expression )*
72+
equal_expr ::= comp_expr ( ( '==' | '!=' ) comp_expr )*
7273

73-
comp_expression ::= bor_expression ( ( '>' | '>=' | '<' | '<=' ) bor_expression )*
74+
comp_expr ::= bor_expr ( ( '>' | '>=' | '<' | '<=' ) bor_expr )*
7475

75-
bor_expression ::= bxor_expression ( '|' bxor_expression )*
76+
bor_expr ::= bxor_expr ( '|' bxor_expr )*
7677

77-
bxor_expression ::= band_expression ( '^' band_expression )*
78+
bxor_expr ::= band_expr ( '^' band_expr )*
7879

79-
band_expression ::= shift_expression ( '&' shift_expression )*
80+
band_expr ::= shift_expr ( '&' shift_expr )*
8081

81-
shift_expression ::= range_expression ( ( '<<' | '>>' ) range_expression )*
82+
shift_expr ::= range_expr ( ( '<<' | '>>' ) range_expr )*
8283

83-
range_expression ::= add_expression ( '..' add_expression )?
84+
range_expr ::= add_expr ( '..' add_expr )?
8485

85-
add_expression ::= mul_expression ( ( '+' | '-' ) mul_expression )*
86+
add_expr ::= mul_expr ( ( '+' | '-' ) mul_expr )*
8687

87-
mul_expression ::= unary_expression ( ( '*' | '/' | '~/' | '%' ) unary_expression )*
88+
mul_expr ::= unary_expr ( ( '*' | '/' | '~/' | '%' ) unary_expr )*
8889

89-
unary_expression ::= ( '-' | '!' | '~' ) unary_expression | primary_expression
90+
unary_expr ::= ( '-' | '!' | '~' ) unary_expr | primary_expr
9091

91-
primary_expression ::= literal
92+
primary_expr ::= literal
9293
| array_constructor
9394
| struct_constructor
9495
| 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
100101

101102
literal ::= 'nil' | 'false' | 'true' | number | string
102103

103-
array_constructor ::= '[' ( expression ( ',' expression )* )? ']'
104+
array_constructor ::= '[' ( expr ( ',' expr )* )? ']'
104105

105-
struct_constructor ::= '{' ( string | NAME ':' expression ( ',' string | NAME ':' expression )* )? '}'
106+
struct_constructor ::= '{' ( string | NAME ':' expr ( ',' string | NAME ':' expr )* )? '}'
106107

107108
anonymous_struct ::= 'struct' '{' ( string | NAME ( ',' string | NAME )* )? '}'
108109

109-
anonymous_function ::= '|' ( 'mut'? NAME ( ',' 'mut'? NAME )* )? '|' ( '=>' expression | block )
110-
| '||' ( '=>' expression | block )
110+
anonymous_fn ::= '|' ( NAME ( ',' NAME )* )? '|' ( '=>' expr | block )
111+
| '||' ( '=>' expr | block )
111112

112-
if_expression ::= ( 'if' | 'if!' ) '(' expression ')' expression 'else' expression
113+
if_expr ::= ( 'if' | 'if!' ) '(' expr ')' expr 'else' expr
113114

114-
match_expression ::= 'match' '(' expression ')' '{' expression '=>' expression ( ',' expression '=>' expression )*
115-
',' '_' '=>' expression '}'
115+
match_expr ::= 'match' '(' expr ')' '{' expr '=>' expr ( ',' expr '=>' expr )*
116+
',' '_' '=>' expr '}'
116117

117-
subscript_call ::= NAME ( subscript | call )* ( '{' ( expression ( ',' expression )* )? '}' )?
118+
subsc_call ::= NAME ( subsc | call )* ( '{' ( expr ( ',' expr )* )? '}' )?
118119

119-
group_expression ::= '(' expression ')'
120+
group_expr ::= '(' expr ')'

0 commit comments

Comments
 (0)