Skip to content

Commit cdd1911

Browse files
committed
wip
1 parent bc77c34 commit cdd1911

File tree

6 files changed

+947
-411
lines changed

6 files changed

+947
-411
lines changed

src/typescript/Scala.tmLanguage.ts

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,90 @@ export const scalaTmLanguage: TmLanguage = {
370370
},
371371
name: 'string.quoted.triple.scala'
372372
},
373+
{
374+
end: "'''(?!')",
375+
begin: "'''(?=\\s*\\n)",
376+
beginCaptures: {
377+
'0': {
378+
name: 'punctuation.definition.string.begin.scala'
379+
}
380+
},
381+
patterns: [
382+
{
383+
match: '\\\\\\\\|\\\\u[0-9A-Fa-f]{4}',
384+
name: 'constant.character.escape.scala'
385+
}
386+
],
387+
endCaptures: {
388+
'0': {
389+
name: 'punctuation.definition.string.end.scala'
390+
}
391+
},
392+
name: 'string.quoted.triple.scala'
393+
},
394+
{
395+
end: "''''(?!')",
396+
begin: "''''(?=\\s*\\n)",
397+
beginCaptures: {
398+
'0': {
399+
name: 'punctuation.definition.string.begin.scala'
400+
}
401+
},
402+
patterns: [
403+
{
404+
match: '\\\\\\\\|\\\\u[0-9A-Fa-f]{4}',
405+
name: 'constant.character.escape.scala'
406+
}
407+
],
408+
endCaptures: {
409+
'0': {
410+
name: 'punctuation.definition.string.end.scala'
411+
}
412+
},
413+
name: 'string.quoted.triple.scala'
414+
},
415+
{
416+
end: "'''''(?!')",
417+
begin: "'''''(?=\\s*\\n)",
418+
beginCaptures: {
419+
'0': {
420+
name: 'punctuation.definition.string.begin.scala'
421+
}
422+
},
423+
patterns: [
424+
{
425+
match: '\\\\\\\\|\\\\u[0-9A-Fa-f]{4}',
426+
name: 'constant.character.escape.scala'
427+
}
428+
],
429+
endCaptures: {
430+
'0': {
431+
name: 'punctuation.definition.string.end.scala'
432+
}
433+
},
434+
name: 'string.quoted.triple.scala'
435+
},
436+
{
437+
end: "''''''(?!')",
438+
begin: "''''''(?=\\s*\\n)",
439+
beginCaptures: {
440+
'0': {
441+
name: 'punctuation.definition.string.begin.scala'
442+
}
443+
},
444+
patterns: [
445+
{
446+
match: '\\\\\\\\|\\\\u[0-9A-Fa-f]{4}',
447+
name: 'constant.character.escape.scala'
448+
}
449+
],
450+
endCaptures: {
451+
'0': {
452+
name: 'punctuation.definition.string.end.scala'
453+
}
454+
},
455+
name: 'string.quoted.triple.scala'
456+
},
373457
{
374458
begin: `\\b(raw)(""")`,
375459
end: `(""")(?!")|\\$\n|(\\$[^\\$"_{${letterChars}])`,
@@ -403,6 +487,39 @@ export const scalaTmLanguage: TmLanguage = {
403487
}
404488
}
405489
},
490+
{
491+
begin: `\\b(raw)(''')(?=\\s*\\n)`,
492+
end: `(''')(?!')|\\$\n|(\\$[^\\$'_{${letterChars}])`,
493+
beginCaptures: {
494+
'1': {
495+
name: 'keyword.interpolation.scala'
496+
},
497+
'2': {
498+
name: 'string.quoted.triple.interpolated.scala punctuation.definition.string.begin.scala'
499+
}
500+
},
501+
patterns: [
502+
{
503+
match: "\\$[\\$']",
504+
name: 'constant.character.escape.scala'
505+
},
506+
{
507+
"include": "#string-interpolation"
508+
},
509+
{
510+
match: '.',
511+
name: 'string.quoted.triple.interpolated.scala'
512+
}
513+
],
514+
endCaptures: {
515+
'1': {
516+
name: 'string.quoted.triple.interpolated.scala punctuation.definition.string.end.scala'
517+
},
518+
'2': {
519+
name: 'invalid.illegal.unrecognized-string-escape.scala'
520+
}
521+
}
522+
},
406523
{
407524
begin: `\\b(${interpolatorid})(""")`,
408525
end: `(""")(?!")|\\$\n|(\\$[^\\$"_{${letterChars}])`,
@@ -436,6 +553,39 @@ export const scalaTmLanguage: TmLanguage = {
436553
}
437554
}
438555
},
556+
{
557+
begin: `\\b(${interpolatorid})(''')(?=\\s*\\n)`,
558+
end: `(''')(?!')|\\$\n|(\\$[^\\$'_{${letterChars}])`,
559+
beginCaptures: {
560+
'1': {
561+
name: 'keyword.interpolation.scala'
562+
},
563+
'2': {
564+
name: 'string.quoted.triple.interpolated.scala punctuation.definition.string.begin.scala'
565+
}
566+
},
567+
patterns: [
568+
{
569+
"include": "#string-interpolation"
570+
},
571+
{
572+
match: '\\\\\\\\|\\\\u[0-9A-Fa-f]{4}',
573+
name: 'constant.character.escape.scala'
574+
},
575+
{
576+
match: '.',
577+
name: 'string.quoted.triple.interpolated.scala'
578+
}
579+
],
580+
endCaptures: {
581+
'1': {
582+
name: 'string.quoted.triple.interpolated.scala punctuation.definition.string.end.scala'
583+
},
584+
'2': {
585+
name: 'invalid.illegal.unrecognized-string-escape.scala'
586+
}
587+
}
588+
},
439589
{
440590
end: '"',
441591
begin: '"',

syntaxes/Scala.tmLanguage.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
object DedentedStringLiterals {
2+
3+
// Triple single quote strings
4+
val str1 = '''
5+
Hello
6+
World
7+
'''
8+
9+
// Four single quote strings
10+
val str2 = ''''
11+
Nested
12+
''' quotes
13+
''''
14+
15+
// Five single quote strings
16+
val str3 = '''''
17+
More
18+
'''' quotes
19+
'''''
20+
21+
// Six single quote strings
22+
val str4 = ''''''
23+
Even more
24+
''''' quotes
25+
''''''
26+
27+
// Interpolated triple single quote strings
28+
val name = "World"
29+
val str5 = s'''
30+
Hello $name
31+
'''
32+
33+
// Raw triple single quote strings
34+
val str6 = raw'''
35+
Raw $name content
36+
'''
37+
38+
// Custom interpolated triple single quote strings
39+
val str7 = custom'''
40+
Custom $name content
41+
'''
42+
43+
// Make sure regular strings still work
44+
val regular1 = """
45+
Regular triple quotes
46+
"""
47+
48+
val regular2 = "Regular double quotes"
49+
50+
// Edge case: mismatched delimiters should not close
51+
val str8 = ''''
52+
This has four quotes to open
53+
''' but only three to close, so this should not end the string
54+
This line should still be part of the string
55+
''''
56+
57+
}

0 commit comments

Comments
 (0)