Skip to content

Commit 9c2b2d3

Browse files
committed
Simplify and extract literals
1 parent 93c019e commit 9c2b2d3

File tree

1 file changed

+41
-42
lines changed

1 file changed

+41
-42
lines changed

syntaxes/effekt.tmLanguage.json

Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
{ "include": "#definitions" },
99
{ "include": "#keywords" },
1010
{ "include": "#names" },
11-
{ "include": "#strings" },
12-
{ "include": "#characters" },
13-
{ "include": "#numbers" },
11+
{ "include": "#literals" },
1412
{ "include": "#holes" }
1513
],
1614
"repository": {
@@ -112,46 +110,68 @@
112110
"name": "keyword.control"
113111
}]
114112
},
115-
"names": {
113+
"literals": {
116114
"patterns": [{
117115
"match": "\\b(true|false)\\b",
118-
"name": "constant.language"
116+
"name": "constant.language.boolean.effekt"
119117
}, {
120-
"match": "\\b([a-z][a-zA-Z0-9_]*)\\b[\\s]*[({\\[]",
121-
"captures": {
122-
"1": { "name": "entity.name.function" }
123-
}
118+
"match": "\\b([0-9]+\\.[0-9]+)\\b",
119+
"name": "constant.numeric.float.effekt"
124120
}, {
125-
"match": "\\b[a-z][a-zA-Z0-9_]*\\b",
126-
"name": "variable"
121+
"match": "\\b([0-9]+)\\b",
122+
"name": "constant.numeric.integer.effekt"
127123
}, {
128-
"match": "\\b[A-Z][a-zA-Z0-9_]*\\b",
129-
"name": "entity.name.type"
124+
"include": "#characters"
125+
}, {
126+
"include": "#strings"
127+
}]
128+
},
129+
"characters": {
130+
"name": "string.quoted.single.effekt",
131+
"begin": "'",
132+
"end": "'",
133+
"patterns": [{
134+
"name": "constant.character.escape.effekt",
135+
"match": "\\\\((u[0-9a-fA-F]{4})|.)"
130136
}]
131137
},
132138
"strings": {
133139
"patterns": [{
140+
"name": "string.quoted.triple.effekt",
134141
"begin": "\"\"\"",
135142
"end": "\"\"\"",
136-
"name": "string.quoted.triple.literal",
137143
"patterns": [{
138-
"include": "#stringTemplates"
144+
"name": "constant.character.escape.effekt",
145+
"match": "\\\\((u[0-9a-fA-F]{4})|.)"
139146
}, {
140-
"match": "\\\\.",
141-
"name": "constant.character.escape.effekt"
147+
"include": "#stringTemplates"
142148
}]
143149
}, {
150+
"name": "string.quoted.double.effekt",
144151
"begin": "\"",
145152
"end": "\"",
146-
"name": "string.quoted.double.literal",
147153
"patterns": [{
148-
"include": "#stringTemplates"
154+
"name": "constant.character.escape.effekt",
155+
"match": "\\\\((u[0-9a-fA-F]{4})|.)"
149156
}, {
150-
"match": "\\\\.",
151-
"name": "constant.character.escape.effekt"
157+
"include": "#stringTemplates"
152158
}]
153159
}]
154160
},
161+
"names": {
162+
"patterns": [{
163+
"match": "\\b([a-z][a-zA-Z0-9_]*)\\b[\\s]*[({\\[]",
164+
"captures": {
165+
"1": { "name": "entity.name.function" }
166+
}
167+
}, {
168+
"match": "\\b[a-z][a-zA-Z0-9_]*\\b",
169+
"name": "variable"
170+
}, {
171+
"match": "\\b[A-Z][a-zA-Z0-9_]*\\b",
172+
"name": "entity.name.type"
173+
}]
174+
},
155175
"stringTemplates": {
156176
"begin": "\\$\\{",
157177
"beginCaptures": {
@@ -166,27 +186,6 @@
166186
{ "include": "$self" }
167187
]
168188
},
169-
"characters": {
170-
"patterns": [{
171-
"match": "'(\\\\[nrt\\\\']|[^'\\\\])'",
172-
"name": "string.quoted.single.char.effekt"
173-
}, {
174-
"match": "\\\\u[0-9A-Fa-f]{4}",
175-
"name": "string.quoted.single.char.effekt"
176-
}]
177-
},
178-
"numbers": {
179-
"patterns": [
180-
{
181-
"match": "\\b([0-9]+\\.[0-9]+)\\b",
182-
"name": "constant.numeric.float.effekt"
183-
},
184-
{
185-
"match": "\\b([0-9]+)\\b",
186-
"name": "constant.numeric.integer.effekt"
187-
}
188-
]
189-
},
190189
"punctuation": {
191190
"patterns": [{
192191
"match": "[{}\\(\\)\\[\\];,]",

0 commit comments

Comments
 (0)