/
source.objectscript.js
174 lines (173 loc) · 5.6 KB
/
source.objectscript.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
// 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 = {
dependencies: ['source.objectscript_macros'],
extensions: [],
names: ['objectscript'],
patterns: [
{include: '#comments'},
{include: '#embedded'},
{include: '#constants'},
{include: '#keywords'},
{include: '#macros'},
{include: '#elements'}
],
repository: {
commands: {
patterns: [
{
captures: {1: {name: 'keyword.control.objectscript'}},
match:
'(?i)(?<=\\s)\\b(BREAK|B|SET|S|DO|D|KILL|K|GOTO|G|READ|R|WRITE|W|OPEN|O|USE|U|CLOSE|C|CONTINUE|FOR|F|HALT|H|HANG|JOB|J|MERGE|M|NEW|N|QUIT|Q|RETURN|RET|TSTART|TS|TCOMMIT|TC|TROLLBACK|TRO|THROW|VIEW|V|XECUTE|X|ZKILL|ZL|ZNSPACE|ZN|ZTRAP|ZWRITE|ZW|ZZDUMP|ZZWRITE)\\b(?=( (?![=+-]|\\&|\\|)|:|$))'
},
{
captures: {1: {name: 'keyword.control.objectscript'}},
match: '(?i)(?<=\\s)\\b(LOCK|L)\\b(?=( (?![=]|\\&|\\|)|:|$))'
}
]
},
comments: {
patterns: [
{
begin: '(/\\*)',
beginCaptures: {1: {name: 'comment.multiline.objectscript'}},
contentName: 'comment.multiline.objectscript',
end: '(.*?\\*/)',
endCaptures: {1: {name: 'comment.multiline.objectscript'}}
},
{begin: '^\\s*#;', end: '$', name: 'comment.line.macro.objectscript'},
{begin: '//|;', end: '$', name: 'comment.endline.objectscript'},
{begin: '##;', end: '$', name: 'comment.endline.macro.objectscript'}
]
},
constants: {
patterns: [
{
begin: '(")',
beginCaptures: {
1: {name: 'punctuation.definition.string.begin.objectscript'}
},
end: '(")',
endCaptures: {
1: {name: 'punctuation.definition.string.end.objectscript'}
},
name: 'string.quoted.double.objectscript'
},
{match: '\\d+', name: 'constant.numeric.objectscript'}
]
},
'control-commands': {
patterns: [
{
captures: {1: {name: 'keyword.control.objectscript'}},
match:
'(?i)(?<=\\s)\\b(IF|I|WHILE|FOR|F|TRY|CATCH|ELSE|E|ELSEIF)\\b(?=( (?![=+-]|\\&|\\|)|:|$))'
}
]
},
elements: {
patterns: [
{match: '^[a-zA-Z0-9]+', name: 'entity.name.function'},
{
captures: {
1: {name: 'keyword.other'},
2: {name: 'punctuation.objectscript'},
3: {name: 'entity.name.class'},
4: {name: 'punctuation.objectscript'}
},
match: '(?i)(##class)(\\()([^)]+)(\\))'
},
{match: '%[a-zA-Z0-9]+', name: 'entity.other.attribute-name'},
{match: '[i|r]%[a-zA-Z0-9]+', name: 'entity.other.attribute-name'},
{match: '[i|r]%"[^".]"', name: 'entity.other.attribute-name'},
{
captures: {
1: {name: 'punctuation.objectscript'},
2: {name: 'entity.other.attribute-name'}
},
match: '(\\.{1,2})(%?[a-zA-Z0-9]+)(?=\\()'
},
{
captures: {
1: {name: 'punctuation.objectscript'},
2: {name: 'entity.other.attribute-name'}
},
match: '(\\.{1,2})(%?[a-zA-Z0-9]+)(?!\\()'
},
{
captures: {
1: {name: 'punctuation.objectscript'},
2: {name: 'meta.parameter.type.variable'}
},
match: '(\\.{1,2}#)([a-zA-Z0-9]+)'
},
{match: '%?[a-zA-Z0-9]+', name: 'variable.name.objectscrip'},
{match: '\\^%?[a-zA-Z0-9]+', name: 'variable.name.global.objectscrip'},
{
match: '\\$[a-zA-Z0-9]+',
name: 'entity.name.function.system.objectscript'
},
{
match: '\\${2}[a-zA-Z0-9]+',
name: 'entity.name.function.local.objectscript'
},
{match: '\\${3}[a-zA-Z0-9]+', name: 'meta.preprocessor.objectscript'}
]
},
embedded: {patterns: [{include: '#embeddedSQL'}, {include: '#embeddedJS'}]},
embeddedJS: {
patterns: [
{
begin: '(&js)(\\()',
beginCaptures: {
1: {name: 'keyword.special.js.objectscript'},
2: {name: 'punctuation.objectscript'}
},
contentName: 'text.js',
end: '\\)',
patterns: [{include: 'source.js'}]
}
]
},
embeddedSQL: {
patterns: [
{
begin: '(&sql)(\\()',
beginCaptures: {
1: {name: 'keyword.special.sql.objectscript'},
2: {name: 'punctuation.objectscript'}
},
contentName: 'meta.embedded.block.sql',
end: '\\)',
patterns: [{include: 'source.sql'}]
}
]
},
keywords: {
patterns: [{include: '#commands'}, {include: '#control-commands'}]
},
macros: {
patterns: [
{
captures: {
1: {name: 'meta.preprocessor.dim.objectscript'},
2: {name: 'whitespace.objectscript'},
3: {name: 'variable.name'},
4: {name: 'whitespace.objectscript'},
5: {name: 'keyword.as.objectscript'},
6: {name: 'whitespace.objectscript'},
7: {name: 'entity.name.class'}
},
match:
'(?i)(#dim)(\\s)(%?[a-zA-Z0-9]+)(\\s)(?:(As)(\\s)(%?[a-zA-Z0-9.]+))?'
},
{include: 'source.objectscript_macros'}
]
},
statements: {patterns: [{include: '#variables'}]}
},
scopeName: 'source.objectscript'
}
export default grammar