Skip to content

Commit d7ff0e2

Browse files
authored
feat: improved TextMate grammar (#623)
### Summary of Changes Various improvements to the auto-generated TextMate grammar: * Categorization of keywords into correct groups * Description of number literals * Treatment of keywords that are enclosed in backticks as names * Test markers are no longer treated as comments
1 parent 608e470 commit d7ff0e2

File tree

3 files changed

+90
-2
lines changed

3 files changed

+90
-2
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dist/
1212
dist-ssr/
1313
generated/
1414
out/
15-
syntaxes/safe-ds.tmLanguage.json
15+
syntaxes/safe-ds.generated.tmLanguage.json
1616

1717
# Node
1818
.npm/

langium-config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"grammar": "src/language/grammar/safe-ds.langium",
77
"fileExtensions": [".sdspipe", ".sdsstub", ".sdstest"],
88
"textMate": {
9-
"out": "syntaxes/safe-ds.tmLanguage.json"
9+
"out": "syntaxes/safe-ds.generated.tmLanguage.json"
1010
}
1111
}
1212
],

syntaxes/safe-ds.tmLanguage.json

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
"name": "safe-ds",
3+
"scopeName": "source.safe-ds",
4+
"fileTypes": [
5+
".sdspipe",
6+
".sdsstub",
7+
".sdstest"
8+
],
9+
"patterns": [
10+
{
11+
"include": "#comments"
12+
},
13+
{
14+
"name": "constant.numeric.safe-ds",
15+
"match": "\\b([0-9]+(\\.[0-9]+)?([eE][+-]?[0-9]+)?)\\b"
16+
},
17+
{
18+
"name": "constant.language.safe-ds",
19+
"match": "\\b(false|null|true)\\b"
20+
},
21+
{
22+
"name": "storage.type.safe-ds",
23+
"match": "\\b(annotation|attr|class|enum|fun|package|pipeline|schema|segment|val)\\b"
24+
},
25+
{
26+
"name": "storage.modifier.safe-ds",
27+
"match": "\\b(const|in|internal|out|private|static)\\b"
28+
},
29+
{
30+
"name": "keyword.operator.safe-ds",
31+
"match": "\\b(and|not|or|sub|super)\\b"
32+
},
33+
{
34+
"name": "keyword.other.safe-ds",
35+
"match": "\\b(as|from|import|literal|union|where|yield)\\b"
36+
},
37+
{
38+
"name": "entity.name.safe-ds",
39+
"begin": "\\`",
40+
"end": "\\`"
41+
},
42+
{
43+
"name": "string.quoted.double.safe-ds",
44+
"begin": "\"",
45+
"end": "\"",
46+
"patterns": [
47+
{
48+
"include": "#string-character-escape"
49+
}
50+
]
51+
}
52+
],
53+
"repository": {
54+
"comments": {
55+
"patterns": [
56+
{
57+
"name": "comment.line.double-slash.safe-ds",
58+
"begin": "//",
59+
"beginCaptures": {
60+
"1": {
61+
"name": "punctuation.whitespace.comment.leading.safe-ds"
62+
}
63+
},
64+
"end": "(?=$)"
65+
},
66+
{
67+
"name": "comment.block.safe-ds",
68+
"begin": "/\\*",
69+
"beginCaptures": {
70+
"0": {
71+
"name": "punctuation.definition.comment.safe-ds"
72+
}
73+
},
74+
"end": "\\*/",
75+
"endCaptures": {
76+
"0": {
77+
"name": "punctuation.definition.comment.safe-ds"
78+
}
79+
}
80+
}
81+
]
82+
},
83+
"string-character-escape": {
84+
"name": "constant.character.escape.safe-ds",
85+
"match": "\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u\\{[0-9A-Fa-f]+\\}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.|$)"
86+
}
87+
}
88+
}

0 commit comments

Comments
 (0)