@thomasfosterau/effect-parse 0.4.1 → 0.6.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/CHANGELOG.md +202 -0
- package/README.md +56 -14
- package/dist/Ascii.d.ts +11 -4
- package/dist/Ascii.d.ts.map +1 -1
- package/dist/Ascii.js +12 -4
- package/dist/Ascii.js.map +1 -1
- package/dist/Binary.d.ts +5 -2
- package/dist/Binary.d.ts.map +1 -1
- package/dist/Binary.js +83 -37
- package/dist/Binary.js.map +1 -1
- package/dist/Bits.d.ts.map +1 -1
- package/dist/Bits.js +11 -4
- package/dist/Bits.js.map +1 -1
- package/dist/Compiler.d.ts +74 -2
- package/dist/Compiler.d.ts.map +1 -1
- package/dist/Compiler.js +78 -1
- package/dist/Compiler.js.map +1 -1
- package/dist/Expression.d.ts.map +1 -1
- package/dist/Expression.js +86 -74
- package/dist/Expression.js.map +1 -1
- package/dist/Input.d.ts +56 -5
- package/dist/Input.d.ts.map +1 -1
- package/dist/Input.js +70 -1
- package/dist/Input.js.map +1 -1
- package/dist/Nom.d.ts +5 -15
- package/dist/Nom.d.ts.map +1 -1
- package/dist/Nom.js.map +1 -1
- package/dist/ParseError.d.ts +69 -11
- package/dist/ParseError.d.ts.map +1 -1
- package/dist/ParseError.js +129 -28
- package/dist/ParseError.js.map +1 -1
- package/dist/Parser.d.ts +375 -29
- package/dist/Parser.d.ts.map +1 -1
- package/dist/Parser.js +394 -37
- package/dist/Parser.js.map +1 -1
- package/dist/ParserSchema.d.ts.map +1 -1
- package/dist/ParserSchema.js +2 -3
- package/dist/ParserSchema.js.map +1 -1
- package/dist/ParserStream.d.ts +122 -14
- package/dist/ParserStream.d.ts.map +1 -1
- package/dist/ParserStream.js +293 -62
- package/dist/ParserStream.js.map +1 -1
- package/dist/Syntax.d.ts +23 -5
- package/dist/Syntax.d.ts.map +1 -1
- package/dist/Syntax.js +1 -1
- package/dist/Syntax.js.map +1 -1
- package/dist/Text.d.ts.map +1 -1
- package/dist/Text.js +21 -15
- package/dist/Text.js.map +1 -1
- package/dist/Token.d.ts +65 -11
- package/dist/Token.d.ts.map +1 -1
- package/dist/Token.js +73 -26
- package/dist/Token.js.map +1 -1
- package/dist/internal/compiler/closure.d.ts +1 -1
- package/dist/internal/compiler/closure.d.ts.map +1 -1
- package/dist/internal/compiler/closure.js +263 -113
- package/dist/internal/compiler/closure.js.map +1 -1
- package/dist/internal/compiler/entries.d.ts +3 -1
- package/dist/internal/compiler/entries.d.ts.map +1 -1
- package/dist/internal/compiler/entries.js +3 -2
- package/dist/internal/compiler/entries.js.map +1 -1
- package/dist/internal/compiler/first.d.ts.map +1 -1
- package/dist/internal/compiler/first.js +9 -2
- package/dist/internal/compiler/first.js.map +1 -1
- package/dist/internal/compiler/graph.d.ts +39 -0
- package/dist/internal/compiler/graph.d.ts.map +1 -0
- package/dist/internal/compiler/graph.js +78 -0
- package/dist/internal/compiler/graph.js.map +1 -0
- package/dist/internal/compiler/jit.d.ts +5 -0
- package/dist/internal/compiler/jit.d.ts.map +1 -1
- package/dist/internal/compiler/jit.js +208 -106
- package/dist/internal/compiler/jit.js.map +1 -1
- package/dist/internal/compiler/registry.d.ts +11 -3
- package/dist/internal/compiler/registry.d.ts.map +1 -1
- package/dist/internal/compiler/registry.js.map +1 -1
- package/dist/internal/compiler/search.d.ts +32 -0
- package/dist/internal/compiler/search.d.ts.map +1 -0
- package/dist/internal/compiler/search.js +68 -0
- package/dist/internal/compiler/search.js.map +1 -0
- package/dist/internal/compiler/sets.d.ts.map +1 -1
- package/dist/internal/compiler/sets.js +1 -1
- package/dist/internal/compiler/sets.js.map +1 -1
- package/dist/internal/compiler/wasm.d.ts +8 -0
- package/dist/internal/compiler/wasm.d.ts.map +1 -0
- package/dist/internal/compiler/wasm.js +2840 -0
- package/dist/internal/compiler/wasm.js.map +1 -0
- package/dist/internal/compiler/wasmAsm.d.ts +199 -0
- package/dist/internal/compiler/wasmAsm.d.ts.map +1 -0
- package/dist/internal/compiler/wasmAsm.js +427 -0
- package/dist/internal/compiler/wasmAsm.js.map +1 -0
- package/dist/internal/entries.d.ts +3 -1
- package/dist/internal/entries.d.ts.map +1 -1
- package/dist/internal/entries.js.map +1 -1
- package/dist/internal/node.d.ts +77 -3
- package/dist/internal/node.d.ts.map +1 -1
- package/dist/internal/node.js +54 -10
- package/dist/internal/node.js.map +1 -1
- package/dist/internal/numbers.d.ts.map +1 -1
- package/dist/internal/numbers.js.map +1 -1
- package/dist/internal/run.d.ts +14 -0
- package/dist/internal/run.d.ts.map +1 -1
- package/dist/internal/run.js +53 -11
- package/dist/internal/run.js.map +1 -1
- package/dist/internal/stack.d.ts +14 -0
- package/dist/internal/stack.d.ts.map +1 -1
- package/dist/internal/stack.js +24 -2
- package/dist/internal/stack.js.map +1 -1
- package/dist/internal/syntax.d.ts +4 -4
- package/dist/internal/syntax.d.ts.map +1 -1
- package/dist/internal/syntax.js +18 -10
- package/dist/internal/syntax.js.map +1 -1
- package/dist/internal/text.d.ts +32 -0
- package/dist/internal/text.d.ts.map +1 -1
- package/dist/internal/text.js +68 -14
- package/dist/internal/text.js.map +1 -1
- package/dist/internal/tokens.d.ts +20 -0
- package/dist/internal/tokens.d.ts.map +1 -1
- package/dist/internal/tokens.js +72 -39
- package/dist/internal/tokens.js.map +1 -1
- package/dist/internal/tuple.d.ts +6 -0
- package/dist/internal/tuple.d.ts.map +1 -0
- package/dist/internal/tuple.js +170 -0
- package/dist/internal/tuple.js.map +1 -0
- package/package.json +18 -10
- package/src/Ascii.ts +47 -12
- package/src/Binary.ts +174 -73
- package/src/Bits.ts +16 -6
- package/src/Compiler.ts +101 -10
- package/src/Expression.ts +94 -81
- package/src/Input.ts +99 -7
- package/src/Nom.ts +15 -5
- package/src/ParseError.ts +209 -52
- package/src/Parser.ts +684 -143
- package/src/ParserSchema.ts +1 -2
- package/src/ParserStream.ts +361 -68
- package/src/Syntax.ts +60 -36
- package/src/Text.ts +32 -27
- package/src/Token.ts +152 -34
- package/src/internal/compiler/closure.ts +371 -153
- package/src/internal/compiler/entries.ts +4 -2
- package/src/internal/compiler/first.ts +16 -0
- package/src/internal/compiler/graph.ts +96 -0
- package/src/internal/compiler/jit.ts +319 -169
- package/src/internal/compiler/registry.ts +10 -2
- package/src/internal/compiler/search.ts +68 -0
- package/src/internal/compiler/sets.ts +7 -3
- package/src/internal/compiler/wasm.ts +3276 -0
- package/src/internal/compiler/wasmAsm.ts +484 -0
- package/src/internal/entries.ts +8 -2
- package/src/internal/node.ts +103 -7
- package/src/internal/numbers.ts +3 -1
- package/src/internal/run.ts +73 -12
- package/src/internal/stack.ts +25 -1
- package/src/internal/syntax.ts +39 -18
- package/src/internal/text.ts +97 -9
- package/src/internal/tokens.ts +106 -14
- package/src/internal/tuple.ts +141 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import * as Arr from "effect/Array";
|
|
2
|
+
// src/internal/compiler/search.ts
|
|
3
|
+
/**
|
|
4
|
+
* Searching for the stop characters of `Token.takeTill` on string input
|
|
5
|
+
* (#75): a run is scanned a unit at a time for `SearchHead` units, then
|
|
6
|
+
* found with `indexOf`, which V8 runs much faster on long runs. Both
|
|
7
|
+
* compilers use these; the interpreter scans unit by unit.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* How many units a compiled `takeTill` tests one at a time before it
|
|
11
|
+
* searches with `indexOf` (twice as many for several stop characters, whose
|
|
12
|
+
* cached search costs more): short runs, most tokens, are faster scanned.
|
|
13
|
+
*/
|
|
14
|
+
const SearchHead = 8;
|
|
15
|
+
/** The most stop characters a compiled `takeTill` searches for. */
|
|
16
|
+
const MaxStops = 3;
|
|
17
|
+
/**
|
|
18
|
+
* The stop characters of a `takeTill` set, as UTF-16 units, when there are
|
|
19
|
+
* one to `MaxStops` of them, each a whole code point (not a surrogate).
|
|
20
|
+
*/
|
|
21
|
+
const stopChars = (cs) => {
|
|
22
|
+
const ranges = cs.ranges;
|
|
23
|
+
if (ranges === void 0 || Arr.isReadonlyArrayEmpty(ranges) || ranges.length > MaxStops) return void 0;
|
|
24
|
+
if (!ranges.every(([a, b]) => a === b && (a < 55296 || a > 57343 && a <= 65535))) return void 0;
|
|
25
|
+
return ranges.map(([a]) => a);
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* The stop characters of one compiled `takeTill`, identifying its search site.
|
|
29
|
+
* The state holds, under this site, where each one next occurs (see
|
|
30
|
+
* `nextStop`).
|
|
31
|
+
*/
|
|
32
|
+
var StopCache = class {
|
|
33
|
+
chars;
|
|
34
|
+
constructor(chars) {
|
|
35
|
+
this.chars = chars;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The first index from `p` of any of `site.chars` in the input of `s`, or
|
|
40
|
+
* `s.end`. The state remembers, for each stop character `i`, the first
|
|
41
|
+
* index at or after `from` where it occurs (`-1` if none), as
|
|
42
|
+
* `[from, at]` at `2 * i` in `s.searches.get(site)`: successive runs over
|
|
43
|
+
* one input then pay a comparison per stop character instead of a search,
|
|
44
|
+
* and one that never occurs is searched for once.
|
|
45
|
+
*/
|
|
46
|
+
const nextStop = (site, s, p) => {
|
|
47
|
+
const searches = s.searches ??= /* @__PURE__ */ new Map();
|
|
48
|
+
let memo = searches.get(site);
|
|
49
|
+
if (memo === void 0) {
|
|
50
|
+
memo = site.chars.flatMap(() => [-1, -1]);
|
|
51
|
+
searches.set(site, memo);
|
|
52
|
+
}
|
|
53
|
+
let best = s.end;
|
|
54
|
+
for (let i = 0; i < site.chars.length; i++) {
|
|
55
|
+
const from = memo[2 * i];
|
|
56
|
+
let at = memo[2 * i + 1];
|
|
57
|
+
if (from < 0 || p < from || at >= 0 && at < p) {
|
|
58
|
+
at = s.input.indexOf(site.chars[i], p);
|
|
59
|
+
memo[2 * i] = p;
|
|
60
|
+
memo[2 * i + 1] = at;
|
|
61
|
+
}
|
|
62
|
+
if (at >= 0 && at < best) best = at;
|
|
63
|
+
}
|
|
64
|
+
return best;
|
|
65
|
+
};
|
|
66
|
+
export { SearchHead, StopCache, nextStop, stopChars };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","names":[],"sources":["../../../src/internal/compiler/search.ts"],"sourcesContent":["/**\n * Searching for the stop characters of `Token.takeTill` on string input\n * (#75): a run is scanned a unit at a time for `SearchHead` units, then\n * found with `indexOf`, which V8 runs much faster on long runs. Both\n * compilers use these; the interpreter scans unit by unit.\n */\nimport * as Arr from \"effect/Array\"\nimport type { State } from \"../../Input.js\"\nimport type { CharSet } from \"./sets.js\"\n\n/**\n * How many units a compiled `takeTill` tests one at a time before it\n * searches with `indexOf` (twice as many for several stop characters, whose\n * cached search costs more): short runs, most tokens, are faster scanned.\n */\nexport const SearchHead = 8\n\n/** The most stop characters a compiled `takeTill` searches for. */\nconst MaxStops = 3\n\n/**\n * The stop characters of a `takeTill` set, as UTF-16 units, when there are\n * one to `MaxStops` of them, each a whole code point (not a surrogate).\n */\nexport const stopChars = (cs: CharSet): ReadonlyArray<number> | undefined => {\n const ranges = cs.ranges\n if (ranges === undefined || Arr.isReadonlyArrayEmpty(ranges) || ranges.length > MaxStops) return undefined\n if (!ranges.every(([a, b]) => a === b && (a < 0xd800 || (a > 0xdfff && a <= 0xffff)))) return undefined\n return ranges.map(([a]) => a)\n}\n\n/**\n * The stop characters of one compiled `takeTill`, identifying its search site.\n * The state holds, under this site, where each one next occurs (see\n * `nextStop`).\n */\nexport class StopCache {\n constructor(readonly chars: ReadonlyArray<string>) {}\n}\n\n/**\n * The first index from `p` of any of `site.chars` in the input of `s`, or\n * `s.end`. The state remembers, for each stop character `i`, the first\n * index at or after `from` where it occurs (`-1` if none), as\n * `[from, at]` at `2 * i` in `s.searches.get(site)`: successive runs over\n * one input then pay a comparison per stop character instead of a search,\n * and one that never occurs is searched for once.\n */\nexport const nextStop = (site: StopCache, s: State<string>, p: number): number => {\n const searches = (s.searches ??= new Map())\n let memo = searches.get(site)\n if (memo === undefined) {\n memo = site.chars.flatMap(() => [-1, -1])\n searches.set(site, memo)\n }\n let best = s.end\n for (let i = 0; i < site.chars.length; i++) {\n const from = memo[2 * i]\n let at = memo[2 * i + 1]\n if (from < 0 || p < from || (at >= 0 && at < p)) {\n at = s.input.indexOf(site.chars[i], p)\n memo[2 * i] = p\n memo[2 * i + 1] = at\n }\n if (at >= 0 && at < best) best = at\n }\n return best\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAa,aAAa;;AAG1B,MAAM,WAAW;;;;;AAMjB,MAAa,aAAa,OAAmD;CAC3E,MAAM,SAAS,GAAG;CAClB,IAAI,WAAW,KAAA,KAAa,IAAI,qBAAqB,MAAM,KAAK,OAAO,SAAS,UAAU,OAAO,KAAA;CACjG,IAAI,CAAC,OAAO,OAAO,CAAC,GAAG,OAAO,MAAM,MAAM,IAAI,SAAW,IAAI,SAAU,KAAK,MAAQ,GAAG,OAAO,KAAA;CAC9F,OAAO,OAAO,KAAK,CAAC,OAAO,CAAC;AAC9B;;;;;;AAOA,IAAa,YAAb,MAAuB;CACA;CAArB,YAAY,OAAuC;EAA9B,KAAA,QAAA;CAA+B;AACtD;;;;;;;;;AAUA,MAAa,YAAY,MAAiB,GAAkB,MAAsB;CAChF,MAAM,WAAY,EAAE,6BAAa,IAAI,IAAI;CACzC,IAAI,OAAO,SAAS,IAAI,IAAI;CAC5B,IAAI,SAAS,KAAA,GAAW;EACtB,OAAO,KAAK,MAAM,cAAc,CAAC,IAAI,EAAE,CAAC;EACxC,SAAS,IAAI,MAAM,IAAI;CACzB;CACA,IAAI,OAAO,EAAE;CACb,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,MAAM,QAAQ,KAAK;EAC1C,MAAM,OAAO,KAAK,IAAI;EACtB,IAAI,KAAK,KAAK,IAAI,IAAI;EACtB,IAAI,OAAO,KAAK,IAAI,QAAS,MAAM,KAAK,KAAK,GAAI;GAC/C,KAAK,EAAE,MAAM,QAAQ,KAAK,MAAM,IAAI,CAAC;GACrC,KAAK,IAAI,KAAK;GACd,KAAK,IAAI,IAAI,KAAK;EACpB;EACA,IAAI,MAAM,KAAK,KAAK,MAAM,OAAO;CACnC;CACA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sets.d.ts","names":[],"sources":["../../../src/internal/compiler/sets.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"sets.d.ts","names":[],"sources":["../../../src/internal/compiler/sets.ts"],"mappings":";;qBAaa;iBAEI;;WAEN,OAAO;;WAEP,OAAO;;WAEP,QAAQ;;;qBAIN,cAAe,KAAK,SAAS,oBAAkB;;;;;qBAwE/C,WAAY,cAAc,gBAAc;;qBAMxC,UAAW,iBAAe;;qBAG1B,eAAgB,GAAG,SAAS;;qBAI5B,iBAAkB,KAAK"}
|
|
@@ -16,7 +16,7 @@ const acceptTable = (set, negate) => {
|
|
|
16
16
|
for (let c = 0; c < 256; c++) t[c] = set.table[c] === 1 !== negate ? 1 : 0;
|
|
17
17
|
return t;
|
|
18
18
|
};
|
|
19
|
-
const isRange = (u) => Predicate.isObjectOrArray(u) && u
|
|
19
|
+
const isRange = (u) => Predicate.isObjectOrArray(u) && Predicate.isTagged(u, "TokenRange");
|
|
20
20
|
const toCode = (u) => Predicate.isNumber(u) ? u : firstCodePoint(u);
|
|
21
21
|
/** The code point ranges of a token set, or `undefined` if it has an unknown predicate. */
|
|
22
22
|
const rangesOf = (set) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sets.js","names":[],"sources":["../../../src/internal/compiler/sets.ts"],"sourcesContent":["/**\n * Token sets for compiled parsers: membership tables for small units, the\n * exact test for the rest, and the code point ranges when they are known.\n */\nimport * as Arr from \"effect/Array\"\nimport * as Order from \"effect/Order\"\nimport * as Predicate from \"effect/Predicate\"\nimport type { Encoding } from \"../../Encoding.js\"\nimport { firstCodePoint } from \"../text.js\"\nimport { compile, compileAny, PredicateRanges } from \"../tokens.js\"\n\n/** Size of the membership table: every byte, and the Latin-1 code points. */\nexport const TableSize = 256\n\nexport interface CharSet {\n /** Tests a code point (or byte, for `Token` on bytes). */\n readonly test: (code: number) => boolean\n /** `table[c] === 1` iff `test(c)`, for `c < TableSize`. */\n readonly table: Uint8Array\n /** Sorted inclusive ranges of accepted code points, when known. */\n readonly ranges: ReadonlyArray<readonly [number, number]> | undefined\n}\n\n/** 1 where a small code is accepted (taking `negate` into account). */\nexport const acceptTable = (set: CharSet, negate: boolean): Uint8Array => {\n const t = new Uint8Array(TableSize)\n for (let c = 0; c < TableSize; c++) t[c] = (set.table[c] === 1) !== negate ? 1 : 0\n return t\n}\n\nconst isRange = (u: unknown): u is
|
|
1
|
+
{"version":3,"file":"sets.js","names":[],"sources":["../../../src/internal/compiler/sets.ts"],"sourcesContent":["/**\n * Token sets for compiled parsers: membership tables for small units, the\n * exact test for the rest, and the code point ranges when they are known.\n */\nimport * as Arr from \"effect/Array\"\nimport * as Order from \"effect/Order\"\nimport * as Predicate from \"effect/Predicate\"\nimport type { Encoding } from \"../../Encoding.js\"\nimport { firstCodePoint } from \"../text.js\"\nimport type { TokenRangeLike } from \"../tokens.js\"\nimport { compile, compileAny, PredicateRanges } from \"../tokens.js\"\n\n/** Size of the membership table: every byte, and the Latin-1 code points. */\nexport const TableSize = 256\n\nexport interface CharSet {\n /** Tests a code point (or byte, for `Token` on bytes). */\n readonly test: (code: number) => boolean\n /** `table[c] === 1` iff `test(c)`, for `c < TableSize`. */\n readonly table: Uint8Array\n /** Sorted inclusive ranges of accepted code points, when known. */\n readonly ranges: ReadonlyArray<readonly [number, number]> | undefined\n}\n\n/** 1 where a small code is accepted (taking `negate` into account). */\nexport const acceptTable = (set: CharSet, negate: boolean): Uint8Array => {\n const t = new Uint8Array(TableSize)\n for (let c = 0; c < TableSize; c++) t[c] = (set.table[c] === 1) !== negate ? 1 : 0\n return t\n}\n\nconst isRange = (u: unknown): u is TokenRangeLike => Predicate.isObjectOrArray(u) && Predicate.isTagged(u, \"TokenRange\")\n\nconst toCode = (u: string | number): number => (Predicate.isNumber(u) ? u : firstCodePoint(u))\n\n/** The code point ranges of a token set, or `undefined` if it has an unknown predicate. */\nconst rangesOf = (set: unknown): Array<[number, number]> | undefined => {\n const out: Array<[number, number]> = []\n const add = (u: unknown): boolean => {\n if (Predicate.isString(u)) {\n for (const c of u) {\n const cp = firstCodePoint(c)\n out.push([cp, cp])\n }\n return true\n }\n if (Predicate.isNumber(u)) {\n out.push([u, u])\n return true\n }\n if (u instanceof Uint8Array) {\n for (const b of u) out.push([b, b])\n return true\n }\n if (isRange(u)) {\n out.push([toCode(u.from), toCode(u.to)])\n return true\n }\n if (Predicate.isFunction(u)) {\n // SAFETY: `codePointPredicate` is the only writer of `PredicateRanges`, and it stores the\n // predicate's sorted inclusive code point ranges there (or nothing)\n const r = (u as { readonly [PredicateRanges]?: ReadonlyArray<readonly [number, number]> | undefined })[\n PredicateRanges\n ]\n if (r === undefined) return false\n for (const [a, b] of r) out.push([a, b])\n return true\n }\n if (Array.isArray(u)) return u.every(add)\n return false\n }\n if (!add(set)) return undefined\n const merged: Array<[number, number]> = []\n for (const [a, b] of Arr.sort(\n out,\n Order.mapInput(Order.Number, (range: readonly [number, number]) => range[0])\n )) {\n if (b < a) continue\n const last = merged[merged.length - 1]\n if (last !== undefined && a <= last[1] + 1) last[1] = Math.max(last[1], b)\n else merged.push([a, b])\n }\n return merged\n}\n\nconst makeSet = (test: (code: number) => boolean, set: unknown): CharSet => {\n // The table calls the test once per small code: token-set predicates are\n // assumed to be pure (see the design notes).\n const table = new Uint8Array(TableSize)\n for (let c = 0; c < TableSize; c++) table[c] = test(c) ? 1 : 0\n return { test, table, ranges: rangesOf(set) }\n}\n\n/**\n * The set as a `Token` parser sees it: string predicates receive strings on\n * string input, everything receives numbers on byte input.\n */\nexport const tokenSet = (set: unknown, kind: 0 | 1): CharSet => {\n const m = compileAny(set)\n return makeSet(kind === 0 ? m.forString.code : m.forCode.code, set)\n}\n\n/** The set as a `Text` parser sees it: code points, for any encoding. */\nexport const textSet = (set: unknown): CharSet => makeSet(compile(set, \"string\").code, set)\n\n/** Whether some accepted code point is at least `limit` (true when unknown). */\nexport const reachesAbove = (s: CharSet, limit: number): boolean =>\n s.ranges === undefined || s.ranges.some(([, b]) => b >= limit)\n\n/** The input kind a `Text` encoding reads: 0 for strings, 1 for bytes. */\nexport const kindOfEncoding = (enc: Encoding<any>): 0 | 1 => {\n let k = kinds.get(enc)\n if (k === undefined) kinds.set(enc, (k = Predicate.isString(enc.encode(\"\")) ? 0 : 1))\n return k\n}\n\nconst kinds = /*#__PURE__*/ new WeakMap<Encoding<any>, 0 | 1>()\n"],"mappings":"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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Backend } from "./registry.js";
|
|
2
|
+
/**
|
|
3
|
+
* The WebAssembly compiler as a backend. Streaming builds, array input and
|
|
4
|
+
* environments without `WebAssembly` or `new Function` use the JIT, as does
|
|
5
|
+
* a parser whose module fails to build.
|
|
6
|
+
*/
|
|
7
|
+
export declare const backend: Backend;
|
|
8
|
+
//# sourceMappingURL=wasm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm.d.ts","names":[],"sources":["../../../src/internal/compiler/wasm.ts"],"mappings":";;;;;;qBA8rGa,SAAS"}
|