/
source.nut.js
187 lines (186 loc) · 5.66 KB
/
source.nut.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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.nut'],
names: ['squirrel'],
patterns: [
{include: '#special-block'},
{include: '#comments'},
{
match:
'\\b(break|case|catch|default|do|else|for|foreach|if|resume|return|switch|throw|try|while|yield)\\b',
name: 'keyword.control.squirrel'
},
{
match: '\\b(clone|delete|in|instanceof|typeof)\\b',
name: 'keyword.control.squirrel'
},
{match: '\\b(base|this)\\b', name: 'variable.language.squirrel'},
{
match: '\\b(class|constructor|function|local)\\b',
name: 'storage.type.squirrel'
},
{match: '\\b(const|extends|static)\\b', name: 'storage.modifier.squirrel'},
{match: '\\b(null|true|false)\\b', name: 'constant.squirrel.squirrel'},
{
match:
'!|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|==|=|!=|<=>|<=|>=|<-|>>>|<<|>>|<|>|!|&&|\\|\\||\\?\\:|\\*=|(?<!\\()/=|%=|\\+=|\\-=|&=|%=|\\.',
name: 'keyword.operator.squirrel'
},
{
match: '\\b((0(x|X)[0-9a-fA-F]+)|([0-9]+(\\.[0-9]+)?))\\b',
name: 'constant.numeric.squirrel'
},
{
match: '\\b([_A-Za-z][_A-Za-z0-9]\\w*)\\b(?=\\s*(?:[({"\']|\\[\\[))',
name: 'support.function.any-method.squirrel'
},
{
match: '(?<=[^.]\\.)\\b([_A-Za-z][_A-Za-z0-9]\\w*)',
name: 'variable.other.squirrel'
},
{include: '#attributes'},
{include: '#block'},
{include: '#strings'}
],
repository: {
attributes: {
begin: '</',
end: '/>',
name: 'meta.attributes.squirrel',
patterns: [{include: '$base'}]
},
block: {
patterns: [
{
begin: '\\{',
beginCaptures: {
0: {name: 'punctuation.section.block.begin.bracket.curly.squirrel'}
},
end: '\\}',
endCaptures: {
0: {name: 'punctuation.section.block.end.bracket.curly.squirrel'}
},
name: 'meta.block.squirrel',
patterns: [{include: '$base'}]
}
]
},
comments: {
patterns: [
{
captures: {1: {name: 'meta.toc-list.banner.block.squirrel'}},
match: '^/\\* =(\\s*.*?)\\s*= \\*/$\\n?',
name: 'comment.block.squirrel'
},
{
begin: '/\\*',
beginCaptures: {
0: {name: 'punctuation.definition.comment.begin.squirrel'}
},
end: '\\*/',
endCaptures: {
0: {name: 'punctuation.definition.comment.end.squirrel'}
},
name: 'comment.block.squirrel'
},
{
begin: '(^[ \\t]+)?(?=//)',
beginCaptures: {
1: {name: 'punctuation.whitespace.comment.leading.squirrel'}
},
end: '(?!\\G)',
patterns: [
{
begin: '//',
beginCaptures: {
0: {name: 'punctuation.definition.comment.squirrel'}
},
end: '(?=\\n)',
name: 'comment.line.double-slash.squirrel'
}
]
},
{
begin: '(^[ \\t]+)?(?=#)',
beginCaptures: {
1: {name: 'punctuation.whitespace.comment.leading.squirrel'}
},
end: '(?!\\G)',
patterns: [
{
begin: '#',
beginCaptures: {
0: {name: 'punctuation.definition.comment.squirrel'}
},
end: '(?=\\n)',
name: 'comment.line.hash.squirrel'
}
]
}
]
},
'special-block': {
patterns: [
{
begin:
'\\b(class)\\b\\s*([_A-Za-z][_A-Za-z0-9]*\\b)?+(\\s*(extends)\\s*([_A-Za-z][_A-Za-z0-9]*\\b))?',
beginCaptures: {
1: {name: 'storage.type.squirrel'},
2: {name: 'entity.name.type.squirrel'},
4: {name: 'storage.type.modifier.squirrel'},
5: {name: 'entity.name.type.inherited.squirrel'}
},
end: '(?<=\\})|(?=(=))',
name: 'meta.class-block.squirrel',
patterns: [{include: '#block'}]
},
{
begin:
'\\b(function)\\b\\s*([_A-Za-z][_A-Za-z0-9]*\\b)?+(\\s*(::)\\s*([_A-Za-z][_A-Za-z0-9]*\\b))?',
beginCaptures: {
1: {name: 'storage.type.squirrel'},
2: {name: 'entity.name.type.squirrel'},
4: {name: 'punctuation.separator.global.access.squirrel'},
5: {name: 'entity.name.function.squirrel'}
},
end: '(?<=\\})|(?=(=))',
name: 'meta.function-block.squirrel',
patterns: [{include: '#block'}]
},
{
begin: '\\b([_A-Za-z][_A-Za-z0-9]*\\b)?+(\\s*(<-))',
beginCaptures: {
1: {name: 'entity.name.type.squirrel'},
3: {name: 'punctuation.separator.namespace.access.squirrel'}
},
end: '(?<=\\})|(?=(;|,|\\(|\\)|>|\\[|\\]|=))',
name: 'meta.namespace-block.squirrel',
patterns: [{include: '#block'}]
}
]
},
strings: {
patterns: [
{
begin: '@?"',
beginCaptures: {
0: {name: 'punctuation.definition.string.begin.squirrel'}
},
end: '"',
endCaptures: {
0: {name: 'punctuation.definition.string.end.squirrel'}
},
name: 'string.quoted.double.squirrel',
patterns: [
{match: '\\\\.', name: 'constant.character.escape.squirrel'}
]
}
]
}
},
scopeName: 'source.nut'
}
export default grammar