/
source.pony.js
167 lines (166 loc) · 5.21 KB
/
source.pony.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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/CausalityLtd/sublime-pony>
// and licensed `bsd-2-clause`.
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.pony'],
names: ['pony'],
patterns: [
{include: '#block-comments'},
{include: '#line-comments'},
{include: '#typedeclarations'},
{include: '#methoddeclarations'},
{include: '#keywords'},
{include: '#constants'},
{include: '#identifiers'},
{include: '#strings'}
],
repository: {
'block-comments': {
begin: '/\\*',
end: '\\*/',
name: 'comment.block.pony',
patterns: [{include: '#block-comments'}]
},
constants: {
patterns: [
{match: '\\b(this)\\b', name: 'constant.other.pony'},
{match: '\\b(true|false)\\b', name: 'constant.language.pony'},
{
match:
'\\b((0b[0-1_]*)|(0x[0-9a-fA-F_]*)|([0-9][0-9_]*(\\.[0-9][0-9_]*)?((e|E)(\\+|-)?[0-9_]+)?))\\b',
name: 'constant.numeric.pony'
}
]
},
identifiers: {
patterns: [
{
captures: {1: {name: 'support.function.pony'}},
match: '\\b([_a-z][_a-zA-Z0-9]*)\\b(\\(|\\[)'
},
{
captures: {1: {name: 'variable.parameter.pony'}},
match: '\\.\\s*([_a-z][_a-zA-Z0-9]*)\\b[^\\(\\[]'
},
{
captures: {1: {name: 'support.function.pony'}},
match: '@\\s*([_a-zA-z][_a-zA-Z0-9]*)\\s*(\\(|\\[)'
},
{match: '\\b(_*[A-Z][_a-zA-Z0-9]*)\\b', name: 'entity.name.class.pony'},
{match: "\\b(_*[a-z][_a-zA-Z0-9']*)"}
]
},
keywords: {
patterns: [
{
match: '\\b(compile_intrinsic|compile_error)\\b',
name: 'keyword.other.intrinsic.pony'
},
{match: '\\b(use)\\b', name: 'keyword.other.import.pony'},
{
match: '\\b(var|let|embed)\\b',
name: 'keyword.other.declaration.pony'
},
{
match: '\\b(iso|trn|ref|val|box|tag)\\b',
name: 'entity.other.attribute-name.pony'
},
{
match: '\\b(break|continue|return|error)\\b',
name: 'keyword.control.jump.pony'
},
{
match:
'\\b(if|ifdef|then|elseif|else|end|match|where|try|with|as|recover|consume|object|digestof)\\b',
name: 'keyword.control.pony'
},
{
match: '\\b(while|do|repeat|until|for|in)\\b',
name: 'keyword.control.loop.pony'
},
{match: '(\\?|[-=]>)'},
{match: '(\\-|\\+|\\*|/(?![/*])|%|<<|>>)'},
{match: '(==|!=|<=|>=|<|>)'},
{match: '\\b(is|isnt|not|and|or|xor)\\b'},
{match: '='},
{match: '(\\||\\&|\\,|\\^)'}
]
},
'line-comments': {
begin: '//',
end: '\\n',
name: 'comment.line.double-slash.pony'
},
methoddeclarations: {
captures: {
1: {name: 'keyword.declaration.pony'},
2: {name: 'support.other.annotation.pony'},
3: {name: 'keyword.other.capability.pony'},
4: {name: 'entity.name.function.pony'}
},
match:
'\\b(new|be|fun)\\s+(\\\\[_a-z][_a-zA-Z0-9]*\\\\)?\\s*(iso|trn|ref|val|box|tag)?\\b\\s*([_a-z][_a-zA-Z0-9]*)'
},
strings: {
patterns: [
{
begin: "'",
beginCaptures: {
0: {name: 'punctuation.definition.character.begin.pony'}
},
end: "'",
endCaptures: {0: {name: 'punctuation.definition.character.end.pony'}},
name: 'constant.character.pony',
patterns: [
{
match: '\\\\(?:[abfnrtv\\\\"0]|x[0-9A-Fa-f]{2})',
name: 'constant.character.escape.pony'
},
{match: '\\\\.', name: 'invalid.illegal.pony'}
]
},
{
begin: '"""',
beginCaptures: {
0: {name: 'punctuation.definition.string.begin.pony'}
},
end: '"""(?!")',
endCaptures: {0: {name: 'punctuation.definition.string.end.pony'}},
name: 'variable.parameter.pony'
},
{
begin: '"',
beginCaptures: {
0: {name: 'punctuation.definition.string.begin.pony'}
},
end: '"',
endCaptures: {0: {name: 'punctuation.definition.string.end.pony'}},
name: 'string.quoted.double.pony',
patterns: [
{
match:
'\\\\(?:[abfnrtv\\\\"0]|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{6})',
name: 'constant.string.escape.pony'
},
{match: '\\\\.', name: 'invalid.illegal.pony'}
]
}
]
},
typedeclarations: {
captures: {
1: {name: 'keyword.declaration.pony'},
2: {name: 'support.other.annotation.pony'},
3: {name: 'keyword.other.capability.pony'},
4: {name: 'entity.name.type.pony'}
},
match:
'\\b(type|interface|trait|primitive|struct|class|actor)\\s+(\\\\[_a-z][_a-zA-Z0-9]*\\\\)?\\s*(iso|trn|ref|val|box|tag)?@?\\s*([_A-Z][_a-zA-Z0-9]*)'
}
},
scopeName: 'source.pony'
}
export default grammar