limn-hl 0.1.0 → 0.2.0
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.
- package/README.md +109 -148
- package/dist/detect.d.ts +7 -1
- package/dist/detect.js +592 -502
- package/dist/engine.js +45 -1
- package/dist/generated/detect.d.ts +11 -0
- package/dist/generated/detect.js +2434 -0
- package/dist/generated/grammars.d.ts +119 -0
- package/dist/generated/grammars.js +613 -0
- package/dist/generated/lang.d.ts +6 -0
- package/dist/{lang/index.js → generated/lang.js} +82 -56
- package/dist/{theme/generated.d.ts → generated/themes.d.ts} +3 -1
- package/dist/{theme/generated.js → generated/themes.js} +29 -0
- package/dist/lang.d.ts +1 -0
- package/dist/lang.js +1 -0
- package/dist/render/ansi.d.ts +1 -1
- package/dist/render/html.d.ts +1 -1
- package/dist/{theme/index.d.ts → theme.d.ts} +1 -1
- package/dist/theme.js +1 -0
- package/dist/vm/compile.d.ts +4 -0
- package/dist/vm/compile.js +390 -0
- package/dist/vm/exec.d.ts +3 -0
- package/dist/vm/exec.js +218 -0
- package/dist/vm/format.d.ts +255 -0
- package/dist/vm/format.js +248 -0
- package/dist/vm/index.d.ts +2 -0
- package/dist/vm/index.js +2 -0
- package/dist/vm/pat.d.ts +4 -0
- package/dist/vm/pat.js +701 -0
- package/dist/vm/quoted.d.ts +8 -0
- package/dist/vm/quoted.js +190 -0
- package/dist/vm/scan.d.ts +3 -0
- package/dist/vm/scan.js +499 -0
- package/dist/wordtable.d.ts +8 -4
- package/dist/wordtable.js +107 -30
- package/package.json +6 -6
- package/dist/lang/clike.d.ts +0 -15
- package/dist/lang/clike.js +0 -35
- package/dist/lang/clike_helpers.d.ts +0 -8
- package/dist/lang/clike_helpers.js +0 -220
- package/dist/lang/code.d.ts +0 -45
- package/dist/lang/code.js +0 -779
- package/dist/lang/config.d.ts +0 -5
- package/dist/lang/config.js +0 -164
- package/dist/lang/css.d.ts +0 -5
- package/dist/lang/css.js +0 -125
- package/dist/lang/docs.d.ts +0 -12
- package/dist/lang/docs.js +0 -462
- package/dist/lang/formats.d.ts +0 -10
- package/dist/lang/formats.js +0 -295
- package/dist/lang/html.d.ts +0 -11
- package/dist/lang/html.js +0 -298
- package/dist/lang/index.d.ts +0 -20
- package/dist/lang/js.d.ts +0 -9
- package/dist/lang/js.js +0 -532
- package/dist/lang/js_helpers.d.ts +0 -7
- package/dist/lang/js_helpers.js +0 -308
- package/dist/lang/json.d.ts +0 -3
- package/dist/lang/json.js +0 -136
- package/dist/lang/markdown.d.ts +0 -3
- package/dist/lang/markdown.js +0 -249
- package/dist/lang/python.d.ts +0 -3
- package/dist/lang/python.js +0 -335
- package/dist/lang/scripting.d.ts +0 -7
- package/dist/lang/scripting.js +0 -216
- package/dist/lang/shell.d.ts +0 -7
- package/dist/lang/shell.js +0 -278
- package/dist/lang/specs_gen.d.ts +0 -66
- package/dist/lang/specs_gen.js +0 -381
- package/dist/lang/terminal.d.ts +0 -9
- package/dist/lang/terminal.js +0 -550
- package/dist/lang/yaml.d.ts +0 -4
- package/dist/lang/yaml.js +0 -176
- package/dist/theme/index.js +0 -1
package/dist/lang/terminal.js
DELETED
|
@@ -1,550 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Cursor,
|
|
3
|
-
emitCommentWithTodo,
|
|
4
|
-
hasCallParen,
|
|
5
|
-
isDigit,
|
|
6
|
-
isHexDigit,
|
|
7
|
-
isIdentCont,
|
|
8
|
-
isIdentStart,
|
|
9
|
-
scanNumber
|
|
10
|
-
} from "../cursor.js";
|
|
11
|
-
import { Grammar } from "../engine.js";
|
|
12
|
-
import { TokenKind, WordTable } from "../index.js";
|
|
13
|
-
import { onceGrammar } from "./code.js";
|
|
14
|
-
import {
|
|
15
|
-
emitCommentEOL,
|
|
16
|
-
isASCIIAlpha,
|
|
17
|
-
isHyphenIdentCont,
|
|
18
|
-
nextCodePointEnd,
|
|
19
|
-
scanQuotedEscaped
|
|
20
|
-
} from "./docs.js";
|
|
21
|
-
const LOG_UNITS = ["ms", "us", "ns", "kb", "mb", "gb", "s", "m", "h"];
|
|
22
|
-
function isASCIIAlnum(c) {
|
|
23
|
-
return isASCIIAlpha(c) || isDigit(c);
|
|
24
|
-
}
|
|
25
|
-
function isPSVarCont(c) {
|
|
26
|
-
return isASCIIAlnum(c) || c === 95 || c === 58;
|
|
27
|
-
}
|
|
28
|
-
function isPSDashParamBoundary(c) {
|
|
29
|
-
return c === 32 || c === 9 || c === 10 || c === 13 || c === 40 || c === 123 || c === 124 || c === 59 || c === 44 || c === 61;
|
|
30
|
-
}
|
|
31
|
-
function scanPSDoubleString(src, pos, e) {
|
|
32
|
-
const n = src.length;
|
|
33
|
-
let i = pos + 1;
|
|
34
|
-
let seg = pos;
|
|
35
|
-
while (i < n) {
|
|
36
|
-
const ch = src.charCodeAt(i);
|
|
37
|
-
if (ch === 34) {
|
|
38
|
-
i++;
|
|
39
|
-
e.emit(seg, i, TokenKind.String);
|
|
40
|
-
return i;
|
|
41
|
-
}
|
|
42
|
-
if (ch === 96 && i + 1 < n) {
|
|
43
|
-
if (i > seg)
|
|
44
|
-
e.emit(seg, i, TokenKind.String);
|
|
45
|
-
const escEnd = nextCodePointEnd(src, i + 1);
|
|
46
|
-
e.emit(i, escEnd, TokenKind.Escape);
|
|
47
|
-
i = escEnd;
|
|
48
|
-
seg = i;
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
if (ch === 36 && i + 1 < n) {
|
|
52
|
-
const next = src.charCodeAt(i + 1);
|
|
53
|
-
if (next === 123) {
|
|
54
|
-
if (i > seg)
|
|
55
|
-
e.emit(seg, i, TokenKind.String);
|
|
56
|
-
const cur = new Cursor(src, i + 2);
|
|
57
|
-
cur.scanBalanced(123, 125, false);
|
|
58
|
-
e.emit(i, cur.pos, TokenKind.Variable);
|
|
59
|
-
i = cur.pos;
|
|
60
|
-
seg = i;
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
if (isIdentStart(next)) {
|
|
64
|
-
if (i > seg)
|
|
65
|
-
e.emit(seg, i, TokenKind.String);
|
|
66
|
-
let end = i + 2;
|
|
67
|
-
while (end < n && isPSVarCont(src.charCodeAt(end)))
|
|
68
|
-
end++;
|
|
69
|
-
e.emit(i, end, TokenKind.Variable);
|
|
70
|
-
i = end;
|
|
71
|
-
seg = i;
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
i++;
|
|
76
|
-
}
|
|
77
|
-
if (n > seg)
|
|
78
|
-
e.emit(seg, n, TokenKind.String);
|
|
79
|
-
return n;
|
|
80
|
-
}
|
|
81
|
-
function scanPSSingleString(src, pos, e) {
|
|
82
|
-
const n = src.length;
|
|
83
|
-
let i = pos + 1;
|
|
84
|
-
while (i < n) {
|
|
85
|
-
if (src.charCodeAt(i) === 39) {
|
|
86
|
-
if (i + 1 < n && src.charCodeAt(i + 1) === 39) {
|
|
87
|
-
i += 2;
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
i++;
|
|
91
|
-
e.emit(pos, i, TokenKind.String);
|
|
92
|
-
return i;
|
|
93
|
-
}
|
|
94
|
-
i++;
|
|
95
|
-
}
|
|
96
|
-
e.emit(pos, n, TokenKind.String);
|
|
97
|
-
return n;
|
|
98
|
-
}
|
|
99
|
-
function scanPowerShell(src, psWords, psOps, psConsts, e) {
|
|
100
|
-
const n = src.length;
|
|
101
|
-
let i = 0;
|
|
102
|
-
while (i < n && !e.stopped()) {
|
|
103
|
-
const ch = src.charCodeAt(i);
|
|
104
|
-
if (ch === 60 && i + 1 < n && src.charCodeAt(i + 1) === 35) {
|
|
105
|
-
const cur = new Cursor(src, i + 2);
|
|
106
|
-
cur.scanUntil("#>");
|
|
107
|
-
emitCommentWithTodo(src, i, cur.pos, e);
|
|
108
|
-
i = cur.pos;
|
|
109
|
-
} else if (ch === 35) {
|
|
110
|
-
i = emitCommentEOL(src, i, e);
|
|
111
|
-
} else if (ch === 34) {
|
|
112
|
-
i = scanPSDoubleString(src, i, e);
|
|
113
|
-
} else if (ch === 39) {
|
|
114
|
-
i = scanPSSingleString(src, i, e);
|
|
115
|
-
} else if (ch === 36) {
|
|
116
|
-
if (i + 1 < n && src.charCodeAt(i + 1) === 123) {
|
|
117
|
-
const cur = new Cursor(src, i + 2);
|
|
118
|
-
cur.scanBalanced(123, 125, false);
|
|
119
|
-
e.emit(i, cur.pos, TokenKind.Variable);
|
|
120
|
-
i = cur.pos;
|
|
121
|
-
} else if (i + 1 < n && isPSVarCont(src.charCodeAt(i + 1))) {
|
|
122
|
-
let end = i + 2;
|
|
123
|
-
while (end < n && isPSVarCont(src.charCodeAt(end)))
|
|
124
|
-
end++;
|
|
125
|
-
let kind = psConsts.lookupSpan(src, i + 1, end);
|
|
126
|
-
if (kind === TokenKind.Plain)
|
|
127
|
-
kind = TokenKind.Variable;
|
|
128
|
-
e.emit(i, end, kind);
|
|
129
|
-
i = end;
|
|
130
|
-
} else {
|
|
131
|
-
i++;
|
|
132
|
-
}
|
|
133
|
-
} else if (ch === 45 && (i === 0 || isPSDashParamBoundary(src.charCodeAt(i - 1))) && i + 1 < n && isASCIIAlpha(src.charCodeAt(i + 1))) {
|
|
134
|
-
let end = i + 2;
|
|
135
|
-
while (end < n && isHyphenIdentCont(src.charCodeAt(end)))
|
|
136
|
-
end++;
|
|
137
|
-
let kind = psOps.lookupSpan(src, i + 1, end);
|
|
138
|
-
if (kind === TokenKind.Plain)
|
|
139
|
-
kind = TokenKind.Property;
|
|
140
|
-
e.emit(i, end, kind);
|
|
141
|
-
i = end;
|
|
142
|
-
} else if (isIdentStart(ch) && (i === 0 || !isHyphenIdentCont(src.charCodeAt(i - 1)))) {
|
|
143
|
-
let end = i + 1;
|
|
144
|
-
while (end < n && isHyphenIdentCont(src.charCodeAt(end)))
|
|
145
|
-
end++;
|
|
146
|
-
let kind = psWords.lookupSpan(src, i, end);
|
|
147
|
-
if (kind === TokenKind.Plain) {
|
|
148
|
-
const dash = src.indexOf("-", i);
|
|
149
|
-
if (dash >= i && dash < end || hasCallParen(src, end)) {
|
|
150
|
-
kind = TokenKind.Func;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
if (kind !== TokenKind.Plain)
|
|
154
|
-
e.emit(i, end, kind);
|
|
155
|
-
i = end;
|
|
156
|
-
} else if (isDigit(ch) && (i === 0 || !isHyphenIdentCont(src.charCodeAt(i - 1)))) {
|
|
157
|
-
const end = scanNumber(src, i);
|
|
158
|
-
e.emit(i, end, TokenKind.Number);
|
|
159
|
-
i = end;
|
|
160
|
-
} else if (ch === 123 || ch === 125 || ch === 40 || ch === 41 || ch === 91 || ch === 93 || ch === 46 || ch === 44 || ch === 59 || ch === 58) {
|
|
161
|
-
e.emit(i, i + 1, TokenKind.Punctuation);
|
|
162
|
-
i++;
|
|
163
|
-
} else if (ch === 43 || ch === 45 || ch === 42 || ch === 47 || ch === 37 || ch === 61 || ch === 60 || ch === 62 || ch === 33 || ch === 38 || ch === 124) {
|
|
164
|
-
e.emit(i, i + 1, TokenKind.Operator);
|
|
165
|
-
i++;
|
|
166
|
-
} else {
|
|
167
|
-
i++;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
function isBatSpace(c) {
|
|
172
|
-
return c === 32 || c === 9 || c === 13 || c === 10;
|
|
173
|
-
}
|
|
174
|
-
function scanBat(src, batWords, e) {
|
|
175
|
-
const n = src.length;
|
|
176
|
-
let i = 0;
|
|
177
|
-
let lineStart = true;
|
|
178
|
-
while (i < n && !e.stopped()) {
|
|
179
|
-
const ch = src.charCodeAt(i);
|
|
180
|
-
if (ch === 10) {
|
|
181
|
-
lineStart = true;
|
|
182
|
-
i++;
|
|
183
|
-
continue;
|
|
184
|
-
}
|
|
185
|
-
if (ch === 32 || ch === 9 || ch === 13) {
|
|
186
|
-
i++;
|
|
187
|
-
continue;
|
|
188
|
-
}
|
|
189
|
-
if (lineStart && ch === 58) {
|
|
190
|
-
if (i + 1 < n && src.charCodeAt(i + 1) === 58) {
|
|
191
|
-
i = emitCommentEOL(src, i, e);
|
|
192
|
-
lineStart = false;
|
|
193
|
-
continue;
|
|
194
|
-
}
|
|
195
|
-
if (i + 1 < n && !isBatSpace(src.charCodeAt(i + 1))) {
|
|
196
|
-
let end = i + 2;
|
|
197
|
-
while (end < n && !isBatSpace(src.charCodeAt(end)))
|
|
198
|
-
end++;
|
|
199
|
-
e.emit(i, end, TokenKind.Section);
|
|
200
|
-
i = end;
|
|
201
|
-
lineStart = false;
|
|
202
|
-
continue;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
if (lineStart && i + 3 <= n && (src.charCodeAt(i) | 32) === 114 && (src.charCodeAt(i + 1) | 32) === 101 && (src.charCodeAt(i + 2) | 32) === 109 && (i + 3 === n || isBatSpace(src.charCodeAt(i + 3)))) {
|
|
206
|
-
i = emitCommentEOL(src, i, e);
|
|
207
|
-
lineStart = false;
|
|
208
|
-
continue;
|
|
209
|
-
}
|
|
210
|
-
if (ch === 34) {
|
|
211
|
-
let end = i + 1;
|
|
212
|
-
while (end < n && src.charCodeAt(end) !== 34 && src.charCodeAt(end) !== 10)
|
|
213
|
-
end++;
|
|
214
|
-
if (end < n && src.charCodeAt(end) === 34)
|
|
215
|
-
end++;
|
|
216
|
-
e.emit(i, end, TokenKind.String);
|
|
217
|
-
i = end;
|
|
218
|
-
} else if (ch === 37) {
|
|
219
|
-
if (i + 2 < n && src.charCodeAt(i + 1) === 37 && isASCIIAlpha(src.charCodeAt(i + 2))) {
|
|
220
|
-
e.emit(i, i + 3, TokenKind.Variable);
|
|
221
|
-
i += 3;
|
|
222
|
-
} else if (i + 2 < n && src.charCodeAt(i + 1) === 126 && isASCIIAlnum(src.charCodeAt(i + 2))) {
|
|
223
|
-
let end = i + 3;
|
|
224
|
-
while (end < n && isASCIIAlnum(src.charCodeAt(end)))
|
|
225
|
-
end++;
|
|
226
|
-
e.emit(i, end, TokenKind.Variable);
|
|
227
|
-
i = end;
|
|
228
|
-
} else if (i + 1 < n && (isDigit(src.charCodeAt(i + 1)) || src.charCodeAt(i + 1) === 42)) {
|
|
229
|
-
e.emit(i, i + 2, TokenKind.Variable);
|
|
230
|
-
i += 2;
|
|
231
|
-
} else if (i + 1 < n && isIdentStart(src.charCodeAt(i + 1))) {
|
|
232
|
-
let end = i + 2;
|
|
233
|
-
while (end < n && isIdentCont(src.charCodeAt(end)))
|
|
234
|
-
end++;
|
|
235
|
-
if (end < n && src.charCodeAt(end) === 37) {
|
|
236
|
-
end++;
|
|
237
|
-
e.emit(i, end, TokenKind.Variable);
|
|
238
|
-
i = end;
|
|
239
|
-
} else {
|
|
240
|
-
i++;
|
|
241
|
-
}
|
|
242
|
-
} else {
|
|
243
|
-
i++;
|
|
244
|
-
}
|
|
245
|
-
} else if (ch === 33 && i + 1 < n && isIdentStart(src.charCodeAt(i + 1))) {
|
|
246
|
-
let end = i + 2;
|
|
247
|
-
while (end < n && isIdentCont(src.charCodeAt(end)))
|
|
248
|
-
end++;
|
|
249
|
-
if (end < n && src.charCodeAt(end) === 33) {
|
|
250
|
-
end++;
|
|
251
|
-
e.emit(i, end, TokenKind.Variable);
|
|
252
|
-
i = end;
|
|
253
|
-
} else {
|
|
254
|
-
i++;
|
|
255
|
-
}
|
|
256
|
-
} else if (isIdentStart(ch)) {
|
|
257
|
-
let end = i + 1;
|
|
258
|
-
while (end < n && isIdentCont(src.charCodeAt(end)))
|
|
259
|
-
end++;
|
|
260
|
-
const kind = batWords.lookupSpan(src, i, end);
|
|
261
|
-
if (kind !== TokenKind.Plain)
|
|
262
|
-
e.emit(i, end, kind);
|
|
263
|
-
i = end;
|
|
264
|
-
} else if (isDigit(ch)) {
|
|
265
|
-
const end = scanNumber(src, i);
|
|
266
|
-
e.emit(i, end, TokenKind.Number);
|
|
267
|
-
i = end;
|
|
268
|
-
} else if (ch === 64 || ch === 124 || ch === 62 || ch === 60 || ch === 38 || ch === 61) {
|
|
269
|
-
e.emit(i, i + 1, TokenKind.Operator);
|
|
270
|
-
i++;
|
|
271
|
-
} else if (ch === 40 || ch === 41 || ch === 46 || ch === 44) {
|
|
272
|
-
e.emit(i, i + 1, TokenKind.Punctuation);
|
|
273
|
-
i++;
|
|
274
|
-
} else {
|
|
275
|
-
i++;
|
|
276
|
-
}
|
|
277
|
-
lineStart = false;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
function scanAsm(src, asmWords, e) {
|
|
281
|
-
const n = src.length;
|
|
282
|
-
let i = 0;
|
|
283
|
-
let lineStart = true;
|
|
284
|
-
while (i < n && !e.stopped()) {
|
|
285
|
-
const ch = src.charCodeAt(i);
|
|
286
|
-
if (ch === 10) {
|
|
287
|
-
lineStart = true;
|
|
288
|
-
i++;
|
|
289
|
-
continue;
|
|
290
|
-
}
|
|
291
|
-
if (ch === 32 || ch === 9 || ch === 13) {
|
|
292
|
-
i++;
|
|
293
|
-
continue;
|
|
294
|
-
}
|
|
295
|
-
if (ch === 59) {
|
|
296
|
-
i = emitCommentEOL(src, i, e);
|
|
297
|
-
} else if (ch === 47 && i + 1 < n && src.charCodeAt(i + 1) === 47) {
|
|
298
|
-
i = emitCommentEOL(src, i, e);
|
|
299
|
-
} else if (ch === 47 && i + 1 < n && src.charCodeAt(i + 1) === 42) {
|
|
300
|
-
const cur = new Cursor(src, i + 2);
|
|
301
|
-
cur.scanUntil("*/");
|
|
302
|
-
emitCommentWithTodo(src, i, cur.pos, e);
|
|
303
|
-
i = cur.pos;
|
|
304
|
-
lineStart = i > 0 && src.charCodeAt(i - 1) === 10;
|
|
305
|
-
continue;
|
|
306
|
-
} else if (ch === 35) {
|
|
307
|
-
if (lineStart || i + 1 >= n || isBatSpace(src.charCodeAt(i + 1))) {
|
|
308
|
-
i = emitCommentEOL(src, i, e);
|
|
309
|
-
} else {
|
|
310
|
-
e.emit(i, i + 1, TokenKind.Operator);
|
|
311
|
-
i++;
|
|
312
|
-
}
|
|
313
|
-
} else if (ch === 34 || ch === 39) {
|
|
314
|
-
i = scanQuotedEscaped(src, i, ch, false, e);
|
|
315
|
-
} else if (ch === 37) {
|
|
316
|
-
if (i + 1 < n && isASCIIAlnum(src.charCodeAt(i + 1))) {
|
|
317
|
-
let end = i + 2;
|
|
318
|
-
while (end < n && isASCIIAlnum(src.charCodeAt(end)))
|
|
319
|
-
end++;
|
|
320
|
-
e.emit(i, end, TokenKind.Variable);
|
|
321
|
-
i = end;
|
|
322
|
-
} else {
|
|
323
|
-
i++;
|
|
324
|
-
}
|
|
325
|
-
} else if (ch === 46) {
|
|
326
|
-
if (i + 1 < n && isIdentStart(src.charCodeAt(i + 1))) {
|
|
327
|
-
let end = i + 2;
|
|
328
|
-
while (end < n && (isIdentCont(src.charCodeAt(end)) || src.charCodeAt(end) === 46))
|
|
329
|
-
end++;
|
|
330
|
-
if (end < n && src.charCodeAt(end) === 58) {
|
|
331
|
-
end++;
|
|
332
|
-
e.emit(i, end, TokenKind.Section);
|
|
333
|
-
} else {
|
|
334
|
-
e.emit(i, end, TokenKind.Keyword);
|
|
335
|
-
}
|
|
336
|
-
i = end;
|
|
337
|
-
} else {
|
|
338
|
-
e.emit(i, i + 1, TokenKind.Punctuation);
|
|
339
|
-
i++;
|
|
340
|
-
}
|
|
341
|
-
} else if (isIdentStart(ch)) {
|
|
342
|
-
let end = i + 1;
|
|
343
|
-
while (end < n && isIdentCont(src.charCodeAt(end)))
|
|
344
|
-
end++;
|
|
345
|
-
if (end < n && src.charCodeAt(end) === 58) {
|
|
346
|
-
end++;
|
|
347
|
-
e.emit(i, end, TokenKind.Section);
|
|
348
|
-
} else {
|
|
349
|
-
const kind = asmWords.lookupSpan(src, i, end);
|
|
350
|
-
if (kind !== TokenKind.Plain)
|
|
351
|
-
e.emit(i, end, kind);
|
|
352
|
-
}
|
|
353
|
-
i = end;
|
|
354
|
-
} else if (isDigit(ch)) {
|
|
355
|
-
const end = scanNumber(src, i);
|
|
356
|
-
e.emit(i, end, TokenKind.Number);
|
|
357
|
-
i = end;
|
|
358
|
-
} else if (ch === 36) {
|
|
359
|
-
if (i + 1 < n && isDigit(src.charCodeAt(i + 1))) {
|
|
360
|
-
const end = scanNumber(src, i + 1);
|
|
361
|
-
e.emit(i, end, TokenKind.Number);
|
|
362
|
-
i = end;
|
|
363
|
-
} else if (i + 1 < n && isHexDigit(src.charCodeAt(i + 1))) {
|
|
364
|
-
let end = i + 2;
|
|
365
|
-
while (end < n && isHexDigit(src.charCodeAt(end)))
|
|
366
|
-
end++;
|
|
367
|
-
e.emit(i, end, TokenKind.Number);
|
|
368
|
-
i = end;
|
|
369
|
-
} else {
|
|
370
|
-
e.emit(i, i + 1, TokenKind.Operator);
|
|
371
|
-
i++;
|
|
372
|
-
}
|
|
373
|
-
} else if (ch === 40 || ch === 41 || ch === 91 || ch === 93 || ch === 44 || ch === 58) {
|
|
374
|
-
e.emit(i, i + 1, TokenKind.Punctuation);
|
|
375
|
-
i++;
|
|
376
|
-
} else if (ch === 43 || ch === 45 || ch === 42 || ch === 47) {
|
|
377
|
-
e.emit(i, i + 1, TokenKind.Operator);
|
|
378
|
-
i++;
|
|
379
|
-
} else {
|
|
380
|
-
i++;
|
|
381
|
-
}
|
|
382
|
-
lineStart = false;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
function isTwoDigits(src, pos) {
|
|
386
|
-
return pos + 2 <= src.length && isDigit(src.charCodeAt(pos)) && isDigit(src.charCodeAt(pos + 1));
|
|
387
|
-
}
|
|
388
|
-
function matchLogTime(src, pos) {
|
|
389
|
-
const n = src.length;
|
|
390
|
-
if (pos + 8 > n || !isTwoDigits(src, pos) || src.charCodeAt(pos + 2) !== 58 || !isTwoDigits(src, pos + 3) || src.charCodeAt(pos + 5) !== 58 || !isTwoDigits(src, pos + 6)) {
|
|
391
|
-
return 0;
|
|
392
|
-
}
|
|
393
|
-
let end = pos + 8;
|
|
394
|
-
if (end < n && (isDigit(src.charCodeAt(end)) || src.charCodeAt(end) === 58))
|
|
395
|
-
return 0;
|
|
396
|
-
if (end + 1 < n && src.charCodeAt(end) === 46 && isDigit(src.charCodeAt(end + 1))) {
|
|
397
|
-
end += 2;
|
|
398
|
-
while (end < n && isDigit(src.charCodeAt(end)))
|
|
399
|
-
end++;
|
|
400
|
-
}
|
|
401
|
-
return end;
|
|
402
|
-
}
|
|
403
|
-
function matchLogTimestamp(src, pos) {
|
|
404
|
-
if (pos > 0 && isDigit(src.charCodeAt(pos - 1)))
|
|
405
|
-
return 0;
|
|
406
|
-
const n = src.length;
|
|
407
|
-
if (pos + 10 <= n && isTwoDigits(src, pos) && isTwoDigits(src, pos + 2) && src.charCodeAt(pos + 4) === 45 && isTwoDigits(src, pos + 5) && src.charCodeAt(pos + 7) === 45 && isTwoDigits(src, pos + 8) && (pos + 10 === n || src.charCodeAt(pos + 10) !== 45 && !isDigit(src.charCodeAt(pos + 10)))) {
|
|
408
|
-
let end = pos + 10;
|
|
409
|
-
if (end + 9 <= n && (src.charCodeAt(end) === 84 || src.charCodeAt(end) === 32)) {
|
|
410
|
-
const tEnd = matchLogTime(src, end + 1);
|
|
411
|
-
if (tEnd > 0) {
|
|
412
|
-
end = tEnd;
|
|
413
|
-
if (end < n && src.charCodeAt(end) === 90) {
|
|
414
|
-
end++;
|
|
415
|
-
} else if (end + 6 <= n && (src.charCodeAt(end) === 43 || src.charCodeAt(end) === 45) && isTwoDigits(src, end + 1) && src.charCodeAt(end + 3) === 58 && isTwoDigits(src, end + 4)) {
|
|
416
|
-
end += 6;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
return end;
|
|
421
|
-
}
|
|
422
|
-
return matchLogTime(src, pos);
|
|
423
|
-
}
|
|
424
|
-
function isLogIdentCont(c) {
|
|
425
|
-
return isIdentCont(c) || c === 46 || c === 45;
|
|
426
|
-
}
|
|
427
|
-
function scanLog(src, logWords, e) {
|
|
428
|
-
const n = src.length;
|
|
429
|
-
let i = 0;
|
|
430
|
-
while (i < n && !e.stopped()) {
|
|
431
|
-
const ch = src.charCodeAt(i);
|
|
432
|
-
if (ch === 104 && (src.startsWith("http://", i) || src.startsWith("https://", i))) {
|
|
433
|
-
let end = i;
|
|
434
|
-
while (end < n) {
|
|
435
|
-
const c = src.charCodeAt(end);
|
|
436
|
-
if (isBatSpace(c) || c === 34 || c === 39 || c === 60 || c === 62 || c === 41 || c === 93 || c === 125 || c === 44) {
|
|
437
|
-
break;
|
|
438
|
-
}
|
|
439
|
-
end++;
|
|
440
|
-
}
|
|
441
|
-
e.emit(i, end, TokenKind.String);
|
|
442
|
-
i = end;
|
|
443
|
-
} else if (ch === 34 || ch === 39) {
|
|
444
|
-
i = scanQuotedEscaped(src, i, ch, false, e);
|
|
445
|
-
} else if (isDigit(ch)) {
|
|
446
|
-
const tsEnd = matchLogTimestamp(src, i);
|
|
447
|
-
if (tsEnd > 0) {
|
|
448
|
-
e.emit(i, tsEnd, TokenKind.Comment);
|
|
449
|
-
i = tsEnd;
|
|
450
|
-
continue;
|
|
451
|
-
}
|
|
452
|
-
if (i + 1 < n && (src.charCodeAt(i + 1) === 120 || src.charCodeAt(i + 1) === 88)) {
|
|
453
|
-
const end = scanNumber(src, i);
|
|
454
|
-
e.emit(i, end, TokenKind.Number);
|
|
455
|
-
i = end;
|
|
456
|
-
continue;
|
|
457
|
-
}
|
|
458
|
-
let end = i + 1;
|
|
459
|
-
while (end < n) {
|
|
460
|
-
const b = src.charCodeAt(end);
|
|
461
|
-
if (isDigit(b) || b === 46 || b === 58)
|
|
462
|
-
end++;
|
|
463
|
-
else
|
|
464
|
-
break;
|
|
465
|
-
}
|
|
466
|
-
while (end > i && (src.charCodeAt(end - 1) === 46 || src.charCodeAt(end - 1) === 58)) {
|
|
467
|
-
end--;
|
|
468
|
-
}
|
|
469
|
-
if (end < n && src.charCodeAt(end) === 37) {
|
|
470
|
-
end++;
|
|
471
|
-
} else {
|
|
472
|
-
for (const u of LOG_UNITS) {
|
|
473
|
-
if (src.startsWith(u, end) && (end + u.length >= n || !isIdentCont(src.charCodeAt(end + u.length)))) {
|
|
474
|
-
end += u.length;
|
|
475
|
-
break;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
e.emit(i, end, TokenKind.Number);
|
|
480
|
-
i = end;
|
|
481
|
-
} else if (isIdentStart(ch)) {
|
|
482
|
-
let end = i + 1;
|
|
483
|
-
while (end < n && isLogIdentCont(src.charCodeAt(end)))
|
|
484
|
-
end++;
|
|
485
|
-
if (end >= n || src.charCodeAt(end) !== 61) {
|
|
486
|
-
while (end > i + 1 && (src.charCodeAt(end - 1) === 46 || src.charCodeAt(end - 1) === 45)) {
|
|
487
|
-
end--;
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
if (end < n && src.charCodeAt(end) === 61) {
|
|
491
|
-
e.emit(i, end, TokenKind.Property);
|
|
492
|
-
} else {
|
|
493
|
-
const kind = logWords.lookupSpan(src, i, end);
|
|
494
|
-
if (kind !== TokenKind.Plain)
|
|
495
|
-
e.emit(i, end, kind);
|
|
496
|
-
}
|
|
497
|
-
i = end;
|
|
498
|
-
} else if (ch === 91 || ch === 93 || ch === 40 || ch === 41 || ch === 123 || ch === 125 || ch === 44 || ch === 59 || ch === 58) {
|
|
499
|
-
e.emit(i, i + 1, TokenKind.Punctuation);
|
|
500
|
-
i++;
|
|
501
|
-
} else if (ch === 61 || ch === 45 || ch === 62) {
|
|
502
|
-
e.emit(i, i + 1, TokenKind.Operator);
|
|
503
|
-
i++;
|
|
504
|
-
} else {
|
|
505
|
-
i++;
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
export const powershell = /* @__PURE__ */ onceGrammar(() => {
|
|
510
|
-
const psWords = new WordTable(true, {
|
|
511
|
-
kind: TokenKind.Keyword,
|
|
512
|
-
words: "begin break catch class continue data do dynamicparam else elseif end enum exit filter finally for foreach from function if in param process return switch throw trap try until using while"
|
|
513
|
-
});
|
|
514
|
-
const psOps = new WordTable(true, {
|
|
515
|
-
kind: TokenKind.Operator,
|
|
516
|
-
words: "eq ne gt lt ge le like notlike match notmatch contains notcontains in notin and or not xor band bor bxor bnot is isnot as f replace split join shl shr"
|
|
517
|
-
});
|
|
518
|
-
const psConsts = new WordTable(true, {
|
|
519
|
-
kind: TokenKind.Constant,
|
|
520
|
-
words: "true false null"
|
|
521
|
-
});
|
|
522
|
-
return new Grammar("powershell", (src, e) => scanPowerShell(src, psWords, psOps, psConsts, e), "ps1", "pwsh");
|
|
523
|
-
});
|
|
524
|
-
export const bat = /* @__PURE__ */ onceGrammar(() => {
|
|
525
|
-
const batWords = new WordTable(true, {
|
|
526
|
-
kind: TokenKind.Keyword,
|
|
527
|
-
words: "echo off on set setlocal endlocal if else not exist defined errorlevel equ neq lss leq gtr geq for in do goto call exit shift start title cd chdir dir copy xcopy move del erase md mkdir rd rmdir ren rename type cls pause pushd popd nul rem"
|
|
528
|
-
});
|
|
529
|
-
return new Grammar("bat", (src, e) => scanBat(src, batWords, e), "cmd", "batch");
|
|
530
|
-
});
|
|
531
|
-
export const asm = /* @__PURE__ */ onceGrammar(() => {
|
|
532
|
-
const asmWords = new WordTable(true, {
|
|
533
|
-
kind: TokenKind.Keyword,
|
|
534
|
-
words: "mov movq movl movw movb movzx movsx movabs lea leaq push pushq pop popq add addq addl sub subq subl mul imul div idiv inc dec neg and or xor not shl shr sar sal rol ror cmp cmpq cmpl test jmp je jne jz jnz jg jge jl jle ja jae jb jbe call callq ret retq nop syscall sysenter int hlt ldr str stp ldp adrp adr b bl br blr cbz cbnz beq bne bgt blt svc addi ld sd lw sw jal jalr ecall section segment global extern bits db dw dd dq dt resb resw resd resq equ times"
|
|
535
|
-
}, {
|
|
536
|
-
kind: TokenKind.Variable,
|
|
537
|
-
words: "rax rbx rcx rdx rsi rdi rbp rsp r8 r9 r10 r11 r12 r13 r14 r15 rip eax ebx ecx edx esi edi ebp esp eip ax bx cx dx si di bp sp al bl cl dl ah bh ch dh xmm0 xmm1 xmm2 xmm3 xmm4 xmm5 xmm6 xmm7 x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 x21 x22 x23 x24 x25 x26 x27 x28 x29 x30 w0 w1 w2 w3 w4 w5 w6 w7 lr pc fp zero ra gp tp t0 t1 t2 t3 t4 t5 t6 s0 s1 s2 s3 s4 s5 s6 s7 a0 a1 a2 a3 a4 a5 a6 a7"
|
|
538
|
-
});
|
|
539
|
-
return new Grammar("asm", (src, e) => scanAsm(src, asmWords, e), "s", "nasm", "assembly");
|
|
540
|
-
});
|
|
541
|
-
export const log = /* @__PURE__ */ onceGrammar(() => {
|
|
542
|
-
const logWords = new WordTable(true, {
|
|
543
|
-
kind: TokenKind.Error,
|
|
544
|
-
words: "error err fatal panic crit critical alert emerg fail failed"
|
|
545
|
-
}, {
|
|
546
|
-
kind: TokenKind.Constant,
|
|
547
|
-
words: "warn warning deprecated true false null nil"
|
|
548
|
-
}, { kind: TokenKind.Inserted, words: "info ok success passed" }, { kind: TokenKind.Comment, words: "debug trace verbose" });
|
|
549
|
-
return new Grammar("log", (src, e) => scanLog(src, logWords, e), "logs");
|
|
550
|
-
});
|
package/dist/lang/yaml.d.ts
DELETED