@criogaid/pi-hashline-edit 0.11.0 → 0.13.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/LICENSE +1 -0
- package/README.md +73 -17
- package/README.zh-CN.md +74 -18
- package/package.json +8 -7
- package/src/core/AGENTS.md +2 -2
- package/src/core/apply.test.ts +15 -2
- package/src/core/apply.ts +6 -10
- package/src/core/case-fold.test.ts +16 -25
- package/src/core/case-fold.ts +4 -4
- package/src/core/character-set.test.ts +1 -6
- package/src/core/character-set.ts +7 -61
- package/src/core/regex.ts +2 -32
- package/src/core/replace.test.ts +51 -0
- package/src/core/replace.ts +10 -4
- package/src/core/search-analysis.test.ts +66 -61
- package/src/core/search-analysis.ts +24 -39
- package/src/core/search-matrix.test.ts +2 -2
- package/src/core/search-matrix.testing.ts +6 -16
- package/src/core/search-schema.ts +0 -1
- package/src/core/search.test.ts +6 -19
- package/src/core/search.ts +10 -8
- package/src/index.ts +28 -3
- package/src/integration/config-registration.test.ts +77 -4
- package/src/integration/fusion-dispatch.test.ts +47 -2
- package/src/integration/grep-errors.test.ts +31 -0
- package/src/integration/grep-flags.test.ts +13 -196
- package/src/integration/grep-js-completeness.test.ts +41 -8
- package/src/integration/grep-line-candidates.test.ts +4 -33
- package/src/integration/grep-matrix.test.ts +1 -1
- package/src/integration/grep-path-matrix.test.ts +59 -65
- package/src/integration/grep-prefilter-coverage.test.ts +26 -8
- package/src/integration/grep-process-limits.test.ts +46 -0
- package/src/integration/grep-regex.test.ts +7 -2
- package/src/integration/grep-rg.test.ts +106 -12
- package/src/integration/grep-translation.test.ts +14 -7
- package/src/integration/model-budget-lifecycle.test.ts +41 -2
- package/src/integration/npm-package.test.ts +12 -10
- package/src/integration/npm-package.testing.ts +147 -1
- package/src/integration/replace-package.testing.ts +2 -2
- package/src/integration/report-replay.test.ts +4 -0
- package/src/pi/AGENTS.md +23 -15
- package/src/pi/action-fusion.test.ts +38 -4
- package/src/pi/action-fusion.ts +23 -19
- package/src/pi/argument-diagnostics.ts +28 -48
- package/src/pi/argument-validation.test.ts +103 -6
- package/src/pi/argument-validation.ts +55 -31
- package/src/pi/budgets.ts +19 -10
- package/src/pi/config.test.ts +1 -1
- package/src/pi/diagnostic-buffer.test.ts +1 -0
- package/src/pi/edit-tool.ts +3 -3
- package/src/pi/execute.test.ts +4 -0
- package/src/pi/failure-context.test.ts +24 -3
- package/src/pi/failure-context.ts +36 -42
- package/src/pi/failure-path.test.ts +8 -3
- package/src/pi/file-commit.test.ts +109 -52
- package/src/pi/file-commit.ts +62 -56
- package/src/pi/fusion-card.ts +12 -7
- package/src/pi/grep-candidates.test.ts +5 -5
- package/src/pi/grep-candidates.ts +80 -48
- package/src/pi/grep-matrix.test.ts +14 -29
- package/src/pi/grep-order.test.ts +132 -9
- package/src/pi/grep-output.ts +173 -48
- package/src/pi/grep-render.ts +40 -34
- package/src/pi/grep-rg.testing.ts +9 -6
- package/src/pi/grep-scope.ts +51 -29
- package/src/pi/grep-search.ts +96 -71
- package/src/pi/grep-tool.ts +28 -34
- package/src/pi/grep.test.ts +348 -83
- package/src/pi/model-budgets.test.ts +56 -6
- package/src/pi/model-budgets.ts +7 -4
- package/src/pi/mutation-result.test.ts +25 -1
- package/src/pi/mutation-result.ts +7 -2
- package/src/pi/mutation-runner.ts +4 -5
- package/src/pi/output-budgets.test.ts +3 -1
- package/src/pi/path.ts +18 -4
- package/src/pi/pi.test.ts +22 -0
- package/src/pi/read-delegation.test.ts +119 -0
- package/src/pi/read-tool.ts +109 -61
- package/src/pi/read.test.ts +351 -17
- package/src/pi/regex-worker.test.ts +42 -0
- package/src/pi/regex-worker.ts +17 -11
- package/src/pi/registration.test.ts +157 -102
- package/src/pi/render.test.ts +97 -0
- package/src/pi/render.ts +9 -9
- package/src/pi/replace-tool.ts +5 -2
- package/src/pi/report-schema.ts +75 -37
- package/src/pi/report.test.ts +73 -31
- package/src/pi/report.ts +12 -5
- package/src/pi/rg-process.ts +41 -5
- package/src/pi/rg-regex.test.ts +12 -39
- package/src/pi/rg-regex.ts +31 -79
- package/src/pi/text-stream.test.ts +3 -0
- package/src/pi/text-stream.ts +1 -1
- package/src/testing/regex-translation-corpus.ts +39 -96
package/src/pi/rg-regex.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* may be dropped and an element may match more text, but nothing a match needs is removed.
|
|
7
7
|
*
|
|
8
8
|
* Original line bytes differ from the LF view in three ways, each widened here: a CRLF line
|
|
9
|
-
* keeps its CR before the line feed, malformed UTF-8 is U+FFFD in the view, and
|
|
10
|
-
*
|
|
9
|
+
* keeps its CR before the line feed, malformed UTF-8 is U+FFFD in the view, and a consuming
|
|
10
|
+
* element can match half of a supplementary character, since grep regexes have no u flag.
|
|
11
11
|
*
|
|
12
12
|
* @module pi-hashline-edit/pi
|
|
13
13
|
*/
|
|
@@ -22,13 +22,12 @@ import {
|
|
|
22
22
|
nativeCharacterRanges,
|
|
23
23
|
foldRanges,
|
|
24
24
|
type Ranges,
|
|
25
|
-
acceptedClassStrings,
|
|
26
25
|
type CharacterNode,
|
|
27
26
|
surrogatePair,
|
|
28
27
|
} from "../core/character-set.ts";
|
|
29
28
|
import { analyzeQueryPattern } from "../core/search-analysis.ts";
|
|
30
|
-
import type
|
|
31
|
-
import { MAX_RG_PATTERN_UNITS } from "./rg-process.ts";
|
|
29
|
+
import { GREP_FLAGS, type GrepQuery } from "../core/search.ts";
|
|
30
|
+
import { MAX_RG_PATTERN_UNITS, rgPatternArgUnits } from "./rg-process.ts";
|
|
32
31
|
|
|
33
32
|
const LF = 0x0a;
|
|
34
33
|
const REPLACEMENT = 0xfffd;
|
|
@@ -36,8 +35,6 @@ const SURROGATES: Ranges = [[0xd800, 0xdfff]];
|
|
|
36
35
|
const SUPPLEMENTARY: Ranges = [[0x10000, MAX_SCALAR]];
|
|
37
36
|
/** Repetition counts above this become unbounded, keeping rg's compiled size small. */
|
|
38
37
|
const MAX_EXACT_REPEAT = 16;
|
|
39
|
-
/** Bound expanded class strings by total code points, counting an empty string as one. */
|
|
40
|
-
const MAX_EXPANDED_STRING_POINTS = 256;
|
|
41
38
|
|
|
42
39
|
/** The bytes a lossy decoder shows as U+FFFD: every byte of a malformed sequence is 0x80–0xFF. */
|
|
43
40
|
const MALFORMED = "(?-u:[\\x80-\\xff])+";
|
|
@@ -51,10 +48,6 @@ interface Context {
|
|
|
51
48
|
readonly ignoreCase: boolean;
|
|
52
49
|
/** The i flag, which modifier groups override. */
|
|
53
50
|
readonly flagIgnoreCase: boolean;
|
|
54
|
-
readonly flagDotAll: boolean;
|
|
55
|
-
/** u or v: elements consume code points, not UTF-16 units. */
|
|
56
|
-
readonly unicode: boolean;
|
|
57
|
-
readonly unicodeSets: boolean;
|
|
58
51
|
readonly multilineAnchors: boolean;
|
|
59
52
|
/** Translating a group as the text a backreference repeats, away from where it matched. */
|
|
60
53
|
readonly repeated: boolean;
|
|
@@ -70,7 +63,7 @@ const INNER: Position = { first: false, last: false };
|
|
|
70
63
|
const intersects = (ranges: Ranges, other: Ranges) => intersect(ranges, other).length !== 0;
|
|
71
64
|
|
|
72
65
|
const folded = (ranges: Ranges, ctx: Context): Ranges =>
|
|
73
|
-
ctx.ignoreCase ? foldRanges(ranges
|
|
66
|
+
ctx.ignoreCase ? foldRanges(ranges) : ranges;
|
|
74
67
|
|
|
75
68
|
/** One code point in an rg pattern; every non-word character is a code point escape. */
|
|
76
69
|
export const rgCodePoint = (point: number) =>
|
|
@@ -84,12 +77,12 @@ function classPattern(ranges: Ranges): string {
|
|
|
84
77
|
}
|
|
85
78
|
|
|
86
79
|
/**
|
|
87
|
-
* One consuming element over the units
|
|
88
|
-
*
|
|
89
|
-
*
|
|
80
|
+
* One consuming element over the UTF-16 units it can match. U+FFFD may be malformed bytes.
|
|
81
|
+
* A surrogate may be half of a supplementary character: the element then consumes the whole
|
|
82
|
+
* character or nothing, and its neighbour consumes the other half.
|
|
90
83
|
*/
|
|
91
|
-
function unit(ranges: Ranges
|
|
92
|
-
const halves =
|
|
84
|
+
function unit(ranges: Ranges): string {
|
|
85
|
+
const halves = intersects(ranges, SURROGATES);
|
|
93
86
|
let scalars = subtract(ranges, [[LF, LF], ...SURROGATES]);
|
|
94
87
|
if (halves) scalars = normalize([...scalars, ...SUPPLEMENTARY]);
|
|
95
88
|
const alternatives = [
|
|
@@ -114,56 +107,23 @@ function flagAt(node: AST.Node, flag: "ignoreCase" | "dotAll", patternFlag: bool
|
|
|
114
107
|
const ignoreCaseAt = (node: AST.Node, ctx: Context) =>
|
|
115
108
|
flagAt(node, "ignoreCase", ctx.flagIgnoreCase);
|
|
116
109
|
|
|
110
|
+
/** Grep regexes have no s flag; only a modifier group sets dotAll. */
|
|
117
111
|
function nativeFlags(node: AST.Node, ctx: Context): string {
|
|
118
|
-
|
|
119
|
-
return `${ignoreCaseAt(node, ctx) ? "i" : ""}${dotAll ? "s" : ""}${ctx.unicodeSets ? "v" : ctx.unicode ? "u" : ""}`;
|
|
112
|
+
return `${ignoreCaseAt(node, ctx) ? "i" : ""}${flagAt(node, "dotAll", false) ? "s" : ""}`;
|
|
120
113
|
}
|
|
121
114
|
|
|
122
115
|
function scalarRanges(node: CharacterNode, ctx: Context): Ranges {
|
|
123
116
|
const ranges = nativeCharacterRanges(node.raw, nativeFlags(node, ctx));
|
|
124
|
-
//
|
|
125
|
-
return ctx.repeated
|
|
117
|
+
// Reference comparison can widen even a capture whose native class already uses i.
|
|
118
|
+
return ctx.repeated ? folded(ranges, ctx) : ranges;
|
|
126
119
|
}
|
|
127
120
|
|
|
128
121
|
const choice = (patterns: readonly string[]): string =>
|
|
129
122
|
patterns.length === 0 ? NEVER : patterns.length === 1 ? patterns[0] : `(?:${patterns.join("|")})`;
|
|
130
123
|
|
|
131
|
-
/** Factor common prefixes without dropping an alternative or cutting a code point escape. */
|
|
132
|
-
function wordTree(words: readonly (readonly number[])[], ctx: Context): string {
|
|
133
|
-
const branches = new Map<number, number[][]>();
|
|
134
|
-
let empty = false;
|
|
135
|
-
for (const word of words) {
|
|
136
|
-
if (!word.length) {
|
|
137
|
-
empty = true;
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
const branch = branches.get(word[0]) ?? [];
|
|
141
|
-
branch.push(word.slice(1));
|
|
142
|
-
branches.set(word[0], branch);
|
|
143
|
-
}
|
|
144
|
-
const patterns = [...branches].map(
|
|
145
|
-
([point, tails]) => unit(folded([[point, point]], ctx), ctx) + wordTree(tails, ctx),
|
|
146
|
-
);
|
|
147
|
-
if (empty) patterns.push("");
|
|
148
|
-
return choice(patterns);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function stringPattern(strings: readonly string[], ctx: Context): string {
|
|
152
|
-
const words = [...new Set(strings)].map((text) => [...text].map((char) => char.codePointAt(0)!));
|
|
153
|
-
const size = words.reduce((sum, word) => sum + Math.max(1, word.length), 0);
|
|
154
|
-
return size <= MAX_EXPANDED_STRING_POINTS ? wordTree(words, ctx) : ANY_TEXT;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
124
|
function characterPattern(node: CharacterNode, ctx: Context): string {
|
|
158
|
-
const accepted = acceptedClassStrings(node, nativeFlags(node, ctx));
|
|
159
|
-
if (!accepted) return ANY_TEXT;
|
|
160
125
|
const ranges = scalarRanges(node, ctx);
|
|
161
|
-
return
|
|
162
|
-
...(ranges.length ? [unit(ranges, ctx)] : []),
|
|
163
|
-
...(accepted.length
|
|
164
|
-
? [stringPattern(accepted, { ...ctx, ignoreCase: ctx.ignoreCase || ignoreCaseAt(node, ctx) })]
|
|
165
|
-
: []),
|
|
166
|
-
]);
|
|
126
|
+
return ranges.length ? unit(ranges) : NEVER;
|
|
167
127
|
}
|
|
168
128
|
|
|
169
129
|
function assertion(node: AST.Assertion, ctx: Context, position: Position): string {
|
|
@@ -181,12 +141,10 @@ function assertion(node: AST.Assertion, ctx: Context, position: Position): strin
|
|
|
181
141
|
if (!position.last) return "";
|
|
182
142
|
return ctx.multilineAnchors ? `(?:${TERMINATORS}|\\r?$)` : "\\r?$";
|
|
183
143
|
case "word":
|
|
184
|
-
// JavaScript and rg agree on ASCII word boundaries over valid text and malformed bytes
|
|
185
|
-
//
|
|
186
|
-
//
|
|
187
|
-
|
|
188
|
-
if (node.negate) return ctx.unicode ? "(?-u:\\B)" : "";
|
|
189
|
-
return "(?-u:\\b)";
|
|
144
|
+
// JavaScript and rg agree on ASCII word boundaries over valid text and malformed bytes;
|
|
145
|
+
// \B also holds between the two halves of a supplementary character, which rg consumes
|
|
146
|
+
// as one.
|
|
147
|
+
return node.negate ? "" : "(?-u:\\b)";
|
|
190
148
|
default:
|
|
191
149
|
if (!node.negate && position.first && position.last)
|
|
192
150
|
return alternatives(node.alternatives, ctx, INNER);
|
|
@@ -231,11 +189,11 @@ function participates(group: AST.CapturingGroup, reference: AST.Backreference):
|
|
|
231
189
|
for (let node: AST.Node | null = group; node; node = node.parent) ancestors.add(node);
|
|
232
190
|
let referenceChild: AST.Node = reference;
|
|
233
191
|
let common: AST.Node | null = reference.parent;
|
|
234
|
-
while (
|
|
192
|
+
while (!ancestors.has(common)) {
|
|
235
193
|
referenceChild = common;
|
|
236
194
|
common = common.parent;
|
|
237
195
|
}
|
|
238
|
-
if (common
|
|
196
|
+
if (common.type !== "Alternative") return false;
|
|
239
197
|
let groupChild: AST.Node = group;
|
|
240
198
|
for (let node: AST.Node = group.parent; node !== common; node = node.parent!) {
|
|
241
199
|
const kept =
|
|
@@ -284,7 +242,7 @@ function element(node: AST.Element, ctx: Context, position: Position): string {
|
|
|
284
242
|
switch (node.type) {
|
|
285
243
|
case "Character":
|
|
286
244
|
if (node.value === LF) return NEVER;
|
|
287
|
-
return unit(folded([[node.value, node.value]], ctx)
|
|
245
|
+
return unit(folded([[node.value, node.value]], ctx));
|
|
288
246
|
case "CharacterClass":
|
|
289
247
|
case "ExpressionCharacterClass":
|
|
290
248
|
case "CharacterSet":
|
|
@@ -307,7 +265,7 @@ function alternatives(nodes: readonly AST.Alternative[], ctx: Context, position:
|
|
|
307
265
|
nodes.map(({ elements }) => {
|
|
308
266
|
let pattern = "";
|
|
309
267
|
for (let index = 0; index < elements.length; index++) {
|
|
310
|
-
const pair =
|
|
268
|
+
const pair = surrogatePair(elements[index], elements[index + 1]);
|
|
311
269
|
if (pair !== undefined) {
|
|
312
270
|
pattern += classPattern([[pair, pair]]);
|
|
313
271
|
index++;
|
|
@@ -329,27 +287,21 @@ function alternatives(nodes: readonly AST.Alternative[], ctx: Context, position:
|
|
|
329
287
|
*/
|
|
330
288
|
export function lineCandidatePatterns(query: GrepQuery): string[] | undefined {
|
|
331
289
|
const ctx: Context = {
|
|
332
|
-
ignoreCase: query.
|
|
333
|
-
flagIgnoreCase: query.
|
|
334
|
-
|
|
335
|
-
unicode: query.flags.includes("u") || query.flags.includes("v"),
|
|
336
|
-
unicodeSets: query.flags.includes("v"),
|
|
337
|
-
multilineAnchors: query.flags.includes("m"),
|
|
290
|
+
ignoreCase: query.ignoreCase,
|
|
291
|
+
flagIgnoreCase: query.ignoreCase,
|
|
292
|
+
multilineAnchors: GREP_FLAGS.includes("m"),
|
|
338
293
|
repeated: false,
|
|
339
294
|
};
|
|
340
295
|
const patterns: string[] = [];
|
|
296
|
+
let argumentUnits = 0;
|
|
341
297
|
for (const pattern of query.patterns) {
|
|
342
|
-
const translated = analyzeQueryPattern(pattern, query.literal,
|
|
298
|
+
const translated = analyzeQueryPattern(pattern, query.literal, (parsed) =>
|
|
343
299
|
alternatives(parsed.alternatives, ctx, { first: true, last: true }),
|
|
344
300
|
);
|
|
345
301
|
if (translated === undefined) return undefined;
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
)
|
|
350
|
-
return undefined;
|
|
351
|
-
// A sticky match starts where the line starts.
|
|
352
|
-
patterns.push(query.flags.includes("y") ? `^(?:${translated})` : translated);
|
|
302
|
+
argumentUnits += rgPatternArgUnits(translated);
|
|
303
|
+
if (argumentUnits > MAX_RG_PATTERN_UNITS) return undefined;
|
|
304
|
+
patterns.push(translated);
|
|
353
305
|
}
|
|
354
306
|
return patterns;
|
|
355
307
|
}
|
|
@@ -43,6 +43,7 @@ test("streamed lines preserve BOM, standalone CR, and boundaries split across ch
|
|
|
43
43
|
assert.equal(line.byteLength, Buffer.byteLength(line.text!));
|
|
44
44
|
lines.push(line.text!);
|
|
45
45
|
},
|
|
46
|
+
{},
|
|
46
47
|
);
|
|
47
48
|
assert.deepEqual(lines, splitLines(text));
|
|
48
49
|
assert.equal(stats.totalLines, lines.length);
|
|
@@ -76,6 +77,7 @@ test("streamed scans → return the revision of every original byte and byte-bas
|
|
|
76
77
|
path,
|
|
77
78
|
(number) => number === 1,
|
|
78
79
|
() => {},
|
|
80
|
+
{},
|
|
79
81
|
);
|
|
80
82
|
assert.equal(selected.revision, stats.revision);
|
|
81
83
|
}
|
|
@@ -110,6 +112,7 @@ test("streamed validation checks the entire file and gives NUL precedence over m
|
|
|
110
112
|
path,
|
|
111
113
|
(number) => number === 1,
|
|
112
114
|
() => {},
|
|
115
|
+
{},
|
|
113
116
|
),
|
|
114
117
|
(error: unknown) => error instanceof Utf8DecodingError,
|
|
115
118
|
);
|
package/src/pi/text-stream.ts
CHANGED
|
@@ -109,7 +109,7 @@ export async function scanTextLines(
|
|
|
109
109
|
readonly signal?: AbortSignal;
|
|
110
110
|
readonly maxLineBytes?: number;
|
|
111
111
|
readonly decoding?: Utf8Decoding;
|
|
112
|
-
}
|
|
112
|
+
},
|
|
113
113
|
) {
|
|
114
114
|
const { signal, decoding, maxLineBytes: maxBytes = Infinity } = options;
|
|
115
115
|
let number = 1;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
export interface RegexWitness {
|
|
7
7
|
readonly pattern: string;
|
|
8
|
-
readonly
|
|
8
|
+
readonly ignoreCase: boolean;
|
|
9
9
|
readonly hits: readonly string[];
|
|
10
10
|
readonly misses: readonly string[];
|
|
11
11
|
readonly rejectCandidates: boolean;
|
|
@@ -18,7 +18,7 @@ const local = "JS-to-rg translation contract";
|
|
|
18
18
|
export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
19
19
|
{
|
|
20
20
|
pattern: "(?:([])\\1|b)",
|
|
21
|
-
|
|
21
|
+
ignoreCase: false,
|
|
22
22
|
hits: ["b"],
|
|
23
23
|
misses: ["a"],
|
|
24
24
|
rejectCandidates: true,
|
|
@@ -26,7 +26,7 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
28
|
pattern: "(?!a)[a-z]",
|
|
29
|
-
|
|
29
|
+
ignoreCase: false,
|
|
30
30
|
hits: ["b", "z"],
|
|
31
31
|
misses: ["a", "A"],
|
|
32
32
|
rejectCandidates: false,
|
|
@@ -34,7 +34,7 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
36
|
pattern: "(?=ab)a[bcd]",
|
|
37
|
-
|
|
37
|
+
ignoreCase: false,
|
|
38
38
|
hits: ["ab"],
|
|
39
39
|
misses: ["ac", "ad"],
|
|
40
40
|
rejectCandidates: false,
|
|
@@ -42,7 +42,7 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
pattern: "[a-z](?<=b)",
|
|
45
|
-
|
|
45
|
+
ignoreCase: false,
|
|
46
46
|
hits: ["b"],
|
|
47
47
|
misses: ["a", "c"],
|
|
48
48
|
rejectCandidates: false,
|
|
@@ -50,7 +50,7 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
52
|
pattern: "(?!ab)[a-z]{2}",
|
|
53
|
-
|
|
53
|
+
ignoreCase: false,
|
|
54
54
|
hits: ["ac", "ba"],
|
|
55
55
|
misses: ["ab"],
|
|
56
56
|
rejectCandidates: false,
|
|
@@ -58,7 +58,7 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
pattern: "[a-z]{2}(?<!ab)",
|
|
61
|
-
|
|
61
|
+
ignoreCase: false,
|
|
62
62
|
hits: ["ac", "ba"],
|
|
63
63
|
misses: ["ab"],
|
|
64
64
|
rejectCandidates: false,
|
|
@@ -66,15 +66,15 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
68
|
pattern: "(?i:(?!k)[a-z])",
|
|
69
|
-
|
|
70
|
-
hits: ["a"
|
|
71
|
-
misses: ["k", "K", "K"],
|
|
69
|
+
ignoreCase: false,
|
|
70
|
+
hits: ["a"],
|
|
71
|
+
misses: ["k", "K", "K", "ſ"],
|
|
72
72
|
rejectCandidates: false,
|
|
73
73
|
source: local,
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
76
|
pattern: "a\\b[ a]",
|
|
77
|
-
|
|
77
|
+
ignoreCase: false,
|
|
78
78
|
hits: ["a "],
|
|
79
79
|
misses: ["aa"],
|
|
80
80
|
rejectCandidates: true,
|
|
@@ -82,23 +82,23 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
84
|
pattern: "k\\b[\\w ]",
|
|
85
|
-
|
|
86
|
-
hits: ["k "
|
|
87
|
-
misses: ["kk", "Kk"],
|
|
85
|
+
ignoreCase: true,
|
|
86
|
+
hits: ["k "],
|
|
87
|
+
misses: ["kk", "Kk", "K "],
|
|
88
88
|
rejectCandidates: false,
|
|
89
89
|
source: local,
|
|
90
90
|
},
|
|
91
91
|
{
|
|
92
92
|
pattern: "(?m:[\\ra]^b)",
|
|
93
|
-
|
|
93
|
+
ignoreCase: false,
|
|
94
94
|
hits: ["\rb"],
|
|
95
95
|
misses: ["ab"],
|
|
96
96
|
rejectCandidates: false,
|
|
97
97
|
source: local,
|
|
98
98
|
},
|
|
99
99
|
{
|
|
100
|
-
pattern: "a^b",
|
|
101
|
-
|
|
100
|
+
pattern: "(?-m:a^b)",
|
|
101
|
+
ignoreCase: false,
|
|
102
102
|
hits: [],
|
|
103
103
|
misses: ["ab", "a^b"],
|
|
104
104
|
rejectCandidates: true,
|
|
@@ -106,7 +106,7 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
106
106
|
},
|
|
107
107
|
{
|
|
108
108
|
pattern: "(?=needle)",
|
|
109
|
-
|
|
109
|
+
ignoreCase: false,
|
|
110
110
|
hits: ["needle"],
|
|
111
111
|
misses: ["haystack"],
|
|
112
112
|
rejectCandidates: true,
|
|
@@ -114,7 +114,7 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
114
114
|
},
|
|
115
115
|
{
|
|
116
116
|
pattern: "(?<=needle)",
|
|
117
|
-
|
|
117
|
+
ignoreCase: false,
|
|
118
118
|
hits: ["needle"],
|
|
119
119
|
misses: ["haystack"],
|
|
120
120
|
rejectCandidates: true,
|
|
@@ -122,7 +122,7 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
122
122
|
},
|
|
123
123
|
{
|
|
124
124
|
pattern: "(?<=(a)\\1)",
|
|
125
|
-
|
|
125
|
+
ignoreCase: false,
|
|
126
126
|
hits: ["a", "ab"],
|
|
127
127
|
misses: ["b"],
|
|
128
128
|
rejectCandidates: true,
|
|
@@ -130,7 +130,7 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
130
130
|
},
|
|
131
131
|
{
|
|
132
132
|
pattern: "(?<=\\1(a))",
|
|
133
|
-
|
|
133
|
+
ignoreCase: false,
|
|
134
134
|
hits: ["aa"],
|
|
135
135
|
misses: ["a", "ab"],
|
|
136
136
|
rejectCandidates: true,
|
|
@@ -138,7 +138,7 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
138
138
|
},
|
|
139
139
|
{
|
|
140
140
|
pattern: "(cat|dog)\\1",
|
|
141
|
-
|
|
141
|
+
ignoreCase: false,
|
|
142
142
|
hits: ["catcat", "dogdog"],
|
|
143
143
|
misses: ["catdog", "dogcat"],
|
|
144
144
|
rejectCandidates: false,
|
|
@@ -146,7 +146,7 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
146
146
|
},
|
|
147
147
|
{
|
|
148
148
|
pattern: "(a|bc)\\1",
|
|
149
|
-
|
|
149
|
+
ignoreCase: false,
|
|
150
150
|
hits: ["aa", "bcbc"],
|
|
151
151
|
misses: ["abc", "bca"],
|
|
152
152
|
rejectCandidates: false,
|
|
@@ -154,23 +154,15 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
154
154
|
},
|
|
155
155
|
{
|
|
156
156
|
pattern: "(a{1,2})b\\1",
|
|
157
|
-
|
|
157
|
+
ignoreCase: false,
|
|
158
158
|
hits: ["aba", "aabaa"],
|
|
159
159
|
misses: ["abb"],
|
|
160
160
|
rejectCandidates: true,
|
|
161
161
|
source: local,
|
|
162
162
|
},
|
|
163
|
-
{
|
|
164
|
-
pattern: "(?i:([\\q{ks|ab}]))(?-i:\\1)",
|
|
165
|
-
flags: "v",
|
|
166
|
-
hits: ["KsKs", "abab"],
|
|
167
|
-
misses: ["Ksks", "abAB"],
|
|
168
|
-
rejectCandidates: false,
|
|
169
|
-
source: local,
|
|
170
|
-
},
|
|
171
163
|
{
|
|
172
164
|
pattern: "(a(?=b))b\\1",
|
|
173
|
-
|
|
165
|
+
ignoreCase: false,
|
|
174
166
|
hits: ["aba"],
|
|
175
167
|
misses: ["abb"],
|
|
176
168
|
rejectCandidates: false,
|
|
@@ -178,48 +170,15 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
178
170
|
},
|
|
179
171
|
{
|
|
180
172
|
pattern: "^(é|Σ|𐐀)$",
|
|
181
|
-
|
|
182
|
-
hits: ["É", "é", "ς", "σ", "Σ"
|
|
183
|
-
misses: ["e", "s", "a"],
|
|
184
|
-
rejectCandidates: true,
|
|
185
|
-
source: local,
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
pattern: "^\\p{Letter}+$",
|
|
189
|
-
flags: "u",
|
|
190
|
-
hits: ["é", "Σ", "𐐀"],
|
|
191
|
-
misses: ["123", "😀"],
|
|
192
|
-
rejectCandidates: true,
|
|
193
|
-
source: local,
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
pattern: "^[\\p{Letter}--[a-z]]+$",
|
|
197
|
-
flags: "v",
|
|
198
|
-
hits: ["É", "Σ"],
|
|
199
|
-
misses: ["abc", "123"],
|
|
200
|
-
rejectCandidates: true,
|
|
201
|
-
source: local,
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
pattern: "^[^\\p{Letter}]$",
|
|
205
|
-
flags: "v",
|
|
206
|
-
hits: ["1", "😀"],
|
|
207
|
-
// Malformed-byte widening may also admit non-ASCII letters as candidates.
|
|
208
|
-
misses: ["a"],
|
|
173
|
+
ignoreCase: true,
|
|
174
|
+
hits: ["É", "é", "ς", "σ", "Σ"],
|
|
175
|
+
misses: ["e", "s", "a", "𐐨"],
|
|
209
176
|
rejectCandidates: true,
|
|
210
177
|
source: local,
|
|
211
178
|
},
|
|
212
|
-
{
|
|
213
|
-
pattern: `^[\\q{prefix${"a".repeat(300)}suffix|prefix${"b".repeat(300)}suffix}]$`,
|
|
214
|
-
flags: "v",
|
|
215
|
-
hits: [`prefix${"a".repeat(300)}suffix`, `prefix${"b".repeat(300)}suffix`],
|
|
216
|
-
misses: ["wrong", "prefixwrong", "wrongsuffix"],
|
|
217
|
-
rejectCandidates: false,
|
|
218
|
-
source: local,
|
|
219
|
-
},
|
|
220
179
|
{
|
|
221
180
|
pattern: "(?:(?<x>a)|(?<x>b))\\k<x>",
|
|
222
|
-
|
|
181
|
+
ignoreCase: false,
|
|
223
182
|
hits: ["aa", "bb"],
|
|
224
183
|
misses: ["abab", "cdef"],
|
|
225
184
|
rejectCandidates: false,
|
|
@@ -227,7 +186,7 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
227
186
|
},
|
|
228
187
|
{
|
|
229
188
|
pattern: "(?:(?:(?<x>a)|(?<x>b))\\k<x>){2}",
|
|
230
|
-
|
|
189
|
+
ignoreCase: false,
|
|
231
190
|
hits: ["aabb"],
|
|
232
191
|
misses: ["abab"],
|
|
233
192
|
rejectCandidates: false,
|
|
@@ -235,7 +194,7 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
235
194
|
},
|
|
236
195
|
{
|
|
237
196
|
pattern: "^(?:(?<a>x)|(?<a>y)|z)\\k<a>$",
|
|
238
|
-
|
|
197
|
+
ignoreCase: false,
|
|
239
198
|
hits: ["xx", "z"],
|
|
240
199
|
misses: ["zz"],
|
|
241
200
|
rejectCandidates: false,
|
|
@@ -243,7 +202,7 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
243
202
|
},
|
|
244
203
|
{
|
|
245
204
|
pattern: "^(?:(?<a>x)|(?<a>y)|z){2}\\k<a>$",
|
|
246
|
-
|
|
205
|
+
ignoreCase: false,
|
|
247
206
|
hits: ["xz", "yz"],
|
|
248
207
|
misses: ["xzx", "yzy"],
|
|
249
208
|
rejectCandidates: false,
|
|
@@ -251,7 +210,7 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
251
210
|
},
|
|
252
211
|
{
|
|
253
212
|
pattern: "(.)(?<=(\\1\\1))",
|
|
254
|
-
|
|
213
|
+
ignoreCase: true,
|
|
255
214
|
hits: ["abB"],
|
|
256
215
|
misses: ["ab"],
|
|
257
216
|
rejectCandidates: false,
|
|
@@ -259,7 +218,7 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
259
218
|
},
|
|
260
219
|
{
|
|
261
220
|
pattern: "(..)(?<=\\1\\1\\1)",
|
|
262
|
-
|
|
221
|
+
ignoreCase: false,
|
|
263
222
|
hits: ["fababab"],
|
|
264
223
|
misses: ["fabxbab", "faxabab"],
|
|
265
224
|
rejectCandidates: false,
|
|
@@ -267,7 +226,7 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
267
226
|
},
|
|
268
227
|
{
|
|
269
228
|
pattern: "(?<=(.))(\\w+)(?=\\1)",
|
|
270
|
-
|
|
229
|
+
ignoreCase: false,
|
|
271
230
|
hits: [" 'foo' ", ' "foo" '],
|
|
272
231
|
misses: [' .foo" '],
|
|
273
232
|
rejectCandidates: false,
|
|
@@ -275,7 +234,7 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
275
234
|
},
|
|
276
235
|
{
|
|
277
236
|
pattern: "(?<=ab(?=c)\\wd)\\w\\w",
|
|
278
|
-
|
|
237
|
+
ignoreCase: false,
|
|
279
238
|
hits: ["abcdef"],
|
|
280
239
|
misses: [],
|
|
281
240
|
rejectCandidates: false,
|
|
@@ -283,7 +242,7 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
283
242
|
},
|
|
284
243
|
{
|
|
285
244
|
pattern: "(?<=a(?=([bc]{2}(?<!a{2}))d)\\w{3})\\w\\w",
|
|
286
|
-
|
|
245
|
+
ignoreCase: false,
|
|
287
246
|
hits: ["abcdef"],
|
|
288
247
|
misses: [],
|
|
289
248
|
rejectCandidates: false,
|
|
@@ -291,7 +250,7 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
291
250
|
},
|
|
292
251
|
{
|
|
293
252
|
pattern: "(?<=a(?=([bc]{2}(?<!a*))d)\\w{3})\\w\\w",
|
|
294
|
-
|
|
253
|
+
ignoreCase: false,
|
|
295
254
|
hits: [],
|
|
296
255
|
misses: ["abcdef"],
|
|
297
256
|
rejectCandidates: false,
|
|
@@ -299,26 +258,10 @@ export const REGEX_TRANSLATION_CORPUS: readonly RegexWitness[] = [
|
|
|
299
258
|
},
|
|
300
259
|
{
|
|
301
260
|
pattern: "(?<!(^|[ab]))\\w{2}",
|
|
302
|
-
|
|
261
|
+
ignoreCase: false,
|
|
303
262
|
hits: ["abcdef"],
|
|
304
263
|
misses: [],
|
|
305
264
|
rejectCandidates: false,
|
|
306
265
|
source: `${test262}lookBehind/captures-negative.js`,
|
|
307
266
|
},
|
|
308
|
-
{
|
|
309
|
-
pattern: "^[[0-9]--\\p{ASCII_Hex_Digit}]+$",
|
|
310
|
-
flags: "v",
|
|
311
|
-
hits: [],
|
|
312
|
-
misses: ["0", "9", "C", "☃", "𝌆", "🇧🇪"],
|
|
313
|
-
rejectCandidates: true,
|
|
314
|
-
source: `${test262}unicodeSets/generated/character-class-difference-character-property-escape.js`,
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
pattern: "^[[0-9]&&[0-9]]+$",
|
|
318
|
-
flags: "v",
|
|
319
|
-
hits: ["0", "9"],
|
|
320
|
-
misses: ["6\uFE0F\u20E3", "C", "☃", "𝌆", "🇧🇪"],
|
|
321
|
-
rejectCandidates: true,
|
|
322
|
-
source: `${test262}unicodeSets/generated/character-class-intersection-character-class.js`,
|
|
323
|
-
},
|
|
324
267
|
];
|