Skip to content

Commit 126539a

Browse files
committed
Move ArrayInitializer grammar to ArrayLiteral in expression.dd
ArrayInitializer is not referenced anywhere else. ArrayLiteral grammar was wrong. Tweak wording of array literal description.
1 parent 24b64d4 commit 126539a

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

spec/declaration.dd

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,12 @@ $(GNAME Initializer):
104104

105105
$(GNAME NonVoidInitializer):
106106
$(GLINK2 expression, AssignExpression)$(LEGACY_LNAME2 ExpInitializer)
107-
$(GLINK ArrayInitializer)
107+
$(GLINK2 expression, ArrayLiteral)$(LEGACY_LNAME2 ArrayInitializer)
108108
$(GLINK2 struct, StructInitializer)$(LEGACY_LNAME2 StructInitializer)
109-
110-
$(GNAME ArrayInitializer):
111-
$(D [) $(GLINK ArrayMemberInitializations)$(OPT) $(D ])
112-
113-
$(GNAME ArrayMemberInitializations):
114-
$(GLINK ArrayMemberInitialization)
115-
$(GLINK ArrayMemberInitialization) $(D ,)
116-
$(GLINK ArrayMemberInitialization) $(D ,) $(GSELF ArrayMemberInitializations)
117-
118-
$(GNAME ArrayMemberInitialization):
119-
$(GLINK NonVoidInitializer)
120-
$(GLINK2 expression, AssignExpression) $(D :) $(GLINK NonVoidInitializer)
121109
)
122110

111+
$(P See also $(GLINK VoidInitializer).)
112+
123113
$(H2 $(LNAME2 declaration_syntax, Declaration Syntax))
124114

125115
$(P Declaration syntax generally reads right to left, including arrays:)

spec/expression.dd

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,15 +1690,24 @@ $(H3 $(LNAME2 array_literals, Array Literals))
16901690

16911691
$(GRAMMAR
16921692
$(GNAME ArrayLiteral):
1693-
$(D [) $(GLINK ArgumentList)$(OPT) $(D ])
1693+
$(D [) $(I ArrayMemberInitializations)$(OPT) $(D ])
1694+
1695+
$(GNAME ArrayMemberInitializations):
1696+
$(I ArrayMemberInitialization)
1697+
$(I ArrayMemberInitialization) $(D ,)
1698+
$(I ArrayMemberInitialization) $(D ,) $(GSELF ArrayMemberInitializations)
1699+
1700+
$(GNAME ArrayMemberInitialization):
1701+
$(GLINK2 declaration, NonVoidInitializer)
1702+
$(GLINK AssignExpression) $(D :) $(GLINK2 declaration, NonVoidInitializer)
16941703
)
16951704

1696-
$(P Array literals are a comma-separated list of $(GLINK AssignExpression)s
1705+
$(P Array literals are a comma-separated list of expressions
16971706
between square brackets $(D [) and $(D ]).
1698-
The $(I AssignExpression)s form the elements of a dynamic array,
1699-
the length of the array is the number of elements.
1700-
The common type of the all elements is taken to be the type of
1701-
the array element, and all elements are implicitly converted
1707+
The expressions form the elements of a dynamic array.
1708+
The length of the array is the number of elements.
1709+
The common type of all the elements is taken to be the
1710+
array element type, and each expression is implicitly converted
17021711
to that type.)
17031712

17041713
---
@@ -1739,9 +1748,10 @@ $(GNAME ArrayLiteral):
17391748
-------------
17401749
)
17411750

1742-
$(P If any of the arguments in the $(GLINK ArgumentList) are
1743-
a $(I ValueSeq), then the elements of the $(I ValueSeq)
1744-
are inserted as arguments in place of the sequence.
1751+
$(P If any $(I ArrayMemberInitialization) is a
1752+
$(DDSUBLINK spec/template, TemplateParameterSequence, ValueSeq),
1753+
then the elements of the $(I ValueSeq)
1754+
are inserted as expressions in place of the sequence.
17451755
)
17461756

17471757
$(P Escaping array literals are allocated on the memory managed heap.

0 commit comments

Comments
 (0)