xmlui 0.9.2 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,310 @@
1
+ "use strict";
2
+ /* Based on https://github.com/microsoft/monaco-editor/blob/main/src/basic-languages/javascript/javascript.ts */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.XmluiScripGrammar = void 0;
5
+ exports.XmluiScripGrammar = {
6
+ id: "xmluiscript",
7
+ config: {
8
+ wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
9
+ comments: {
10
+ lineComment: "//",
11
+ blockComment: ["/*", "*/"],
12
+ },
13
+ brackets: [
14
+ ["{", "}"],
15
+ ["[", "]"],
16
+ ["(", ")"],
17
+ ],
18
+ onEnterRules: [
19
+ {
20
+ // e.g. /** | */
21
+ beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
22
+ afterText: /^\s*\*\/$/,
23
+ action: {
24
+ // numeric repr of indentAction: languages.IndentAction.IndentOutdent, but without the "monaco-core" package
25
+ indentAction: 2,
26
+ appendText: " * ",
27
+ },
28
+ },
29
+ {
30
+ // e.g. /** ...|
31
+ beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
32
+ action: {
33
+ // numeric repr of indentAction: languages.IndentAction.None, but without the "monaco-core" package
34
+ indentAction: 0,
35
+ appendText: " * ",
36
+ },
37
+ },
38
+ {
39
+ // e.g. * ...|
40
+ beforeText: /^(\t|(\ \ ))*\ \*(\ ([^\*]|\*(?!\/))*)?$/,
41
+ action: {
42
+ // numeric repr of indentAction: languages.IndentAction.None, but without the "monaco-core" package
43
+ indentAction: 0,
44
+ appendText: "* ",
45
+ },
46
+ },
47
+ {
48
+ // e.g. */|
49
+ beforeText: /^(\t|(\ \ ))*\ \*\/\s*$/,
50
+ action: {
51
+ // numeric repr of indentAction: languages.IndentAction.None, but without the "monaco-core" package
52
+ indentAction: 0,
53
+ removeText: 1,
54
+ },
55
+ },
56
+ ],
57
+ autoClosingPairs: [
58
+ { open: "{", close: "}" },
59
+ { open: "[", close: "]" },
60
+ { open: "(", close: ")" },
61
+ { open: '"', close: '"', notIn: ["string"] },
62
+ { open: "'", close: "'", notIn: ["string", "comment"] },
63
+ { open: "`", close: "`", notIn: ["string", "comment"] },
64
+ { open: "/**", close: " */", notIn: ["string"] },
65
+ ],
66
+ folding: {
67
+ markers: {
68
+ start: new RegExp("^\\s*//\\s*#?region\\b"),
69
+ end: new RegExp("^\\s*//\\s*#?endregion\\b"),
70
+ },
71
+ },
72
+ },
73
+ language: {
74
+ // Set defaultToken to invalid to see what you do not tokenize yet
75
+ defaultToken: "invalid",
76
+ tokenPostfix: ".xs",
77
+ typeKeywords: [],
78
+ keywords: [
79
+ "break",
80
+ "case",
81
+ "catch",
82
+ "class",
83
+ "continue",
84
+ "const",
85
+ "constructor",
86
+ "debugger",
87
+ "default",
88
+ "delete",
89
+ "do",
90
+ "else",
91
+ "export",
92
+ "extends",
93
+ "false",
94
+ "finally",
95
+ "for",
96
+ "from",
97
+ "function",
98
+ "get",
99
+ "if",
100
+ "import",
101
+ "in",
102
+ "instanceof",
103
+ "let",
104
+ "new",
105
+ "null",
106
+ "return",
107
+ "set",
108
+ "static",
109
+ "super",
110
+ "switch",
111
+ "symbol",
112
+ "this",
113
+ "throw",
114
+ "true",
115
+ "try",
116
+ "typeof",
117
+ "undefined",
118
+ "var",
119
+ "void",
120
+ "while",
121
+ "with",
122
+ "yield",
123
+ "async",
124
+ "await",
125
+ "of",
126
+ ],
127
+ operators: [
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
+ // we include these common regular expressions
173
+ symbols: /[=><!~?:&|+\-*\/\^%]+/,
174
+ escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
175
+ digits: /\d+(_+\d+)*/,
176
+ octaldigits: /[0-7]+(_+[0-7]+)*/,
177
+ binarydigits: /[0-1]+(_+[0-1]+)*/,
178
+ hexdigits: /[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/,
179
+ regexpctl: /[(){}\[\]\$\^|\-*+?\.]/,
180
+ regexpesc: /\\(?:[bBdDfnrstvwWn0\\\/]|@regexpctl|c[A-Z]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})/,
181
+ // The main tokenizer for our languages
182
+ tokenizer: {
183
+ root: [[/[{}]/, "delimiter.bracket"], { include: "common" }],
184
+ common: [
185
+ // identifiers and keywords
186
+ [
187
+ /#?[a-z_$][\w$]*/,
188
+ {
189
+ cases: {
190
+ "@keywords": "keyword",
191
+ "@default": "identifier",
192
+ },
193
+ },
194
+ ],
195
+ [/[A-Z][\w\$]*/, "type.identifier"], // to show class names nicely
196
+ // [/[A-Z][\w\$]*/, 'identifier'],
197
+ // whitespace
198
+ { include: "@whitespace" },
199
+ // regular expression: ensure it is terminated before beginning (otherwise it is an opeator)
200
+ [
201
+ /\/(?=([^\\\/]|\\.)+\/([dgimsuy]*)(\s*)(\.|;|,|\)|\]|\}|$))/,
202
+ { token: "regexp", bracket: "@open", next: "@regexp" },
203
+ ],
204
+ // delimiters and operators
205
+ [/[()\[\]]/, "@brackets"],
206
+ [/[<>](?!@symbols)/, "@brackets"],
207
+ [/!(?=([^=]|$))/, "delimiter"],
208
+ [
209
+ /@symbols/,
210
+ {
211
+ cases: {
212
+ "@operators": "delimiter",
213
+ "@default": "",
214
+ },
215
+ },
216
+ ],
217
+ // numbers
218
+ [/(@digits)[eE]([\-+]?(@digits))?/, "number.float"],
219
+ [/(@digits)\.(@digits)([eE][\-+]?(@digits))?/, "number.float"],
220
+ [/0[xX](@hexdigits)n?/, "number.hex"],
221
+ [/0[oO]?(@octaldigits)n?/, "number.octal"],
222
+ [/0[bB](@binarydigits)n?/, "number.binary"],
223
+ [/(@digits)n?/, "number"],
224
+ // delimiter: after number because of .\d floats
225
+ [/[;,.]/, "delimiter"],
226
+ // strings
227
+ [/"([^"\\]|\\.)*$/, "string.invalid"], // non-teminated string
228
+ [/'([^'\\]|\\.)*$/, "string.invalid"], // non-teminated string
229
+ [/"/, "string", "@string_double"],
230
+ [/'/, "string", "@string_single"],
231
+ [/`/, "string", "@string_backtick"],
232
+ ],
233
+ whitespace: [
234
+ [/[ \t\r\n]+/, ""],
235
+ [/\/\*\*(?!\/)/, "comment.doc", "@jsdoc"],
236
+ [/\/\*/, "comment", "@comment"],
237
+ [/\/\/.*$/, "comment"],
238
+ ],
239
+ comment: [
240
+ [/[^\/*]+/, "comment"],
241
+ [/\*\//, "comment", "@pop"],
242
+ [/[\/*]/, "comment"],
243
+ ],
244
+ jsdoc: [
245
+ [/[^\/*]+/, "comment.doc"],
246
+ [/\*\//, "comment.doc", "@pop"],
247
+ [/[\/*]/, "comment.doc"],
248
+ ],
249
+ // We match regular expression quite precisely
250
+ regexp: [
251
+ [
252
+ /(\{)(\d+(?:,\d*)?)(\})/,
253
+ ["regexp.escape.control", "regexp.escape.control", "regexp.escape.control"],
254
+ ],
255
+ [
256
+ /(\[)(\^?)(?=(?:[^\]\\\/]|\\.)+)/,
257
+ ["regexp.escape.control", { token: "regexp.escape.control", next: "@regexrange" }],
258
+ ],
259
+ [/(\()(\?:|\?=|\?!)/, ["regexp.escape.control", "regexp.escape.control"]],
260
+ [/[()]/, "regexp.escape.control"],
261
+ [/@regexpctl/, "regexp.escape.control"],
262
+ [/[^\\\/]/, "regexp"],
263
+ [/@regexpesc/, "regexp.escape"],
264
+ [/\\\./, "regexp.invalid"],
265
+ [
266
+ /(\/)([dgimsuy]*)/,
267
+ [{ token: "regexp", bracket: "@close", next: "@pop" }, "keyword.other"],
268
+ ],
269
+ ],
270
+ regexrange: [
271
+ [/-/, "regexp.escape.control"],
272
+ [/\^/, "regexp.invalid"],
273
+ [/@regexpesc/, "regexp.escape"],
274
+ [/[^\]]/, "regexp"],
275
+ [
276
+ /\]/,
277
+ {
278
+ token: "regexp.escape.control",
279
+ next: "@pop",
280
+ bracket: "@close",
281
+ },
282
+ ],
283
+ ],
284
+ string_double: [
285
+ [/[^\\"]+/, "string"],
286
+ [/@escapes/, "string.escape"],
287
+ [/\\./, "string.escape.invalid"],
288
+ [/"/, "string", "@pop"],
289
+ ],
290
+ string_single: [
291
+ [/[^\\']+/, "string"],
292
+ [/@escapes/, "string.escape"],
293
+ [/\\./, "string.escape.invalid"],
294
+ [/'/, "string", "@pop"],
295
+ ],
296
+ string_backtick: [
297
+ [/\$\{/, { token: "delimiter.bracket", next: "@bracketCounting" }],
298
+ [/[^\\`$]+/, "string"],
299
+ [/@escapes/, "string.escape"],
300
+ [/\\./, "string.escape.invalid"],
301
+ [/`/, "string", "@pop"],
302
+ ],
303
+ bracketCounting: [
304
+ [/\{/, "delimiter.bracket", "@bracketCounting"],
305
+ [/\}/, "delimiter.bracket", "@pop"],
306
+ { include: "common" },
307
+ ],
308
+ },
309
+ },
310
+ };