Skip to content

Commit 71992a1

Browse files
committed
Support interpolated string syntax highlighting
Fix #496
1 parent 3c8c798 commit 71992a1

File tree

2 files changed

+143
-0
lines changed

2 files changed

+143
-0
lines changed

syntaxes/d.json

+95
Original file line numberDiff line numberDiff line change
@@ -2325,6 +2325,15 @@
23252325
},
23262326
{
23272327
"include": "#token-string"
2328+
},
2329+
{
2330+
"include": "#ies-string"
2331+
},
2332+
{
2333+
"include": "#ies-wysiwyg-string"
2334+
},
2335+
{
2336+
"include": "#ies-token-string"
23282337
}
23292338
]
23302339
},
@@ -2356,6 +2365,26 @@
23562365
}
23572366
]
23582367
},
2368+
"ies-wysiwyg-string": {
2369+
"patterns": [
2370+
{
2371+
"begin": "i`",
2372+
"end": "`[cwd]?",
2373+
"name": "string.ies-wysiwyg-string.d",
2374+
"patterns": [
2375+
{
2376+
"include": "#interpolation-escape"
2377+
},
2378+
{
2379+
"include": "#interpolation-sequence"
2380+
},
2381+
{
2382+
"include": "#wysiwyg-characters"
2383+
}
2384+
]
2385+
}
2386+
]
2387+
},
23592388
"double-quoted-string": {
23602389
"patterns": [
23612390
{
@@ -2370,6 +2399,26 @@
23702399
}
23712400
]
23722401
},
2402+
"ies-string": {
2403+
"patterns": [
2404+
{
2405+
"begin": "i\"",
2406+
"end": "\"[cwd]?",
2407+
"name": "string.ies-string.d",
2408+
"patterns": [
2409+
{
2410+
"include": "#interpolation-escape"
2411+
},
2412+
{
2413+
"include": "#interpolation-sequence"
2414+
},
2415+
{
2416+
"include": "#double-quoted-characters"
2417+
}
2418+
]
2419+
}
2420+
]
2421+
},
23732422
"hex-string": {
23742423
"patterns": [
23752424
{
@@ -2415,6 +2464,28 @@
24152464
}
24162465
]
24172466
},
2467+
"ies-token-string": {
2468+
"begin": "iq\\{",
2469+
"end": "\\}[cdw]?",
2470+
"beginCaptures": {
2471+
"0": {
2472+
"name": "string.quoted.token.d"
2473+
}
2474+
},
2475+
"endCaptures": {
2476+
"0": {
2477+
"name": "string.quoted.token.d"
2478+
}
2479+
},
2480+
"patterns": [
2481+
{
2482+
"include": "#interpolation-sequence"
2483+
},
2484+
{
2485+
"include": "#token-string-content"
2486+
}
2487+
]
2488+
},
24182489
"token-string": {
24192490
"begin": "q\\{",
24202491
"end": "\\}[cdw]?",
@@ -2476,6 +2547,30 @@
24762547
}
24772548
]
24782549
},
2550+
"interpolation-escape": {
2551+
"match": "\\\\\\$",
2552+
"name": "constant.character.escape-sequence.d"
2553+
},
2554+
"interpolation-sequence": {
2555+
"begin": "\\$\\(",
2556+
"end": "\\)",
2557+
"name": "meta.interpolation.expression.d",
2558+
"beginCaptures": {
2559+
"0": {
2560+
"name": "punctuation.definition.template-expression.begin.d"
2561+
}
2562+
},
2563+
"endCaptures": {
2564+
"0": {
2565+
"name": "punctuation.definition.template-expression.end.d"
2566+
}
2567+
},
2568+
"patterns": [
2569+
{
2570+
"include": "#expression"
2571+
}
2572+
]
2573+
},
24792574
"delimited-string-braces": {
24802575
"patterns": [
24812576
{

syntaxes/d.yml

+48
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,9 @@ repository:
10911091
- include: '#delimited-string'
10921092
- include: '#double-quoted-string'
10931093
- include: '#token-string'
1094+
- include: '#ies-string'
1095+
- include: '#ies-wysiwyg-string'
1096+
- include: '#ies-token-string'
10941097
wysiwyg-string:
10951098
patterns:
10961099
- begin: r\"
@@ -1105,13 +1108,31 @@ repository:
11051108
name: string.alternate-wysiwyg-string.d
11061109
patterns:
11071110
- include: '#wysiwyg-characters'
1111+
ies-wysiwyg-string:
1112+
patterns:
1113+
- begin: 'i`'
1114+
end: '`[cwd]?'
1115+
name: string.ies-wysiwyg-string.d
1116+
patterns:
1117+
- include: '#interpolation-escape'
1118+
- include: '#interpolation-sequence'
1119+
- include: '#wysiwyg-characters'
11081120
double-quoted-string:
11091121
patterns:
11101122
- begin: '"'
11111123
end: '"[cwd]?'
11121124
name: string.double-quoted-string.d
11131125
patterns:
11141126
- include: '#double-quoted-characters'
1127+
ies-string:
1128+
patterns:
1129+
- begin: 'i"'
1130+
end: '"[cwd]?'
1131+
name: string.ies-string.d
1132+
patterns:
1133+
- include: '#interpolation-escape'
1134+
- include: '#interpolation-sequence'
1135+
- include: '#double-quoted-characters'
11151136
hex-string:
11161137
patterns:
11171138
- begin: x"
@@ -1136,6 +1157,18 @@ repository:
11361157
- include: '#delimited-string-parens'
11371158
- include: '#delimited-string-angle-brackets'
11381159
- include: '#delimited-string-braces'
1160+
ies-token-string:
1161+
begin: iq\{
1162+
end: \}[cdw]?
1163+
beginCaptures:
1164+
0:
1165+
name: string.quoted.token.d
1166+
endCaptures:
1167+
0:
1168+
name: string.quoted.token.d
1169+
patterns:
1170+
- include: '#interpolation-sequence'
1171+
- include: '#token-string-content'
11391172
token-string:
11401173
begin: q\{
11411174
end: \}[cdw]?
@@ -1168,6 +1201,21 @@ repository:
11681201
name: constant.character.angle-brackets.d
11691202
patterns:
11701203
- include: '#wysiwyg-characters'
1204+
interpolation-escape:
1205+
match: \\\$
1206+
name: constant.character.escape-sequence.d
1207+
interpolation-sequence:
1208+
begin: \$\(
1209+
end: \)
1210+
name: meta.interpolation.expression.d
1211+
beginCaptures:
1212+
0:
1213+
name: punctuation.definition.template-expression.begin.d
1214+
endCaptures:
1215+
0:
1216+
name: punctuation.definition.template-expression.end.d
1217+
patterns:
1218+
- include: '#expression'
11711219
delimited-string-braces:
11721220
patterns:
11731221
- begin: \{

0 commit comments

Comments
 (0)