-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHareScript.sublime-syntax
More file actions
260 lines (219 loc) · 11.7 KB
/
HareScript.sublime-syntax
File metadata and controls
260 lines (219 loc) · 11.7 KB
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
%YAML 1.2
---
name: HareScript
file_extensions: [ whscr, whlib, hslib, wh, tpl, shtml, whsock ]
first_line_match: <\?wh
scope: source.harescript
variables:
attributes: (BINARY|CONSTANT|DEINITMACRO|DEPRECATED|EXECUTESHARESCRIPT|EXTERNAL|INTERNALPROTECTED|ISCOUNT|NOSTATEMODIFY|READONLY|SKIPTRACE|SPECIAL|TERMINATES|VARARG)
controls: (AWAIT|BREAK|CASE|CATCH|CONTINUE|ELSE|FINALLY|FOR|FOREVERY|IF|GOTO|RETURN|SWITCH|THROW|TRY|WHILE|YIELD)
keywords: (DELETE|FUNCTION|INSERT|MACRO|SELECT|ALL|AS|ASC|AT|BY|CELL|COLUMN|CLASSTYPE|CROSS|DEFAULTSTO|DESC|DISTINCT|END|EXCEPT|EXPORT|EXTEND|EXTENDSFROM|FALSE|FROM|FULL|GROUP|HAVING|INDEX|INNER|INTERSECT|INTO|JOIN|KEY|LIMIT|MEMBER|NEW|NULL|NVL|OFFSET|ONLY|ORDER|OUTER|PROPERTY|SET|TEMPORARY|TRUE|UNIQUE|USING|VALUES|VAR|VARTYPE|WHERE)
operators: (AND|BITAND|BITLSHIFT|BITNEG|BITOR|BITRSHIFT|BITXOR|CONCAT|IN|LIKE|NOT|OR|TYPEID|XOR)
types: (ARRAY|BLOB|BOOLEAN|DATETIME|FIXEDPOINT|FLOAT|FUNCTION PTR|INTEGER|INTEGER64|MACRO PTR|MONEY|OBJECT|OBJECTTYPE|RECORD|REF|SCHEMA|STRING|TABLE|VARIANT|WEAKOBJECT)
modifiers: (AGGREGATE|ASYNC|CONSTANT|DEFAULT|PRIVATE|PTR|PUBLIC|STATIC|UPDATE|__ATTRIBUTES__|__CONSTREF)
# These can be updated using mod::tollium_dev/scripts/tools/sublimetext_system_libraries.whscr
system_functions: (Abort|Abs|Any|AnyToString|ArraySlice|AsyncReadFrom|AsyncReadLineFrom|AsyncSendBlobTo|Avg|BindSchemaToTable|BindTransactionToSchema|BindTransactionToTable|ByteToString|CallAnyPtrVA|CallFunctionPtrVA|CallMacroPtrVA|CanCastTypeTo|CastTo|CellDelete|CellExists|CellInsert|CellUpdate|CollectGarbage|Count|Debugger|DebuggerKeepalive|DecodeBase16|DecodeBase32|DecodeBase32Hex|DecodeBase64|DecodeCharSet|DecodeHareScript|DecodeHSON|DecodeHSONBlob|DecodeHTML|DecodeJava|DecodeJSON|DecodeJSONBlob|DecodePacket|DecodeQP|DecodeUFS|DecodeURL|DecodeValue|Detokenize|DumpValue|EncodeAttributeValue|EncodeBase16|EncodeBase32|EncodeBase32Hex|EncodeBase64|EncodeCharSet|EncodeHareScript|EncodeHSON|EncodeHSONBlob|EncodeHTML|EncodeJava|EncodeJSON|EncodeJSONBlob|EncodePacket|EncodeQP|EncodeTextNode|EncodeUFS|EncodeURL|EncodeValue|EnforceStructure|ExplainFunctionPtrSignature|ExplainFunctionSignature|ExtendObject|GeneratorSpawn|GeneratorSpawnTrySync|GetArrayTypeDefaultElement|GetAsyncControl|GetAsyncStackTrace|GetAuthenticationRecord|GetBestCharacterSet|GetBindingFromSchema|GetBindingFromTable|GetByteValue|GetCell|GetExternalSessionData|GetHarescriptTypeIdByName|GetMember|GetMemberType|GetObjectMethodPtr|GetSpotHitCount|GetStackTrace|GetStoredScriptProperty|GetTypeDefaultArray|GetTypeDefaultValue|GetTypeName|GetUCValue|GroupedValues|IsAtEndOfStream|IsDebugTagEnabled|IsDefaultValue|IsObjectReferencePublic|IsPrintableASCII|IsTypeidArray|IsTypeidComparable|IsValidUTF8|IsValueSet|KeepTransactionsAlive|Left|Length|Length64|LimitUTF8Bytes|MakeAutoNumber|MakeEmptyRecord|MakeFunctionPtr|MakeMergedRecord|MakeObject|MakeOverwrittenRecord|MakePublicObjectReference|MakeReplacedRecord|MakeUpdatedRecord|Max|MemberDelete|MemberExists|MemberInsert|MemberUpdate|Min|NormalizeWhitespace|ObjectExists|PickFirst|PickLast|Print|PrintRecordArrayTo|PrintRecordTo|PrintTo|Random|ReadFrom|ReadLineFrom|RecordExists|RedirectOutputTo|Reflect|RepackRecord|RepeatElement|RepeatText|Resolve|ReverseArray|Right|RoundToMultiple|RunGeneratorUntilReturn|SearchElement|SearchLastElement|SearchLastSubstring|SearchSubstring|SeedRandomizer|SendBlobTo|SetAuthenticationRecord|SetErrorContextInfo|SetExternalSessionData|ShuffleArray|Sleep|SortArray|Substitute|Substring|Sum|TerminateScript|ToInteger|ToInteger64|Tokenize|ToLowercase|ToRecordArray|ToString|ToUppercase|TrimWhitespace|UCLeft|UCLength|UCRight|UCSearchLastSubstring|UCSearchSubstring|UCSubstring|UCToString|UCTruncate|UnpackRecord|ValidateFunctionPtr|ValidateOptions|WaitForMultiple|WaitForMultipleUntil|WaitForPromise|WaitUntil|WaitUntilMultiple|WeakObjectExists|WriteTo|__CAST_TO_VARIANT_ARRAY|__HS_CONVERTTOITERATOR|__HS_EnsureTraceItemForFirstError|__HS_GetPrivateMember|__HS_INTERNAL_CancelReceiveLine|__HS_INTERNAL_MakeObjectReferencePrivileged|__HS_INTERNAL_OVERRIDEEXECUTELIBRARY|__HS_INTERNAL_ReceiveFrom|__HS_INTERNAL_THROWEXCEPTION|__HS_INTERNAL_UNMANGLEFUNCTIONNAME|__HS_OBJECTMATCHESOUID|__HS_REBINDFUNCTIONPTR|__HS_REBINDFUNCTIONPTR2|__HS_SetPrivateMember|__HS_SQL_AddRecordArraySource|__HS_SQL_AddTableSource|__HS_SQL_CloseQuery|__HS_SQL_DEBUG_GetVarAsOptimized|__HS_SQL_DeleteRecord|__HS_SQL_DescribeTableTypeInfo|__HS_SQL_GetAction|__HS_SQL_GETARRAYRESULTS|__HS_SQL_GetGroupPosition|__HS_SQL_GetRecAction|__HS_SQL_GetRecordArrayPosition|__HS_SQL_GetRecordFase1|__HS_SQL_GetRecordFase2|__HS_SQL_GetSourcesBaseList|__HS_SQL_Insert|__HS_SQL_InsertMultiple|__HS_SQL_MakeArrayOfValue|__HS_SQL_MakeDistinct|__HS_SQL_MergeRecords|__HS_SQL_OpenCursor2|__HS_SQL_OverwriteRecord|__HS_SQL_RebindSchemaWithTypeInfo|__HS_SQL_RebindTableWithTypeInfo|__HS_SQL_Reorder_Results|__HS_SQL_ReportWhereResult|__HS_SQL_SortArray|__HS_SQL_UpdateRecord|__HS_TYPEID|__INTERNAL_AsyncWaitHandleReadSignalled|__INTERNAL_AsyncWaitHandleWriteSignalled|__INTERNAL_DEBUGGETFUNCTIONPTRRETURNTYPE)
system_objecttypes: (Exception|HarescriptErrorException|InvalidOptionException|LibraryVersionConflictException|__HS_INTERNAL_AsyncCallbackWaitHelperBase|__HS_INTERNAL_AsyncFunctionGenerator|__HS_INTERNAL_AsyncGeneratorGenerator|__HS_INTERNAL_FunctionGenerator|__HS_INTERNAL_OutputObject)
system_variables: (THIS|__system_reflecthook)
contexts:
# Parse HTML by default, switch to HareScript when <?wh is found
main:
- match: ""
push: "Packages/HTML/HTML.sublime-syntax"
with_prototype:
- match: <\?wh
captures:
0: punctuation.section.embedded.begin
set: harescript
# HareScript hashbang
- match: ^#\!.*$
scope: comment.line.number-sign.harescript
# Main HareScript source
harescript:
- include: harescript_content
- match: \?>
captures:
0: punctuation.section.embedded.end
pop: true
# HareScript content
harescript_content:
# Function declaration
- match: (?i)\b(((PUBLIC|PRIVATE|UPDATE)[\s\n]+){0,2})\b((({{types}}[\s\n]+)*)(FUNCTION)|(MACRO))[\s\n]+((NEW)|(\w+))(?=[\s\n]*\()
captures:
1: storage.modifier.harescript
5: storage.type.harescript
8: keyword.harescript # FUNCTION
9: keyword.harescript # MACRO
11: keyword.harescript # NEW
12: identifier.function.harescript
scope: meta.function.harescript
# Objecttype declaration
- match: (?i)\b((PUBLIC|PRIVATE)[\s\n]+)?(STATIC[\s\n]+)?\b(OBJECTTYPE)[\s\n]+(\w+)
captures:
2: storage.modifier.harescript
3: storage.modifier.harescript
4: storage.type.harescript
5: identifier.objecttype.harescript
scope: meta.objecttype.harescript
# Objecttype property
- match: (?i)\b(((PUBLIC|PRIVATE|UPDATE)[\s\n]+){0,2})\b(PROPERTY)[\s\n]+(\w+)(?=[\s\n]*\()
captures:
1: storage.modifier.harescript
4: keyword.harescript
5: identifier.property.harescript
scope: meta.property.harescript
# Loadlib
- match: (?i)\b(LOADLIB)[\s\n]+((\"[^\"]*\")|(\'[^\']*\'))
captures:
1: keyword.control.import.harescript
3: string.quoted.double.harescript
4: string.quoted.single.harescript
scope: meta.loadlib.harescript
# Attributes
- match: (?i)\b(__ATTRIBUTES__)[\s\n]*\(
captures:
1: storage.modifier.harescript
push: attributes
# HareScript types
- match: (?i)\b{{types}}\b
scope: storage.type.harescript
# HareScript keywords
- match: (?i)\b{{keywords}}\b
scope: keyword.harescript
# HareScript control keywords
- match: (?i)\b{{controls}}\b
scope: keyword.control.harescript
# HareScript operator keywords
- match: (?i)\b{{operators}}\b
scope: keyword.operator.harescript
# HareScript storage modifier
- match: (?i)\b{{modifiers}}\b
scope: storage.modifier.harescript
# HareScript system functions
- match: (?i)\b{{system_functions}}\b(?=([\s\n]*\[[\s\n]*\])?[\s\n]*\()
scope: support.function.harescript
# HareScript system objecttypes
- match: (?i)\b{{system_objecttypes}}\b
scope: support.class.harescript
# HareScript system variables
- match: (?i)\b{{system_variables}}\b
scope: variable.language.harescript
# HareScript library include
- match: (?i)\b(LOADLIB)\b
scope: keyword.control.import.harescript
# Decimal (integer, money and float), hexadecimal and binary numeric constants
- match: \b(\d*\.)?\d+(i(64)?|m|f|e[+-]?[0-9]*)?\b|\b0x\h+\b|\b0b(0|1)+\b
scope: constant.numeric.harescript
# String constants
- match: \"
captures:
0: punctuation.definition.string.begin
push: dqstring
- match: \'
captures:
0: punctuation.definition.string.begin
push: sqstring
- match: \`
captures:
0: punctuation.definition.string.begin
push: templatestring
# Single-line documentation comments
- match: ///.*$
scope: comment.line.documentation.harescript
# Single-line comments
- match: //.*$
scope: comment.line.harescript
# Documentation block comments
- match: /\*\*
push: docblockcomment
# Block comments
- match: /\*
push: blockcomment
# HareScript (*) operator
- match: \(\*\)
scope: keyword.operator.harescript
# HareScript preprocessor comments
- match: \(\*
push: preprocessor
# HareScript this->^ hat operator
- match: "(?<!->)\\^"
scope: variable.language.harescript
# HareScript compound operators
- match: "->|:=|::|!=|<=|>=|\\|\\||\\?\\?"
scope: keyword.operator.harescript
# HareScript operators
- match: "=|\\+|-|\\*|/|<|>|\\?(?!>)|:|\\||\\^"
scope: keyword.operator.harescript
# __ATTRIBUTES__
# This doesn't strictly parse <modifier> <string>? ("," <modifier> <string>?)*, but highlights any modifier and string
attributes:
- match: \)
pop: true
- match: (?i)\b{{attributes}}\b
captures:
1: storage.modifier.attribute.harescript
- match: \"
captures:
0: punctuation.definition.string.begin
push: dqstring
- match: \'
captures:
0: punctuation.definition.string.begin
push: sqstring
# Double-quoted string constant
dqstring:
- meta_content_scope: string.quoted.double.harescript
- include: escapes
- match: \"
captures:
0: punctuation.definition.string.end
pop: true
# Single-quoted string constant
sqstring:
- meta_content_scope: string.quoted.single.harescript
- include: escapes
- match: \'
captures:
0: punctuation.definition.string.end
pop: true
# Template string constant
templatestring:
- meta_content_scope: string.template.harescript
- include: escapes
- match: \\[\`\$\{]
scope: constant.character.escape.harescript
- match: "\\$\\{"
push: templateplaceholder
captures:
0: keyword.other.substitution.begin
- match: \`
captures:
0: punctuation.definition.string.end
pop: true
templateplaceholder:
- clear_scopes: true
- meta_scope: source.harescript
- include: harescript_content
- match: \}
captures:
0: keyword.other.substitution.end
pop: true
# Escape characters within strings
escapes:
- match: \\[abfnrt\'\"\\]|\\[0-7]{3}|\\x\h{2}|\\u\h{4}
scope: constant.character.escape.harescript
# Documentation block comment
docblockcomment:
- meta_scope: comment.block.documentation.harescript
- match: \*/
pop: true
# Block comment
blockcomment:
- meta_scope: comment.block.harescript
- match: \*/
pop: true
# Preprocessor comment
preprocessor:
- meta_scope: meta.preprocessor.harescript
- match: \*\)
pop: true