Skip to content

Commit dd9c375

Browse files
committed
Clean up textmate grammar.
Clean up keywords, and remove variant constructors and module access, which are handled at the semantic level.
1 parent 615fb96 commit dd9c375

File tree

1 file changed

+6
-116
lines changed

1 file changed

+6
-116
lines changed

grammars/rescript.tmLanguage.json

Lines changed: 6 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,9 @@
33
"name": "ReScript",
44
"scopeName": "source.rescript",
55
"repository": {
6-
"RE_IDENT": {
7-
"match": "[a-z_][0-9a-zA-Z_]*"
8-
},
9-
"RE_ATTRIBUTE": {
10-
"match": "[A-Za-z_][A-Za-z0-9_\\.]*"
11-
},
12-
"RE_MODULE_IDENT": {
13-
"name": "entity.name.namespace",
14-
"match": "[A-Z_][0-9a-zA-Z_]*"
15-
},
16-
"RE_KEYWORDS": {
6+
"RE_KEYWORD_CONTROL": {
177
"name": "keyword.control",
18-
"match": "\\b(and|as|assert|constraint|downto|else|exception|external|for|if|in|include|lazy|module|mutable|of|open|rec|switch|to|try|type|when|while|with)\\b"
8+
"match": "\\b(and|as|assert|constraint|downto|else|exception|external|for|if|in|lazy|mutable|rec|switch|to|try|when|while|with)\\b"
199
},
2010
"RE_TO_DOWNTO_AS_LABELS": {
2111
"patterns": [
@@ -47,9 +37,9 @@
4737
"name": "constant.language.boolean",
4838
"match": "\\b(false|true)\\b"
4939
},
50-
"RE_LET": {
40+
"RE_KEYWORD": {
5141
"name": "keyword",
52-
"match": "\\b(let)\\b"
42+
"match": "\\b(include|let|module|of|open|type)\\b"
5343
},
5444
"commentLine": {
5545
"match": "//.*",
@@ -109,24 +99,16 @@
10999
}
110100
]
111101
},
112-
"storage": {
113-
"patterns": [
114-
{
115-
"match": "\\btype\\b",
116-
"name": "storage.type"
117-
}
118-
]
119-
},
120102
"keyword": {
121103
"patterns": [
122104
{
123105
"include": "#RE_TO_DOWNTO_AS_LABELS"
124106
},
125107
{
126-
"include": "#RE_KEYWORDS"
108+
"include": "#RE_KEYWORD_CONTROL"
127109
},
128110
{
129-
"include": "#RE_LET"
111+
"include": "#RE_KEYWORD"
130112
}
131113
]
132114
},
@@ -265,10 +247,6 @@
265247
},
266248
"constructor": {
267249
"patterns": [
268-
{
269-
"match": "\\b[A-Z][0-9a-zA-Z_]*\\b",
270-
"name": "variable.function variable.other"
271-
},
272250
{
273251
"match": "(#)\\s*([a-zA-Z][0-9a-zA-Z_]*)\\b",
274252
"captures": {
@@ -374,94 +352,6 @@
374352
"jsx": {
375353
"match": "<>|</>|</|/>",
376354
"name": "punctuation.definition.tag"
377-
},
378-
"openOrIncludeModule": {
379-
"patterns": [
380-
{
381-
"match": "\\b(open|include)\\s+([A-Z_][0-9a-zA-Z_]*((\\.)([A-Z_][0-9a-zA-Z_]*))*)",
382-
"captures": {
383-
"1": {
384-
"name": "keyword"
385-
},
386-
"2": {
387-
"patterns": [
388-
{
389-
"include": "#moduleAccessEndsWithModule"
390-
}
391-
]
392-
}
393-
}
394-
},
395-
{
396-
"match": "\\b(open|include)\\s+",
397-
"name": "keyword"
398-
}
399-
]
400-
},
401-
"moduleAccessEndsWithModule": {
402-
"patterns": [
403-
{
404-
"match": "[A-Z_][0-9a-zA-Z_]*",
405-
"name": "entity.name.namespace"
406-
},
407-
{
408-
"match": "(\\.)([A-Z_][0-9a-zA-Z_]*)",
409-
"captures": {
410-
"1": {
411-
"name": "punctuation.accessor"
412-
},
413-
"2": {
414-
"name": "entity.name.namespace"
415-
}
416-
}
417-
}
418-
]
419-
},
420-
"moduleAccess": {
421-
"patterns": [
422-
{
423-
"match": "\\b([A-Z_][0-9a-zA-Z_]*)(\\.)",
424-
"captures": {
425-
"1": {
426-
"name": "entity.name.namespace"
427-
},
428-
"2": {
429-
"name": "punctuation.accessor"
430-
}
431-
}
432-
}
433-
]
434-
},
435-
"moduleDeclaration": {
436-
"patterns": [
437-
{
438-
"match": "\\b(module)\\s+(type\\s+)?(of\\s+)?([A-Z_][0-9a-zA-Z_]*)",
439-
"captures": {
440-
"1": {
441-
"name": "keyword"
442-
},
443-
"2": {
444-
"name": "keyword"
445-
},
446-
"3": {
447-
"name": "keyword"
448-
},
449-
"4": {
450-
"name": "entity.name.namespace"
451-
}
452-
},
453-
"patterns": [
454-
{
455-
"match": "\\s*:\\s*([A-Z_][0-9a-zA-Z_]*)",
456-
"captures": {
457-
"1": {
458-
"name": "entity.name.namespace"
459-
}
460-
}
461-
}
462-
]
463-
}
464-
]
465355
}
466356
},
467357
"patterns": [

0 commit comments

Comments
 (0)