/
source.elm.js
213 lines (212 loc) · 7.16 KB
/
source.elm.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/elm-community/Elm.tmLanguage>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.elm'],
names: ['elm'],
patterns: [
{
captures: {
1: {name: 'punctuation.definition.entity.elm'},
2: {name: 'punctuation.definition.entity.elm'}
},
match: "(`)[a-zA-Z_']*?(`)",
name: 'keyword.operator.function.infix.elm'
},
{match: '\\(\\)', name: 'constant.language.unit.elm'},
{
begin: '^\\b((effect|port)\\s+)?(module)\\s+',
beginCaptures: {
1: {name: 'keyword.other.elm'},
3: {name: 'keyword.other.elm'}
},
end: '$|;',
endCaptures: {1: {name: 'keyword.other.elm'}},
name: 'meta.declaration.module.elm',
patterns: [
{include: '#module_name'},
{
begin: '(where)\\s*\\{',
beginCaptures: {1: {name: 'keyword.other.elm'}},
end: '\\}',
patterns: [{include: '#type_signature'}]
},
{match: '(exposing)', name: 'keyword.other.elm'},
{include: '#module_exports'},
{match: '(where)', name: 'keyword.other.elm'},
{match: '[a-z]+', name: 'invalid'}
]
},
{
begin: '^\\b(import)\\s+((open)\\s+)?',
beginCaptures: {1: {name: 'keyword.other.elm'}, 3: {name: 'invalid'}},
end: '($|;)',
name: 'meta.import.elm',
patterns: [
{match: '(as|exposing)', name: 'keyword.import.elm'},
{include: '#module_name'},
{include: '#module_exports'}
]
},
{
begin: '(\\[)(glsl)(\\|)',
beginCaptures: {
1: {name: 'keyword.other.elm'},
2: {name: 'support.function.prelude.elm'},
3: {name: 'keyword.other.elm'}
},
end: '(\\|\\])',
endCaptures: {1: {name: 'keyword.other.elm'}},
name: 'entity.glsl.elm',
patterns: [{include: 'source.glsl'}]
},
{
match: '\\b(type alias|type|case|of|let|in|as)\\s+',
name: 'keyword.other.elm'
},
{match: '\\b(if|then|else)\\s+', name: 'keyword.control.elm'},
{
match: '\\b([0-9]+\\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\\b',
name: 'constant.numeric.float.elm'
},
{match: '\\b([0-9]+)\\b', name: 'constant.numeric.elm'},
{
begin: '"""',
beginCaptures: {0: {name: 'punctuation.definition.string.begin.elm'}},
end: '"""',
endCaptures: {0: {name: 'punctuation.definition.string.end.elm'}},
name: 'string.quoted.double.elm',
patterns: [
{
match:
"\\\\(NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|[abfnrtv\\\\'\\&])",
name: 'constant.character.escape.elm'
},
{
match: '\\^[A-Z@\\[\\]\\\\\\^_]',
name: 'constant.character.escape.control.elm'
}
]
},
{
begin: '"',
beginCaptures: {0: {name: 'punctuation.definition.string.begin.elm'}},
end: '"',
endCaptures: {0: {name: 'punctuation.definition.string.end.elm'}},
name: 'string.quoted.double.elm',
patterns: [
{
match:
'\\\\(NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|[abfnrtv\\\\\\"\'\\&])',
name: 'constant.character.escape.elm'
},
{
match: '\\^[A-Z@\\[\\]\\\\\\^_]',
name: 'constant.character.escape.control.elm'
}
]
},
{
captures: {
1: {name: 'punctuation.definition.string.begin.elm'},
2: {name: 'constant.character.escape.elm'},
3: {name: 'punctuation.definition.string.end.elm'}
},
match:
"(?x)\n(')\n(?:\n\t[\\ -\\[\\]-~]\t\t\t\t\t\t\t\t# Basic Char\n | (\\\\(?:NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE\n\t\t|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS\n\t\t|US|SP|DEL|[abfnrtv\\\\\\\"'\\&]))\t\t# Escapes\n | (\\^[A-Z@\\[\\]\\\\\\^_])\t\t\t\t\t\t# Control Chars\n)\n(')",
name: 'string.quoted.single.elm'
},
{
begin:
"^(port\\s+)?([a-z_][a-zA-Z0-9_']*|\\([|!%$+\\-.,=</>]+\\))\\s*((:)([:]+)?)",
beginCaptures: {
1: {name: 'keyword.other.port.elm'},
2: {name: 'entity.name.function.elm'},
4: {name: 'keyword.other.colon.elm'},
5: {name: 'invalid'}
},
end: '$\\n?',
name: 'meta.function.type-declaration.elm',
patterns: [{include: '#type_signature'}]
},
{match: '\\bport\\s+', name: 'keyword.other.port.elm'},
{match: '\\b[A-Z]\\w*\\b', name: 'constant.other.elm'},
{include: '#comments'},
{match: "^[a-z][A-Za-z0-9_']*\\s+", name: 'entity.name.function.elm'},
{include: '#infix_op'},
{match: '[|!%$?~+:\\-.=</>&\\\\*^]+', name: 'keyword.operator.elm'},
{
captures: {1: {name: 'support.function.delimiter.elm'}},
match: '([\\[\\]\\{\\},])',
name: 'constant.language.delimiter.elm'
},
{match: '([\\(\\)])', name: 'keyword.other.parenthesis.elm'}
],
repository: {
block_comment: {
applyEndPatternLast: true,
begin: '\\{-(?!#)',
captures: {0: {name: 'punctuation.definition.comment.elm'}},
end: '-\\}',
name: 'comment.block.elm',
patterns: [{include: '#block_comment'}]
},
comments: {
patterns: [
{
captures: {1: {name: 'punctuation.definition.comment.elm'}},
match: '(--).*$\\n?',
name: 'comment.line.double-dash.elm'
},
{include: '#block_comment'}
]
},
infix_op: {
match: '(\\([|!%$+:\\-.=</>]+\\)|\\(,+\\))',
name: 'entity.name.function.infix.elm'
},
module_exports: {
begin: '\\(',
end: '\\)',
name: 'meta.declaration.exports.elm',
patterns: [
{match: "\\b[a-z][a-zA-Z_'0-9]*", name: 'entity.name.function.elm'},
{match: "\\b[A-Z][A-Za-z_'0-9]*", name: 'storage.type.elm'},
{match: ',', name: 'punctuation.separator.comma.elm'},
{include: '#infix_op'},
{match: '\\(.*?\\)', name: 'meta.other.unknown.elm'}
]
},
module_name: {
match: "[A-Z][A-Za-z0-9._']*",
name: 'support.other.module.elm'
},
type_signature: {
patterns: [
{
captures: {
1: {name: 'entity.other.inherited-class.elm'},
2: {name: 'variable.other.generic-type.elm'},
3: {name: 'keyword.other.big-arrow.elm'}
},
match: "\\(\\s*([A-Z][A-Za-z]*)\\s+([a-z][A-Za-z_']*)\\)\\s*(=>)",
name: 'meta.class-constraint.elm'
},
{match: '->', name: 'keyword.other.arrow.elm'},
{match: '=>', name: 'keyword.other.big-arrow.elm'},
{
match: "\\b[a-z][a-zA-Z0-9_']*\\b",
name: 'variable.other.generic-type.elm'
},
{match: "\\b[A-Z][a-zA-Z0-9_']*\\b", name: 'storage.type.elm'},
{match: '\\(\\)', name: 'support.constant.unit.elm'},
{include: '#comments'}
]
}
},
scopeName: 'source.elm'
}
export default grammar