@@ -10,49 +10,97 @@ string, but can contain values that are passed directly to a function that is
10
10
able to accept them. It is transformed into a $(I Sequence) of expressions that
11
11
can be overloaded or handled by template functions.)
12
12
13
+ $(H2 $(LNAME2 ies, IES Literals))
14
+
13
15
$(GRAMMAR
14
16
$(GNAME InterpolationExpressionSequence):
17
+ $(GLINK InterpolatedDoubleQuotedLiteral)
18
+ $(GLINK InterpolatedWysiwygLiteral)
19
+ $(GLINK InterpolatedTokenLiteral)
20
+ )
21
+
22
+ $(P An Interpolation Expression sequence can either wysiwyg quoted, double
23
+ quoted, or a token literal. Only double quoted literals can have escapes in
24
+ them.)
25
+
26
+ $(P Unlike string literals, IES literals cannot have a suffix defining the
27
+ width of the character type for the string expressions.)
28
+
29
+ $(H3 $(LNAME2 ies_doublequoted, Double Quoted IES Literals))
30
+
31
+ $(GRAMMAR
32
+ $(GNAME InterpolatedDoubleQuotedLiteral):
15
33
$(B i") $(GLINK InterpolatedDoubleQuotedCharacters)$(OPT) $(B ")
16
- $(B $(BACKTICK)) $(GLINK InterpolatedWysiwygCharacters)$(OPT) $(B $(BACKTICK))
17
- $(D q{) $(GLINK InterpolatedTokenStringTokens)$(OPT) $(D })
18
34
19
35
$(GNAME InterpolatedDoubleQuotedCharacters):
20
36
$(GLINK InterpolatedDoubleQuotedCharacter)
21
37
$(GLINK InterpolatedDoubleQuotedCharacter) $(GSELF InterpolatedDoubleQuotedCharacters)
22
38
23
39
$(GNAME InterpolatedDoubleQuotedCharacter):
24
- $(GLINK DoubleQuotedCharacter)
40
+ $(GLINK2 lexical, DoubleQuotedCharacter)
25
41
$(GLINK InterpolationEscapeSequence)
26
42
$(GLINK InterpolationExpression)
27
43
28
44
$(GNAME InterpolationEscapeSequence):
29
45
$(GLINK EscapeSequence)
30
46
$(B \\\$)
31
47
48
+ $(GNAME InterpolationExpression):
49
+ $(B \$$(LPAREN)) $(GLINK AssignExpression) $(B $(RPAREN))
50
+ )
51
+
52
+ $(P Like $(GLINK2 lexical, DoubleQuotedString), double-quoted IES literals can
53
+ have escape characters in them. Added to the normal escapes is the ability to
54
+ escape a literal $)
55
+
56
+ $(P A $ followed by any other chraracter other than a left parenthesis is
57
+ treated as a literal $ in the expression, there is no need to escape it.)
58
+
59
+ $(P The expression inside an $(GLINK InterpolationExpression) is a full D
60
+ expression, and escapes are not needed inside that part of the expression.)
61
+
62
+ $(H3 $(LNAME2 ies_wysiwyg, Wysiwyg IES Literals))
63
+
64
+ $(GRAMMAR
65
+ $(GNAME InterpolatedWysiwygLiteral):
66
+ $(B i$(BACKTICK)) $(GLINK InterpolatedWysiwygCharacters)$(OPT) $(B $(BACKTICK))
67
+
32
68
$(GNAME InterpolatedWysiwygCharacters):
33
69
$(GLINK InterpolatedWysiwygCharacter)
34
70
$(GLINK InterpolatedWysiwygCharacter) $(GSELF InterpolatedWysiwygCharacters)
35
71
36
72
$(GNAME InterpolatedWysiwygCharacter):
37
- $(GLINK WysiwygCharacter)
73
+ $(GLINK2 lexical, WysiwygCharacter)
38
74
$(GLINK InterpolationExpression)
75
+ )
76
+
77
+ $(P Wysiwyg ("what you see is what you get") IES literals are defined like
78
+ $(GLINK2 lexical, WysiwygString) strings, but only support backquote syntax. No
79
+ escapes are recognized inside these literals.)
80
+
81
+ $(H3 $(LNAME2 ies_token, Token IES Literals))
82
+
83
+ $(GRAMMAR
84
+ $(GNAME InterpolatedTokenLiteral):
85
+ $(D iq{) $(GLINK InterpolatedTokenStringTokens)$(OPT) $(D })
39
86
40
87
$(GNAME InterpolatedTokenStringTokens):
41
88
$(GLINK InterpolatedTokenStringTokenNoBraces)
42
89
$(GLINK InterpolatedTokenStringToken) $(GSELF InterpolatedTokenStringTokens)
43
90
44
91
$(GNAME InterpolatedTokenStringToken):
45
92
$(GLINK InterpolatedTokenNoBraces)
46
- (D {) $(GSELF InterpolatedTokenStringTokens)$(OPT) $(D })
93
+ $(B {) $(GSELF InterpolatedTokenStringTokens)$(OPT) $(B })
47
94
48
95
$(GNAME InterpolatedTokenNoBraces):
49
- $(GLINK TokenNoBraces)
50
- $(GLINK InterpolationExpression);
51
-
52
- $(GNAME InterpolationExpression):
53
- $(B $ (LPAREN)) $(GLINK AssignExpression) $(B $(RPAREN))
96
+ $(GLINK2 lexical, TokenNoBraces)
97
+ $(GLINK InterpolationExpression)
54
98
)
55
99
100
+ $(P Like $(GLINK2 lexical, TokenString), IES Token literals must contain only
101
+ valid D tokens, with the exception of $(GLINK InterpolationExpression). No
102
+ escapes are recognized.)
103
+
56
104
$(H2 $(LNAME2 expression_translation, Expression Translation))
57
105
58
106
$(P When the lexer encounters an Interpolation Expression Sequence, the token
@@ -64,7 +112,7 @@ $(D core.interpolation.InterpolationFooter()))
64
112
$(P Each part $(D str) of the token which is literal string data is translated
65
113
into the expression $(D core.interpolation.InterpolatedLiteral!(str)))
66
114
67
- $(P Each part $(D $$(LPAREN)expr$(RPAREN)) of the token which is an $(GLINK
115
+ $(P Each part $(D \ $$(LPAREN)expr$(RPAREN)) of the token which is an $(GLINK
68
116
InterpolationExpression) is translated into the sequence $(D
69
117
core.interpolation.InterpolatedExpression!(expr)$(COMMA) expr).)
70
118
@@ -154,7 +202,7 @@ alias result = processIES!i"Here is a type: $(int)";
154
202
$(H2 $(LNAME2 tostring, Converting to a String))
155
203
156
204
$(P In many cases, it is desirable to convert an IES to a $(D string). The
157
- Phobos function $(D std.conv.text ) can convert the IES to a $(D string) for use
205
+ Phobos function $(REF text, std.conv) can convert the IES to a $(D string) for use
158
206
in any context where a string is needed, for instance to assign to a string
159
207
variable, or call a function that accepts a string.)
160
208
@@ -177,4 +225,4 @@ $(SPEC_SUBNAV_PREV_NEXT lex, Lexical, grammar, Grammar)
177
225
178
226
Macros:
179
227
CHAPTER = 3
180
- TITLE = Interpolation Expression Sequences
228
+ TITLE = Interpolation Expression Sequence
0 commit comments