limn-hl 0.1.1 → 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 +105 -174
- 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} +1 -1
- 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 -404
- 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/{theme/generated.js → generated/themes.js} +0 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { TokenKind } from "../token.js";
|
|
2
|
+
export function onceGrammar(build) {
|
|
3
|
+
let cached;
|
|
4
|
+
return () => {
|
|
5
|
+
if (cached === undefined) {
|
|
6
|
+
cached = build();
|
|
7
|
+
}
|
|
8
|
+
return cached;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export const OP_LIT = 0;
|
|
12
|
+
export const OP_WORD = 1;
|
|
13
|
+
export const OP_NUMBER = 2;
|
|
14
|
+
export const OP_QUOTED = 3;
|
|
15
|
+
export const OP_COMMENT = 4;
|
|
16
|
+
export const OP_PAT = 5;
|
|
17
|
+
export const PAT_OP_RET = 0;
|
|
18
|
+
export const PAT_OP_LIT = 1;
|
|
19
|
+
export const PAT_OP_LIT_FOLD = 2;
|
|
20
|
+
export const PAT_OP_CLASS = 3;
|
|
21
|
+
export const PAT_OP_NOT_CLASS = 4;
|
|
22
|
+
export const PAT_OP_SPAN = 5;
|
|
23
|
+
export const PAT_OP_SPAN_NOT = 6;
|
|
24
|
+
export const PAT_OP_ANY_UTF8 = 7;
|
|
25
|
+
export const PAT_OP_ASSERT = 8;
|
|
26
|
+
export const PAT_OP_CHOICE = 9;
|
|
27
|
+
export const PAT_OP_COMMIT = 10;
|
|
28
|
+
export const PAT_OP_JUMP = 11;
|
|
29
|
+
export const PAT_OP_LOOK = 12;
|
|
30
|
+
export const PAT_OP_MARK = 13;
|
|
31
|
+
export const PAT_OP_EMIT = 14;
|
|
32
|
+
export const PAT_OP_EMBED = 15;
|
|
33
|
+
export const PAT_OP_BALANCED = 16;
|
|
34
|
+
export const PAT_OP_UNTIL = 17;
|
|
35
|
+
export const PAT_OP_CAP_RUN = 18;
|
|
36
|
+
export const PAT_OP_SCAN_CAP_CLOSE = 19;
|
|
37
|
+
export const PAT_OP_LINE_CONT_LIMIT = 20;
|
|
38
|
+
export const PAT_OP_SET_LIMIT = 21;
|
|
39
|
+
export const PAT_OP_TABLE_BRANCH = 22;
|
|
40
|
+
export const PAT_OP_STD_NUM = 23;
|
|
41
|
+
export const PAT_OP_NOT_IN_LINE = 24;
|
|
42
|
+
export const PAT_OP_SKIP_TO_LIMIT = 25;
|
|
43
|
+
export const PAT_OP_SCAN_ESCAPE = 26;
|
|
44
|
+
export const PAT_OP_EMIT_TABLE = 27;
|
|
45
|
+
export const CC_ALPHA = 1 << 0;
|
|
46
|
+
export const CC_DIGIT = 1 << 1;
|
|
47
|
+
export const CC_UNDER = 1 << 2;
|
|
48
|
+
export const CC_NONASCII = 1 << 3;
|
|
49
|
+
export const CC_HYPHEN = 1 << 4;
|
|
50
|
+
export const CC_DOT = 1 << 5;
|
|
51
|
+
export const CC_COLON = 1 << 6;
|
|
52
|
+
export const CC_NONSPACE = 1 << 7;
|
|
53
|
+
export const CC_NONASCII_VAL = CC_NONASCII | CC_NONSPACE;
|
|
54
|
+
export const HDR_AT_LINE_START = 1 << 0;
|
|
55
|
+
export const HDR_PREV_NOT = 1 << 1;
|
|
56
|
+
export const HDR_BOUNDARY = 1 << 2;
|
|
57
|
+
export const HDR_TRANS = 1 << 3;
|
|
58
|
+
export const LF_CASE_INSENSITIVE = 1 << 0;
|
|
59
|
+
export const LF_REQUIRE_SPACE_AFTER = 1 << 1;
|
|
60
|
+
export const LF_HAS_NEXT_MASK = 1 << 2;
|
|
61
|
+
export const WF_REQUIRE_TABLE_HIT = 1 << 0;
|
|
62
|
+
export const WF_CALL_PAREN = 1 << 1;
|
|
63
|
+
export const WF_BANG_MACRO = 1 << 2;
|
|
64
|
+
export const WF_HAS_EXTRA_CONT = 1 << 3;
|
|
65
|
+
export const WF_HAS_FALLBACK = 1 << 4;
|
|
66
|
+
export const WF_HAS_WORD_TRANS = 1 << 5;
|
|
67
|
+
export const WF_HAS_PRE_PAT = 1 << 6;
|
|
68
|
+
export const WF_HAS_AFTER_PAT = 1 << 7;
|
|
69
|
+
export const WF_HAS_KWD_CALL_PAT = 1 << 8;
|
|
70
|
+
export const NF_DOT_LEADING = 1 << 0;
|
|
71
|
+
export const QF_MULTILINE = 1 << 0;
|
|
72
|
+
export const QF_RAW = 1 << 1;
|
|
73
|
+
export const QF_ESCAPES = 1 << 2;
|
|
74
|
+
export const QF_TRIPLE = 1 << 3;
|
|
75
|
+
export const QF_HAS_PREFIX = 1 << 4;
|
|
76
|
+
export const QF_COLON_KEY = 1 << 5;
|
|
77
|
+
export const CF_BLOCK = 1 << 0;
|
|
78
|
+
export const CF_NESTED = 1 << 1;
|
|
79
|
+
export const CF_EMIT_TODO = 1 << 2;
|
|
80
|
+
export const MF_HAS_LIT_GUARD = 1 << 0;
|
|
81
|
+
export const MF_HAS_DEFAULT_KIND = 1 << 1;
|
|
82
|
+
export const MF_HAS_NEWLINE_TRANS = 1 << 2;
|
|
83
|
+
export const MF_HAS_DEFAULT_TRANS = 1 << 3;
|
|
84
|
+
export const MF_HAS_FAST_IDENT = 1 << 4;
|
|
85
|
+
export const MF_HAS_IDENT_GUARD = 1 << 5;
|
|
86
|
+
export const MF_HAS_FAST_QUOTED = 1 << 6;
|
|
87
|
+
export const MF_HAS_NUM_TRANS = 1 << 7;
|
|
88
|
+
export const TR_STAY = 0;
|
|
89
|
+
export const TR_SET = 1;
|
|
90
|
+
export const TR_PUSH = 2;
|
|
91
|
+
export const TR_POP = 3;
|
|
92
|
+
export const TR_RESET = 4;
|
|
93
|
+
export const TR_RESET_IF_EMPTY = 5;
|
|
94
|
+
export const TR_POP_RECONSUME = 6;
|
|
95
|
+
export const TR_PUSH_RET = 7;
|
|
96
|
+
export const TR_SET_RECONSUME = 8;
|
|
97
|
+
export const ACT_SKIP_WS = 0;
|
|
98
|
+
export const ACT_SKIP_WS_NL = 1;
|
|
99
|
+
export const ACT_DEFAULT_RUN = 2;
|
|
100
|
+
export const ACT_NEWLINE = 3;
|
|
101
|
+
export const ACT_IDENT_SIMPLE = 4;
|
|
102
|
+
export const ACT_IDENT_FAST = 5;
|
|
103
|
+
export const ACT_IDENT_GUARD = 6;
|
|
104
|
+
export const ACT_NUMBER_FAST = 7;
|
|
105
|
+
export const ACT_POP_RECONSUME = 8;
|
|
106
|
+
export const ACT_QUOTED_FAST0 = 9;
|
|
107
|
+
export const ACT_QUOTED_FAST1 = 10;
|
|
108
|
+
export const ACT_LIT_GUARD = 11;
|
|
109
|
+
export const ACT_EMIT_SINGLE_BASE = 12;
|
|
110
|
+
export const ACT_EMIT_TRANS_BASE = 29;
|
|
111
|
+
export const ACT_DIRECT_BASE = 45;
|
|
112
|
+
export const ACT_CHAIN_BASE = 160;
|
|
113
|
+
export const MAX_EMIT_TRANS_SLOTS = 16;
|
|
114
|
+
let byteCCTable;
|
|
115
|
+
export function ensureByteCC() {
|
|
116
|
+
if (byteCCTable !== undefined)
|
|
117
|
+
return byteCCTable;
|
|
118
|
+
const t = new Uint8Array(256);
|
|
119
|
+
for (let b = 0;b < 256; b++) {
|
|
120
|
+
let c = 0;
|
|
121
|
+
if (b >= 97 && b <= 122 || b >= 65 && b <= 90) {
|
|
122
|
+
c |= CC_ALPHA;
|
|
123
|
+
} else if (b >= 48 && b <= 57) {
|
|
124
|
+
c |= CC_DIGIT;
|
|
125
|
+
} else if (b === 95) {
|
|
126
|
+
c |= CC_UNDER;
|
|
127
|
+
} else if (b >= 128) {
|
|
128
|
+
c |= CC_NONASCII;
|
|
129
|
+
} else if (b === 45) {
|
|
130
|
+
c |= CC_HYPHEN;
|
|
131
|
+
} else if (b === 46) {
|
|
132
|
+
c |= CC_DOT;
|
|
133
|
+
} else if (b === 58) {
|
|
134
|
+
c |= CC_COLON;
|
|
135
|
+
}
|
|
136
|
+
if (b !== 32 && b !== 9 && b !== 13 && b !== 10) {
|
|
137
|
+
c |= CC_NONSPACE;
|
|
138
|
+
}
|
|
139
|
+
t[b] = c;
|
|
140
|
+
}
|
|
141
|
+
byteCCTable = t;
|
|
142
|
+
return t;
|
|
143
|
+
}
|
|
144
|
+
export function charCC(byteCC, ch) {
|
|
145
|
+
return ch < 256 ? byteCC[ch] : CC_NONASCII_VAL;
|
|
146
|
+
}
|
|
147
|
+
export const EMPTY_MASK = new Uint8Array(0);
|
|
148
|
+
export function makeMask(s) {
|
|
149
|
+
const m = new Uint8Array(256);
|
|
150
|
+
for (let i = 0;i < s.length; i++) {
|
|
151
|
+
m[s.charCodeAt(i) & 255] = 1;
|
|
152
|
+
}
|
|
153
|
+
return m;
|
|
154
|
+
}
|
|
155
|
+
export function hasMask(m, ch) {
|
|
156
|
+
return ch < 256 && m.length > 0 && m[ch] !== 0;
|
|
157
|
+
}
|
|
158
|
+
export const STAY_TRANS = { op: TR_STAY, mode: 0, retMode: 255 };
|
|
159
|
+
export const DISABLED_FAST_IDENT = {
|
|
160
|
+
cont: new Uint8Array(256),
|
|
161
|
+
tableIdx: -1,
|
|
162
|
+
simple: false,
|
|
163
|
+
bangMacro: false,
|
|
164
|
+
callParen: false,
|
|
165
|
+
hasPrePat: false,
|
|
166
|
+
hasAfterPat: false,
|
|
167
|
+
hasKwdCallPat: false,
|
|
168
|
+
preGuard: EMPTY_MASK,
|
|
169
|
+
afterGuard: EMPTY_MASK,
|
|
170
|
+
afterKind: TokenKind.Plain,
|
|
171
|
+
kwdCallGuard: EMPTY_MASK,
|
|
172
|
+
prePatOff: 0,
|
|
173
|
+
afterPatOff: 0,
|
|
174
|
+
kwdCallPatOff: 0,
|
|
175
|
+
kwdCallSkipTable: -1,
|
|
176
|
+
fallbackKind: TokenKind.Plain,
|
|
177
|
+
wtFirstMask: EMPTY_MASK,
|
|
178
|
+
wordTrans: [],
|
|
179
|
+
nonTableWtMask: EMPTY_MASK,
|
|
180
|
+
nonTableWordTrans: [],
|
|
181
|
+
kwdTrans: STAY_TRANS,
|
|
182
|
+
trans: STAY_TRANS
|
|
183
|
+
};
|
|
184
|
+
export const DISABLED_FAST_QUOTED = {
|
|
185
|
+
stop: EMPTY_MASK,
|
|
186
|
+
quoteByte: 0,
|
|
187
|
+
emit: TokenKind.Plain,
|
|
188
|
+
multiline: false,
|
|
189
|
+
raw: false,
|
|
190
|
+
escapes: false,
|
|
191
|
+
colonKey: false,
|
|
192
|
+
trans: STAY_TRANS
|
|
193
|
+
};
|
|
194
|
+
export const execRes = { end: 0, tr: STAY_TRANS };
|
|
195
|
+
export function isWordSpace(c) {
|
|
196
|
+
return c === 32 || c === 9 || c === 13 || c === 10;
|
|
197
|
+
}
|
|
198
|
+
export function skipHSpace(src, pos) {
|
|
199
|
+
const n = src.length;
|
|
200
|
+
while (pos < n) {
|
|
201
|
+
const c = src.charCodeAt(pos);
|
|
202
|
+
if (c > 32 || c !== 32 && c !== 9)
|
|
203
|
+
break;
|
|
204
|
+
pos++;
|
|
205
|
+
}
|
|
206
|
+
return pos;
|
|
207
|
+
}
|
|
208
|
+
export function matchPrefixFold(src, pos, lowerPat) {
|
|
209
|
+
const plen = lowerPat.length;
|
|
210
|
+
if (src.length - pos < plen)
|
|
211
|
+
return false;
|
|
212
|
+
for (let i = 0;i < plen; i++) {
|
|
213
|
+
let c = src.charCodeAt(pos + i);
|
|
214
|
+
if (c >= 65 && c <= 90)
|
|
215
|
+
c += 32;
|
|
216
|
+
if (c !== lowerPat.charCodeAt(i))
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
export function skipCodePoint(src, pos) {
|
|
222
|
+
const c = src.charCodeAt(pos);
|
|
223
|
+
if (c >= 55296 && c <= 56319 && pos + 1 < src.length) {
|
|
224
|
+
const lo = src.charCodeAt(pos + 1);
|
|
225
|
+
if (lo >= 56320 && lo <= 57343)
|
|
226
|
+
return pos + 2;
|
|
227
|
+
}
|
|
228
|
+
return pos + 1;
|
|
229
|
+
}
|
|
230
|
+
export function lookupWordTransSpan(src, start, end, list) {
|
|
231
|
+
const len = end - start;
|
|
232
|
+
for (let i = 0;i < list.length; i++) {
|
|
233
|
+
const wt = list[i];
|
|
234
|
+
const w = wt.word;
|
|
235
|
+
if (w.length !== len)
|
|
236
|
+
continue;
|
|
237
|
+
let eq = true;
|
|
238
|
+
for (let j = 0;j < len; j++) {
|
|
239
|
+
if (src.charCodeAt(start + j) !== w.charCodeAt(j)) {
|
|
240
|
+
eq = false;
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (eq)
|
|
245
|
+
return wt;
|
|
246
|
+
}
|
|
247
|
+
return;
|
|
248
|
+
}
|
package/dist/vm/index.js
ADDED
package/dist/vm/pat.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Emitter } from "../engine.js";
|
|
2
|
+
import { type CompiledVM } from "./format.js";
|
|
3
|
+
export declare function execPatMatch(src: string, pos: number, cm: CompiledVM, off: number): boolean;
|
|
4
|
+
export declare function runPat(src: string, startPos: number, limit: number, capStart: number, capEnd: number, startOff: number, cm: CompiledVM, e: Emitter | undefined): number;
|