Skip to content

Commit c10ea73

Browse files
[create-pull-request] automated change (#907)
Co-authored-by: jskeet <[email protected]>
1 parent 2a61cf4 commit c10ea73

File tree

2 files changed

+104
-27
lines changed

2 files changed

+104
-27
lines changed

standard/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,8 @@
566566
- [§15.8.4](classes.md#1584-static-and-instance-events) Static and instance events
567567
- [§15.8.5](classes.md#1585-virtual-sealed-override-and-abstract-accessors) Virtual, sealed, override, and abstract accessors
568568
- [§15.9](classes.md#159-indexers) Indexers
569+
- [§15.9.1](classes.md#1591-general) General
570+
- [§15.9.2](classes.md#1592-indexer-and-property-differences) Indexer and Property Differences
569571
- [§15.10](classes.md#1510-operators) Operators
570572
- [§15.10.1](classes.md#15101-general) General
571573
- [§15.10.2](classes.md#15102-unary-operators) Unary operators

standard/grammar.md

Lines changed: 102 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,7 +1516,7 @@ declaration_statement
15161516
15171517
// Source: §13.6.2 Local variable declarations
15181518
local_variable_declaration
1519-
: ('ref' 'readonly'?)? local_variable_type local_variable_declarators
1519+
: ref_kind? local_variable_type local_variable_declarators
15201520
;
15211521
15221522
local_variable_type
@@ -1555,16 +1555,18 @@ constant_declarator
15551555
15561556
// Source: §13.6.4 Local function declarations
15571557
local_function_declaration
1558-
: local_function_header local_function_body
1558+
: local_function_modifier* return_type local_function_header local_function_body
1559+
| ref_kind ref_return_type local_function_header ref_local_function_body
15591560
;
15601561
15611562
local_function_header
1562-
: local_function_modifier* ('ref' 'readonly'?)? return_type identifier type_parameter_list?
1563-
'(' formal_parameter_list? ')' type_parameter_constraints_clause*
1563+
: identifier '(' formal_parameter_list? ')'
1564+
| identifier type_parameter_list '(' formal_parameter_list? ')' type_parameter_constraints_clause*
15641565
;
1566+
15651567
local_function_modifier
15661568
: 'async'
1567-
| 'unsafe'
1569+
| unsafe_modifier // unsafe code support
15681570
;
15691571
15701572
local_function_body
@@ -1573,6 +1575,11 @@ local_function_body
15731575
| '=>' expression ';'
15741576
;
15751577
1578+
ref_local_function_body
1579+
: block
1580+
| '=>' 'ref' variable_reference ';'
1581+
;
1582+
15761583
// Source: §13.7 Expression statements
15771584
expression_statement
15781585
: statement_expression ';'
@@ -1668,7 +1675,7 @@ statement_expression_list
16681675
16691676
// Source: §13.9.5 The foreach statement
16701677
foreach_statement
1671-
: 'foreach' '(' ('ref' 'readonly'?)? local_variable_type identifier 'in'
1678+
: 'foreach' '(' ref_kind? local_variable_type identifier 'in'
16721679
expression ')' embedded_statement
16731680
;
16741681
@@ -1978,16 +1985,35 @@ variable_declarator
19781985
19791986
// Source: §15.6.1 General
19801987
method_declaration
1981-
: method_header method_body
1988+
: attributes? method_modifiers return_type method_header method_body
1989+
| attributes? ref_method_modifiers ref_kind ref_return_type method_header ref_method_body
1990+
;
1991+
1992+
method_modifiers
1993+
: method_modifier* 'partial'?
1994+
;
1995+
1996+
ref_kind
1997+
: 'ref'
1998+
| 'ref' 'readonly'
1999+
;
2000+
2001+
ref_method_modifiers
2002+
: ref_method_modifier*
19822003
;
19832004
19842005
method_header
1985-
: attributes? method_modifier* 'partial'? ('ref' 'readonly'?)?
1986-
return_type member_name type_parameter_list?
1987-
'(' formal_parameter_list? ')' type_parameter_constraints_clause*
2006+
: member_name '(' formal_parameter_list? ')'
2007+
| member_name type_parameter_list '(' formal_parameter_list? ')' type_parameter_constraints_clause*
19882008
;
19892009
19902010
method_modifier
2011+
: ref_method_modifier
2012+
| 'async'
2013+
| unsafe_modifier // unsafe code support
2014+
;
2015+
2016+
ref_method_modifier
19912017
: 'new'
19922018
| 'public'
19932019
| 'protected'
@@ -1999,15 +2025,17 @@ method_modifier
19992025
| 'override'
20002026
| 'abstract'
20012027
| 'extern'
2002-
| 'async'
2003-
| unsafe_modifier // unsafe code support
20042028
;
20052029
20062030
return_type
2007-
: type
2031+
: ref_return_type
20082032
| 'void'
20092033
;
20102034
2035+
ref_return_type
2036+
: type
2037+
;
2038+
20112039
member_name
20122040
: identifier
20132041
| interface_type '.' identifier
@@ -2020,6 +2048,12 @@ method_body
20202048
| ';'
20212049
;
20222050
2051+
ref_method_body
2052+
: block
2053+
| '=>' 'ref' variable_reference ';'
2054+
| ';'
2055+
;
2056+
20232057
// Source: §15.6.2.1 General
20242058
formal_parameter_list
20252059
: fixed_parameters
@@ -2056,8 +2090,8 @@ parameter_array
20562090
20572091
// Source: §15.7.1 General
20582092
property_declaration
2059-
: attributes? property_modifier* ('ref' 'readonly'?)? type
2060-
member_name property_body
2093+
: attributes? property_modifier* type member_name property_body
2094+
| attributes? property_modifier* ref_kind type member_name ref_property_body
20612095
;
20622096
20632097
property_modifier
@@ -2084,6 +2118,11 @@ property_initializer
20842118
: '=' variable_initializer ';'
20852119
;
20862120
2121+
ref_property_body
2122+
: '{' ref_get_accessor_declaration '}'
2123+
| '=>' 'ref' variable_reference ';'
2124+
;
2125+
20872126
// Source: §15.7.3 Accessors
20882127
accessor_declarations
20892128
: get_accessor_declaration set_accessor_declaration?
@@ -2114,6 +2153,16 @@ accessor_body
21142153
| ';'
21152154
;
21162155
2156+
ref_get_accessor_declaration
2157+
: attributes? accessor_modifier? 'get' ref_accessor_body
2158+
;
2159+
2160+
ref_accessor_body
2161+
: block
2162+
| '=>' 'ref' variable_reference ';'
2163+
| ';'
2164+
;
2165+
21172166
// Source: §15.8.1 General
21182167
event_declaration
21192168
: attributes? event_modifier* 'event' type variable_declarators ';'
@@ -2149,9 +2198,10 @@ remove_accessor_declaration
21492198
: attributes? 'remove' block
21502199
;
21512200
2152-
// Source: §15.9 Indexers
2201+
// Source: §15.9.1 General
21532202
indexer_declaration
21542203
: attributes? indexer_modifier* indexer_declarator indexer_body
2204+
| attributes? indexer_modifier* ref_kind indexer_declarator ref_indexer_body
21552205
;
21562206
21572207
indexer_modifier
@@ -2169,15 +2219,20 @@ indexer_modifier
21692219
;
21702220
21712221
indexer_declarator
2172-
: ('ref' 'readonly'?)? type 'this' '[' formal_parameter_list ']'
2173-
| ('ref' 'readonly'?)? type interface_type '.' 'this' '[' formal_parameter_list ']'
2222+
: type 'this' '[' formal_parameter_list ']'
2223+
| type interface_type '.' 'this' '[' formal_parameter_list ']'
21742224
;
21752225
21762226
indexer_body
21772227
: '{' accessor_declarations '}'
21782228
| '=>' expression ';'
21792229
;
21802230
2231+
ref_indexer_body
2232+
: '{' ref_get_accessor_declaration '}'
2233+
| '=>' 'ref' variable_reference ';'
2234+
;
2235+
21812236
// Source: §15.10.1 General
21822237
operator_declaration
21832238
: attributes? operator_modifier+ operator_declarator operator_body
@@ -2404,32 +2459,43 @@ interface_member_declaration
24042459
24052460
// Source: §18.4.2 Interface methods
24062461
interface_method_declaration
2407-
: attributes? 'new'? return_type identifier type_parameter_list?
2408-
'(' formal_parameter_list? ')' type_parameter_constraints_clause* ';'
2462+
: attributes? 'new'? return_type interface_method_header
2463+
| attributes? 'new'? ref_kind ref_return_type interface_method_header
2464+
;
2465+
2466+
interface_method_header
2467+
: identifier '(' formal_parameter_list? ')' ';'
2468+
| identifier type_parameter_list '(' formal_parameter_list? ')' type_parameter_constraints_clause* ';'
24092469
;
24102470
24112471
// Source: §18.4.3 Interface properties
24122472
interface_property_declaration
24132473
: attributes? 'new'? type identifier '{' interface_accessors '}'
2474+
| attributes? 'new'? ref_kind type identifier '{' ref_interface_accessor '}'
24142475
;
24152476
2416-
// Source: §18.4.3 Interface properties
24172477
interface_accessors
24182478
: attributes? 'get' ';'
24192479
| attributes? 'set' ';'
24202480
| attributes? 'get' ';' attributes? 'set' ';'
24212481
| attributes? 'set' ';' attributes? 'get' ';'
24222482
;
24232483
2484+
ref_interface_accessor
2485+
: attributes? 'get' ';'
2486+
;
2487+
24242488
// Source: §18.4.4 Interface events
24252489
interface_event_declaration
24262490
: attributes? 'new'? 'event' type identifier ';'
24272491
;
24282492
24292493
// Source: §18.4.5 Interface indexers
2430-
interface_indexer_declaration:
2431-
attributes? 'new'? type 'this' '[' formal_parameter_list ']'
2432-
'{' interface_accessors '}'
2494+
interface_indexer_declaration
2495+
: attributes? 'new'? type 'this' '[' formal_parameter_list ']'
2496+
'{' interface_accessors '}'
2497+
| attributes? 'new'? ref_kind type 'this' '[' formal_parameter_list ']'
2498+
'{' ref_interface_accessor '}'
24332499
;
24342500
24352501
// Source: §19.2 Enum declarations
@@ -2472,17 +2538,26 @@ enum_member_declaration
24722538
24732539
// Source: §20.2 Delegate declarations
24742540
delegate_declaration
2475-
: attributes? delegate_modifier* 'delegate' ('ref' 'readonly'?)? return_type identifier variant_type_parameter_list?
2476-
'(' formal_parameter_list? ')' type_parameter_constraints_clause* ';'
2541+
: attributes? delegate_modifier* 'delegate' return_type delegate_header
2542+
| attributes? ref_delegate_modifier* 'delegate' ref_kind ref_return_type delegate_header
2543+
;
2544+
2545+
delegate_header
2546+
: identifier '(' formal_parameter_list? ')' ';'
2547+
| identifier variant_type_parameter_list '(' formal_parameter_list? ')' type_parameter_constraints_clause* ';'
24772548
;
24782549
24792550
delegate_modifier
2551+
: ref_delegate_modifier
2552+
| unsafe_modifier // unsafe code support
2553+
;
2554+
2555+
ref_delegate_modifier
24802556
: 'new'
24812557
| 'public'
24822558
| 'protected'
24832559
| 'internal'
24842560
| 'private'
2485-
| unsafe_modifier // unsafe code support
24862561
;
24872562
24882563
// Source: §22.3 Attribute specification

0 commit comments

Comments
 (0)