Skip to content

Commit 790cec2

Browse files
[create-pull-request] automated change (#947)
Co-authored-by: jskeet <[email protected]>
1 parent c944138 commit 790cec2

File tree

3 files changed

+45
-15
lines changed

3 files changed

+45
-15
lines changed

standard/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,9 @@
438438
- [§13.6](statements.md#136-declaration-statements) Declaration statements
439439
- [§13.6.1](statements.md#1361-general) General
440440
- [§13.6.2](statements.md#1362-local-variable-declarations) Local variable declarations
441+
- [§13.6.2.1](statements.md#13621-implicitly-typed-local-variable-declarations) Implicitly typed local variable declarations
442+
- [§13.6.2.2](statements.md#13622-explicitly-typed-local-variable-declarations) Explicitly typed local variable declarations
443+
- [§13.6.2.3](statements.md#13623-ref-local-variable-declarations) Ref local variable declarations
441444
- [§13.6.3](statements.md#1363-local-constant-declarations) Local constant declarations
442445
- [§13.6.4](statements.md#1364-local-function-declarations) Local function declarations
443446
- [§13.7](statements.md#137-expression-statements) Expression statements

standard/grammar.md

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,11 @@ declaration_expression
12901290
: local_variable_type identifier
12911291
;
12921292
1293+
local_variable_type
1294+
: type
1295+
| 'var'
1296+
;
1297+
12931298
// Source: §12.18 Conditional operator
12941299
conditional_expression
12951300
: null_coalescing_expression
@@ -1516,30 +1521,52 @@ declaration_statement
15161521
15171522
// Source: §13.6.2 Local variable declarations
15181523
local_variable_declaration
1519-
: ref_kind? local_variable_type local_variable_declarators
1524+
: implicitly_typed_local_variable_declaration
1525+
| explicitly_typed_local_variable_declaration
1526+
| ref_local_variable_declaration
15201527
;
15211528
1522-
local_variable_type
1523-
: type
1524-
| 'var'
1529+
// Source: §13.6.2.1 Implicitly typed local variable declarations
1530+
implicitly_typed_local_variable_declaration
1531+
: 'var' implicitly_typed_local_variable_declarator
1532+
| ref_kind 'var' ref_local_variable_declarator
15251533
;
15261534
1527-
local_variable_declarators
1528-
: local_variable_declarator
1529-
| local_variable_declarators ',' local_variable_declarator
1535+
implicitly_typed_local_variable_declarator
1536+
: identifier '=' expression
15301537
;
15311538
1532-
local_variable_declarator
1533-
: identifier
1534-
| identifier '=' local_variable_initializer
1539+
// Source: §13.6.2.2 Explicitly typed local variable declarations
1540+
explicitly_typed_local_variable_declaration
1541+
: type explicitly_typed_local_variable_declarators
1542+
;
1543+
1544+
explicitly_typed_local_variable_declarators
1545+
: explicitly_typed_local_variable_declarator (',' explicitly_typed_local_variable_declarator)*
1546+
;
1547+
1548+
explicitly_typed_local_variable_declarator
1549+
: identifier ('=' local_variable_initializer)?
15351550
;
15361551
15371552
local_variable_initializer
15381553
: expression
1539-
| 'ref' variable_reference
15401554
| array_initializer
15411555
;
15421556
1557+
// Source: §13.6.2.3 Ref local variable declarations
1558+
ref_local_variable_declaration
1559+
: ref_kind type ref_local_variable_declarators
1560+
;
1561+
1562+
ref_local_variable_declarators
1563+
: ref_local_variable_declarator (',' ref_local_variable_declarator)*
1564+
;
1565+
1566+
ref_local_variable_declarator
1567+
: identifier '=' 'ref' variable_reference
1568+
;
1569+
15431570
// Source: §13.6.3 Local constant declarations
15441571
local_constant_declaration
15451572
: 'const' type constant_declarators
@@ -1631,7 +1658,7 @@ switch_label
16311658
: 'case' pattern case_guard? ':'
16321659
| 'default' ':'
16331660
;
1634-
1661+
16351662
case_guard
16361663
: 'when' expression
16371664
;

standard/statements.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ It is an error to refer to a local variable by name in a textual position that p
351351
352352
The ref-safe-context ([§9.7.2](variables.md#972-ref-safe-contexts)) of a ref local variable is the ref-safe-context of its initializing *variable_reference*. The ref-safe-context of non-ref local variables is *declaration-block*.
353353
354-
#### Implicitly typed local variable declarations
354+
#### 13.6.2.1 Implicitly typed local variable declarations
355355
356356
```ANTLR
357357
implicitly_typed_local_variable_declaration
@@ -405,7 +405,7 @@ An *implicity_typed_local_variable_declaration* introduces a single local variab
405405
>
406406
> *end example*
407407
408-
#### Explicitly typed local variable declarations
408+
#### 13.6.2.2 Explicitly typed local variable declarations
409409
410410
```ANTLR
411411
explicitly_typed_local_variable_declaration
@@ -430,7 +430,7 @@ An *explicity_typed_local_variable_declaration* introduces one or more local var
430430

431431
If a *local_variable_initializer* is present then its type must be appropriate according to the rules of simple assignment ([§12.21.2](expressions.md#12212-simple-assignment)) or array initialization ([§17.7](arrays.md#177-array-initializers)) and its value is assigned as the initial value of the variable.
432432

433-
#### Ref local variable declarations
433+
#### 13.6.2.3 Ref local variable declarations
434434

435435
```ANTLR
436436
ref_local_variable_declaration

0 commit comments

Comments
 (0)