Skip to content

Commit 6f82f13

Browse files
ntreldlang-bot
authored andcommitted
[spec] Introduce template instance grammar
Split out the template argument grammar (unchanged).
1 parent 9de265a commit 6f82f13

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

spec/template.dd

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ $(H2 $(LNAME2 template_instantiation, Template Instantiation))
7878

7979
$(H3 $(LNAME2 explicit_tmp_instantiation, Explicit Template Instantiation))
8080

81-
$(P Templates are explicitly instantiated with:
82-
)
81+
$(P Templates are explicitly instantiated using a `!` after the
82+
template name, then either an argument list or a single token
83+
argument.)
8384

8485
$(GRAMMAR
8586
$(GNAME TemplateInstance):
@@ -94,6 +95,24 @@ $(GNAME TemplateArgumentList):
9495
$(GLINK TemplateArgument) $(D ,)
9596
$(GLINK TemplateArgument) $(D ,) $(GSELF TemplateArgumentList)
9697

98+
$(GNAME TemplateSingleArgument):
99+
$(GLINK_LEX Identifier)
100+
$(GLINK2 type, FundamentalType)
101+
$(GLINK_LEX CharacterLiteral)
102+
$(GLINK_LEX StringLiteral)
103+
$(GLINK_LEX IntegerLiteral)
104+
$(GLINK_LEX FloatLiteral)
105+
$(D true)
106+
$(D false)
107+
$(D null)
108+
$(D this)
109+
$(GLINK2 expression, SpecialKeyword)
110+
)
111+
112+
$(P A template argument can be a type, compile-time expression
113+
or a symbol.)
114+
115+
$(GRAMMAR
97116
$(GNAME TemplateArgument):
98117
$(GLINK2 type, Type)
99118
$(ASSIGNEXPRESSION)
@@ -108,19 +127,6 @@ $(GNAME SymbolTail):
108127
$(GLINK_LEX Identifier) $(D .) $(GSELF SymbolTail)
109128
$(GLINK TemplateInstance)
110129
$(GLINK TemplateInstance) $(D .) $(GSELF SymbolTail)
111-
112-
$(GNAME TemplateSingleArgument):
113-
$(GLINK_LEX Identifier)
114-
$(GLINK2 type, FundamentalType)
115-
$(GLINK_LEX CharacterLiteral)
116-
$(GLINK_LEX StringLiteral)
117-
$(GLINK_LEX IntegerLiteral)
118-
$(GLINK_LEX FloatLiteral)
119-
$(D true)
120-
$(D false)
121-
$(D null)
122-
$(D this)
123-
$(GLINK2 expression, SpecialKeyword)
124130
)
125131

126132
$(P Once instantiated, the declarations inside the template, called

0 commit comments

Comments
 (0)