-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
source.tl.js
150 lines (148 loc) · 4.64 KB
/
source.tl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.tl'],
names: ['type-language', 'tl'],
patterns: [
{include: '#comments'},
{include: '#triple-statement'},
{include: '#combinator-declaration'}
],
repository: {
'combinator-args': {patterns: [{include: '#combinator-args-member'}]},
'combinator-args-member': {
begin:
'([_$[:alpha:]][_$[:alnum:]]*)(\\:)(([_$[:alpha:]][_$[:alnum:]]*)|(#))',
beginCaptures: {
1: {name: 'meta.definition.combinator.arg.tl variable.other.tl'},
2: {name: 'punctuation.separator.key-value.tl'},
4: {name: 'entity.name.type.tl'},
5: {name: 'keyword.other.hash.tl'}
},
name: 'meta.combinator.arg.tl'
},
'combinator-declaration': {
patterns: [
{include: '#combinator-declaration-with-hash'},
{include: '#combinator-declaration-without-hash'}
]
},
'combinator-declaration-with-hash': {
begin: '(([_$\\w]+)(\\b\\.))?([_$\\w]*)(\\b#)([[:alpha:][:alnum:]]*)\\s*',
beginCaptures: {
2: {name: 'meta.definition.combinator.tl variable.other.tl'},
4: {name: 'meta.definition.combinator.tl variable.other.tl'},
5: {name: 'storage.type.tl'},
6: {name: 'storage.type.tl'}
},
end: '\\;\\s*',
name: 'meta.combinator.declaration.tl',
patterns: [
{match: '\\.', name: 'punctuation.namespace.tl'},
{include: '#keywords'},
{include: '#comments'},
{include: '#combinator-opt-args'},
{include: '#combinator-args'},
{include: '#combinator-result-type'},
{
captures: {1: {name: 'keyword.operator.assignment.tl'}},
match: '(=)\\s*'
}
]
},
'combinator-declaration-without-hash': {
begin: '(([_$\\w]+)(\b\\.))?([_$\\w]*)(?= )',
beginCaptures: {
2: {name: 'meta.definition.combinator.tl variable.other.tl'},
4: {name: 'meta.definition.combinator.tl variable.other.tl'}
},
end: '\\;\\s*',
name: 'meta.combinator.declaration.tl',
patterns: [
{match: '\\.', name: 'punctuation.namespace.tl'},
{include: '#keywords'},
{include: '#comments'},
{include: '#combinator-opt-args'},
{include: '#combinator-args'},
{include: '#combinator-result-type'},
{
captures: {1: {name: 'keyword.operator.assignment.tl'}},
match: '(=)\\s*'
}
]
},
'combinator-opt-args': {
begin: '\\{',
beginCaptures: {0: {name: 'punctuation.definition.block.tl'}},
end: '\\}',
endCaptures: {0: {name: 'punctuation.definition.block.tl'}},
name: 'meta.object.type.tl',
patterns: [{include: '#combinator-args-member'}]
},
'combinator-result-type': {
patterns: [
{
captures: {
1: {name: 'entity.name.type.module.tl'},
2: {name: 'punctuation.accessor.tl'}
},
match: '([_$[:alpha:]][_$[:alnum:]]*)\\s*(\\.)'
},
{match: '[_$[:alpha:]][_$[:alnum:]]*', name: 'entity.name.type.tl'}
]
},
comments: {
patterns: [
{
begin: '/\\*\\*',
captures: {0: {name: 'punctuation.definition.comment.tl'}},
end: '\\*/',
name: 'comment.block.documentation.tl'
},
{
begin: '/\\*',
captures: {0: {name: 'punctuation.definition.comment.tl'}},
end: '\\*/',
name: 'comment.block.tl'
},
{
captures: {1: {name: 'punctuation.definition.comment.tl'}},
match: '(//).*$\\n?',
name: 'comment.line.double-slash.tl'
}
]
},
keywords: {
patterns: [
{match: '\\#', name: 'keyword.other.hash.tl'},
{match: '\\?', name: 'keyword.other.questionmark.tl'},
{match: '\\%', name: 'keyword.other.percent.tl'}
]
},
'triple-statement': {
patterns: [
{
begin: '\\-\\-\\-',
beginCaptures: {0: {name: 'punctuation.triple.open.tl'}},
end: '\\-\\-\\-',
endCaptures: {0: {name: 'punctuation.triple.close.tl'}},
name: 'keyword.control.triple.tl',
patterns: [
{
match: '\\b(types|functions)\\b',
name: 'keyword.control.triple.name.tl'
},
{match: '\\b(.*)\\b', name: 'invalid.illegal'}
]
}
]
}
},
scopeName: 'source.tl'
}
export default grammar