@descent-vtt/spec-graph 0.7.0 → 0.9.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 +477 -0
- package/README.md +109 -17
- package/dist/cli.d.ts +2 -2
- package/dist/cli.js +38 -19
- package/dist/cli.js.map +1 -1
- package/dist/directives.d.ts +9 -2
- package/dist/directives.js +15 -4
- package/dist/directives.js.map +1 -1
- package/dist/extract.d.ts +1 -1
- package/dist/extract.js +50 -16
- package/dist/extract.js.map +1 -1
- package/dist/glob.d.ts +44 -44
- package/dist/glob.js +152 -116
- package/dist/glob.js.map +1 -1
- package/dist/identity.d.ts +12 -4
- package/dist/identity.js +32 -8
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/lifecycle.js +10 -2
- package/dist/lifecycle.js.map +1 -1
- package/dist/markdown.d.ts +53 -161
- package/dist/markdown.js +42 -864
- package/dist/markdown.js.map +1 -1
- package/dist/report.d.ts +23 -0
- package/dist/report.js +80 -0
- package/dist/report.js.map +1 -1
- package/dist/rules.js +48 -14
- package/dist/rules.js.map +1 -1
- package/dist/sections.d.ts +1 -1
- package/dist/sections.js +18 -4
- package/dist/sections.js.map +1 -1
- package/dist/select.d.ts +2 -2
- package/dist/select.js +3 -3
- package/dist/select.js.map +1 -1
- package/dist/source.d.ts +6 -19
- package/dist/source.js +4 -70
- package/dist/source.js.map +1 -1
- package/dist/types.d.ts +23 -3
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/vendor/spec-core/markdown/frontmatter.d.ts +103 -0
- package/dist/vendor/spec-core/markdown/frontmatter.js +459 -0
- package/dist/vendor/spec-core/markdown/frontmatter.js.map +1 -0
- package/dist/vendor/spec-core/markdown/headings.d.ts +45 -0
- package/dist/vendor/spec-core/markdown/headings.js +199 -0
- package/dist/vendor/spec-core/markdown/headings.js.map +1 -0
- package/dist/vendor/spec-core/markdown/index.d.ts +5 -0
- package/dist/vendor/spec-core/markdown/index.js +4 -0
- package/dist/vendor/spec-core/markdown/index.js.map +1 -0
- package/dist/vendor/spec-core/markdown/layout.d.ts +39 -0
- package/dist/vendor/spec-core/markdown/layout.js +28 -0
- package/dist/vendor/spec-core/markdown/layout.js.map +1 -0
- package/dist/vendor/spec-core/markdown/links.d.ts +22 -0
- package/dist/vendor/spec-core/markdown/links.js +364 -0
- package/dist/vendor/spec-core/markdown/links.js.map +1 -0
- package/dist/vendor/spec-core/markdown/lists.d.ts +22 -0
- package/dist/vendor/spec-core/markdown/lists.js +127 -0
- package/dist/vendor/spec-core/markdown/lists.js.map +1 -0
- package/dist/vendor/spec-core/markdown/scan.d.ts +36 -0
- package/dist/vendor/spec-core/markdown/scan.js +439 -0
- package/dist/vendor/spec-core/markdown/scan.js.map +1 -0
- package/dist/vendor/spec-core/markdown/syntax.d.ts +75 -0
- package/dist/vendor/spec-core/markdown/syntax.js +181 -0
- package/dist/vendor/spec-core/markdown/syntax.js.map +1 -0
- package/dist/vendor/spec-core/markdown/tables.d.ts +18 -0
- package/dist/vendor/spec-core/markdown/tables.js +86 -0
- package/dist/vendor/spec-core/markdown/tables.js.map +1 -0
- package/dist/vendor/spec-core/markdown/types.d.ts +287 -0
- package/dist/vendor/spec-core/markdown/types.js +9 -0
- package/dist/vendor/spec-core/markdown/types.js.map +1 -0
- package/dist/vendor/spec-core/path/index.d.ts +1 -0
- package/dist/vendor/spec-core/path/index.js +2 -0
- package/dist/vendor/spec-core/path/index.js.map +1 -0
- package/dist/vendor/spec-core/path/posix.d.ts +83 -0
- package/dist/vendor/spec-core/path/posix.js +150 -0
- package/dist/vendor/spec-core/path/posix.js.map +1 -0
- package/dist/vendor/spec-core/pattern/automaton.d.ts +129 -0
- package/dist/vendor/spec-core/pattern/automaton.js +340 -0
- package/dist/vendor/spec-core/pattern/automaton.js.map +1 -0
- package/dist/vendor/spec-core/pattern/charset.d.ts +58 -0
- package/dist/vendor/spec-core/pattern/charset.js +116 -0
- package/dist/vendor/spec-core/pattern/charset.js.map +1 -0
- package/dist/vendor/spec-core/pattern/glob.d.ts +121 -0
- package/dist/vendor/spec-core/pattern/glob.js +481 -0
- package/dist/vendor/spec-core/pattern/glob.js.map +1 -0
- package/dist/vendor/spec-core/pattern/index.d.ts +6 -0
- package/dist/vendor/spec-core/pattern/index.js +4 -0
- package/dist/vendor/spec-core/pattern/index.js.map +1 -0
- package/dist/{regex.d.ts → vendor/spec-core/pattern/regex.d.ts} +20 -29
- package/dist/{regex.js → vendor/spec-core/pattern/regex.js} +40 -49
- package/dist/vendor/spec-core/pattern/regex.js.map +1 -0
- package/dist/vendor/spec-core/text/index.d.ts +2 -0
- package/dist/vendor/spec-core/text/index.js +2 -0
- package/dist/vendor/spec-core/text/index.js.map +1 -0
- package/dist/vendor/spec-core/text/lines.d.ts +72 -0
- package/dist/vendor/spec-core/text/lines.js +156 -0
- package/dist/vendor/spec-core/text/lines.js.map +1 -0
- package/dist/yaml.d.ts +44 -12
- package/dist/yaml.js +115 -206
- package/dist/yaml.js.map +1 -1
- package/package.json +3 -2
- package/src/vendor/spec-core/LICENSE +21 -0
- package/src/vendor/spec-core/README.md +8 -0
- package/dist/regex.js.map +0 -1
package/dist/yaml.js
CHANGED
|
@@ -1,85 +1,133 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* What spec-graph reads out of a document's front matter.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* wrong
|
|
4
|
+
* The reader is spec-core's, copied into `src/vendor/spec-core/markdown/`: the
|
|
5
|
+
* subset of YAML that specifications use - scalars, quoted scalars, inline and
|
|
6
|
+
* block sequences, `#` comments and, as spec-graph reads it, one level of nested
|
|
7
|
+
* mapping flattened to `parent.child` - with the offset of every key and value,
|
|
8
|
+
* because when a status is wrong the report has to point at the line that
|
|
9
|
+
* declares it.
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* Anything richer is recognised and not guessed at: a value continued on the
|
|
12
|
+
* next line, a plain value holding `: `, a block scalar, an anchor. Such a value
|
|
13
|
+
* is not read, and the reason is a parse problem at the value, so a key that
|
|
14
|
+
* says nothing to the graph says why under `--verbose`. Each problem says
|
|
15
|
+
* whether it left something out and which key, for the count a run prints
|
|
16
|
+
* without `--verbose`.
|
|
17
|
+
*
|
|
18
|
+
* What stays here is the shape the rest of spec-graph reads: a key in lower
|
|
19
|
+
* case, which is how a relation key, a status key and `fm.<key>` in a selector
|
|
20
|
+
* have always been compared, and a value that is a string or a list of them.
|
|
21
|
+
*/
|
|
22
|
+
import { frontMatterKind, readFrontMatter } from './vendor/spec-core/markdown/index.js';
|
|
23
|
+
const NOTHING = { entries: [], problems: [] };
|
|
24
|
+
/** A line that reads as `key:` at any indentation, and the key it names. */
|
|
25
|
+
const KEY_SHAPE = /^[ \t]*([A-Za-z_][\w.-]*)[ \t]*:/;
|
|
26
|
+
/** Reads a scanned document's front matter. */
|
|
27
|
+
export function readEntries(scanned) {
|
|
28
|
+
const block = scanned.frontMatter;
|
|
29
|
+
if (block === null)
|
|
30
|
+
return neverClosed(scanned);
|
|
31
|
+
const index = scanned.index;
|
|
32
|
+
// The block and nothing after it: the reader splits what it is given into
|
|
33
|
+
// lines, and the body is none of its business.
|
|
34
|
+
const read = readFrontMatter(scanned.text.slice(0, block.bodyStart), { nested: true });
|
|
35
|
+
// The scan found a closed block, and the reader closes one by the same rule.
|
|
36
|
+
if (read === null)
|
|
37
|
+
return NOTHING;
|
|
38
|
+
const { entries, problems } = entriesOf(read, 0);
|
|
39
|
+
return {
|
|
40
|
+
entries,
|
|
41
|
+
problems: [
|
|
42
|
+
...read.problems.map((problem) => {
|
|
43
|
+
// A key written twice is read, the last of it; any other line with a
|
|
44
|
+
// problem is not, and the key it looks like it names is what went
|
|
45
|
+
// missing - ` status: accepted`, indented under nothing, is a status.
|
|
46
|
+
const unread = !read.entries.some((entry) => entry.line === problem.line);
|
|
47
|
+
const text = index.lineText(problem.line + 1);
|
|
48
|
+
return {
|
|
49
|
+
message: `front matter: ${problem.message}`,
|
|
50
|
+
start: index.lineStart(problem.line + 1),
|
|
51
|
+
end: index.lineEnd(problem.line + 1),
|
|
52
|
+
unread,
|
|
53
|
+
key: KEY_SHAPE.exec(text)?.[1]?.toLowerCase() ?? null,
|
|
54
|
+
};
|
|
55
|
+
}),
|
|
56
|
+
...problems,
|
|
57
|
+
].sort((a, b) => a.start - b.start),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Front matter that opens and never closes, which the scan reads as a rule
|
|
62
|
+
* and Markdown after it, so nothing in it reaches the graph.
|
|
63
|
+
*
|
|
64
|
+
* The scan closes a block by the rule the reader does, so this is the one case
|
|
65
|
+
* it leaves null with a first line that opens one. The usual cause is a closer
|
|
66
|
+
* that only looks like one: `----` and `....` closed front matter here before
|
|
67
|
+
* 0.9.0, and neither is one of YAML's document markers.
|
|
14
68
|
*/
|
|
15
|
-
|
|
16
|
-
const
|
|
69
|
+
function neverClosed(scanned) {
|
|
70
|
+
const index = scanned.index;
|
|
71
|
+
const kind = frontMatterKind(index.lineText(1));
|
|
72
|
+
if (kind === null)
|
|
73
|
+
return NOTHING;
|
|
74
|
+
const delimiter = kind === 'yaml' ? '---' : '+++';
|
|
75
|
+
return {
|
|
76
|
+
entries: [],
|
|
77
|
+
problems: [
|
|
78
|
+
{
|
|
79
|
+
message: `front matter: opened here and never closed, so none of it is read - close it with "${delimiter}" on a line of its own`,
|
|
80
|
+
start: index.lineStart(1),
|
|
81
|
+
end: index.lineEnd(1),
|
|
82
|
+
unread: true,
|
|
83
|
+
key: null,
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
};
|
|
87
|
+
}
|
|
17
88
|
/**
|
|
18
|
-
* Parses front-matter text
|
|
89
|
+
* Parses front-matter text: what lies between the delimiters, as
|
|
90
|
+
* `FrontMatter.raw` holds it.
|
|
19
91
|
*
|
|
20
|
-
* @param raw The text between the delimiters.
|
|
92
|
+
* @param raw The text between the delimiters. It cannot hold a line that would
|
|
93
|
+
* close them, as text a scan read between them never does.
|
|
21
94
|
* @param baseOffset Offset of `raw` within the containing file, so the returned
|
|
22
95
|
* spans address the file rather than the fragment.
|
|
23
96
|
*/
|
|
24
97
|
export function parseFrontMatter(raw, baseOffset = 0) {
|
|
98
|
+
// The reader reads front matter at the top of a document, so the text goes
|
|
99
|
+
// back between delimiters, and every offset back by the four characters the
|
|
100
|
+
// opening one takes. The line break before the closing one is a blank line
|
|
101
|
+
// when `raw` already ends in one, and a blank line is no key's.
|
|
102
|
+
const read = readFrontMatter(`---\n${raw}\n---`, { nested: true });
|
|
103
|
+
// Never null: the text opens with a delimiter and closes with one.
|
|
104
|
+
return read === null ? [] : entriesOf(read, baseOffset - 4).entries;
|
|
105
|
+
}
|
|
106
|
+
/** The entries a reading holds, and the values it could not read as problems. */
|
|
107
|
+
function entriesOf(read, shift) {
|
|
25
108
|
const entries = [];
|
|
26
|
-
const
|
|
27
|
-
for (
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const trimmed = stripComment(rest).trim();
|
|
37
|
-
if (trimmed.length > 0) {
|
|
38
|
-
const valueStart = restStart + rest.indexOf(trimmed);
|
|
39
|
-
entries.push({
|
|
40
|
-
key,
|
|
41
|
-
value: parseScalarOrFlow(trimmed),
|
|
42
|
-
start: baseOffset + line.start + indent,
|
|
43
|
-
end: baseOffset + valueStart + trimmed.length,
|
|
44
|
-
valueStart: baseOffset + valueStart,
|
|
109
|
+
const problems = [];
|
|
110
|
+
for (const entry of read.entries) {
|
|
111
|
+
const { value } = entry;
|
|
112
|
+
if (value.kind === 'unsupported') {
|
|
113
|
+
problems.push({
|
|
114
|
+
message: `front matter: "${entry.key}" is not read: ${value.reason}`,
|
|
115
|
+
start: entry.valueStart + shift,
|
|
116
|
+
end: entry.valueEnd + shift,
|
|
117
|
+
unread: true,
|
|
118
|
+
key: entry.key.toLowerCase(),
|
|
45
119
|
});
|
|
46
120
|
continue;
|
|
47
121
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
end: baseOffset + block.end,
|
|
56
|
-
valueStart: baseOffset + block.valueStart,
|
|
57
|
-
});
|
|
58
|
-
i = block.lastIndex;
|
|
59
|
-
}
|
|
60
|
-
else if (block.kind === 'mapping') {
|
|
61
|
-
for (const child of block.entries) {
|
|
62
|
-
entries.push({
|
|
63
|
-
key: `${key}.${child.key}`,
|
|
64
|
-
value: child.value,
|
|
65
|
-
start: baseOffset + child.start,
|
|
66
|
-
end: baseOffset + child.end,
|
|
67
|
-
valueStart: baseOffset + child.valueStart,
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
i = block.lastIndex;
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
entries.push({
|
|
74
|
-
key,
|
|
75
|
-
value: '',
|
|
76
|
-
start: baseOffset + line.start + indent,
|
|
77
|
-
end: baseOffset + line.end,
|
|
78
|
-
valueStart: baseOffset + line.end,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
122
|
+
entries.push({
|
|
123
|
+
key: entry.key.toLowerCase(),
|
|
124
|
+
value: value.kind === 'scalar' ? value.scalar.text : value.items.map((item) => item.text),
|
|
125
|
+
start: entry.keyStart + shift,
|
|
126
|
+
end: entry.valueEnd + shift,
|
|
127
|
+
valueStart: entry.valueStart + shift,
|
|
128
|
+
});
|
|
81
129
|
}
|
|
82
|
-
return entries;
|
|
130
|
+
return { entries, problems };
|
|
83
131
|
}
|
|
84
132
|
/** Collapses parsed entries into the flat record stored on a document node. */
|
|
85
133
|
export function toRecord(entries) {
|
|
@@ -98,143 +146,4 @@ export function valuesOf(entry) {
|
|
|
98
146
|
: []
|
|
99
147
|
: [...entry.value];
|
|
100
148
|
}
|
|
101
|
-
function splitLines(raw) {
|
|
102
|
-
const out = [];
|
|
103
|
-
let start = 0;
|
|
104
|
-
for (let i = 0; i <= raw.length; i += 1) {
|
|
105
|
-
if (i === raw.length || raw[i] === '\n') {
|
|
106
|
-
let end = i;
|
|
107
|
-
if (end > start && raw[end - 1] === '\r')
|
|
108
|
-
end -= 1;
|
|
109
|
-
out.push({ text: raw.slice(start, end), start, end });
|
|
110
|
-
start = i + 1;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (out.length > 0 && out[out.length - 1].text === '' && raw.endsWith('\n'))
|
|
114
|
-
out.pop();
|
|
115
|
-
return out;
|
|
116
|
-
}
|
|
117
|
-
function readBlock(lines, from, indent) {
|
|
118
|
-
const items = [];
|
|
119
|
-
let valueStart = -1;
|
|
120
|
-
let end = -1;
|
|
121
|
-
let last = from - 1;
|
|
122
|
-
for (let i = from; i < lines.length; i += 1) {
|
|
123
|
-
const line = lines[i];
|
|
124
|
-
if (line.text.trim().length === 0) {
|
|
125
|
-
last = i;
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
const lineIndent = line.text.length - line.text.trimStart().length;
|
|
129
|
-
if (lineIndent <= indent)
|
|
130
|
-
break;
|
|
131
|
-
const seq = SEQUENCE_ITEM.exec(line.text);
|
|
132
|
-
if (!seq) {
|
|
133
|
-
if (items.length > 0)
|
|
134
|
-
break;
|
|
135
|
-
// A nested mapping: re-parse the indented region as its own document.
|
|
136
|
-
const region = collectRegion(lines, from, indent);
|
|
137
|
-
if (region.text.trim().length === 0)
|
|
138
|
-
return { kind: 'empty', lastIndex: from - 1 };
|
|
139
|
-
const nested = parseFrontMatter(region.text, region.start);
|
|
140
|
-
return { kind: 'mapping', entries: nested, lastIndex: region.lastIndex };
|
|
141
|
-
}
|
|
142
|
-
const value = stripComment(seq[2]).trim();
|
|
143
|
-
const offset = line.start + line.text.indexOf(value, seq[1].length + 1);
|
|
144
|
-
if (valueStart === -1)
|
|
145
|
-
valueStart = value.length > 0 ? offset : line.start;
|
|
146
|
-
items.push(unquote(value));
|
|
147
|
-
end = line.start + line.text.length;
|
|
148
|
-
last = i;
|
|
149
|
-
}
|
|
150
|
-
if (items.length === 0)
|
|
151
|
-
return { kind: 'empty', lastIndex: from - 1 };
|
|
152
|
-
return { kind: 'sequence', items, end, valueStart, lastIndex: last };
|
|
153
|
-
}
|
|
154
|
-
function collectRegion(lines, from, indent) {
|
|
155
|
-
let last = from - 1;
|
|
156
|
-
for (let i = from; i < lines.length; i += 1) {
|
|
157
|
-
const line = lines[i];
|
|
158
|
-
if (line.text.trim().length === 0) {
|
|
159
|
-
last = i;
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
162
|
-
const lineIndent = line.text.length - line.text.trimStart().length;
|
|
163
|
-
if (lineIndent <= indent)
|
|
164
|
-
break;
|
|
165
|
-
last = i;
|
|
166
|
-
}
|
|
167
|
-
if (last < from)
|
|
168
|
-
return { text: '', start: 0, lastIndex: from - 1 };
|
|
169
|
-
const start = lines[from].start;
|
|
170
|
-
const stop = lines[last].end;
|
|
171
|
-
const parts = [];
|
|
172
|
-
for (let i = from; i <= last; i += 1)
|
|
173
|
-
parts.push(lines[i].text);
|
|
174
|
-
return { text: parts.join('\n'), start, lastIndex: last };
|
|
175
|
-
void stop;
|
|
176
|
-
}
|
|
177
|
-
/** Drops a trailing `#` comment, respecting quotes. */
|
|
178
|
-
function stripComment(value) {
|
|
179
|
-
let quote = null;
|
|
180
|
-
for (let i = 0; i < value.length; i += 1) {
|
|
181
|
-
const ch = value[i];
|
|
182
|
-
if (quote) {
|
|
183
|
-
if (ch === '\\')
|
|
184
|
-
i += 1;
|
|
185
|
-
else if (ch === quote)
|
|
186
|
-
quote = null;
|
|
187
|
-
}
|
|
188
|
-
else if (ch === '"' || ch === "'") {
|
|
189
|
-
quote = ch;
|
|
190
|
-
}
|
|
191
|
-
else if (ch === '#' && (i === 0 || value[i - 1] === ' ' || value[i - 1] === '\t')) {
|
|
192
|
-
return value.slice(0, i);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return value;
|
|
196
|
-
}
|
|
197
|
-
function parseScalarOrFlow(value) {
|
|
198
|
-
if (value.startsWith('[') && value.endsWith(']')) {
|
|
199
|
-
const inner = value.slice(1, -1).trim();
|
|
200
|
-
if (inner.length === 0)
|
|
201
|
-
return [];
|
|
202
|
-
return splitFlow(inner).map(unquote);
|
|
203
|
-
}
|
|
204
|
-
return unquote(value);
|
|
205
|
-
}
|
|
206
|
-
/** Splits `a, "b, c", d` on commas that are not inside quotes. */
|
|
207
|
-
function splitFlow(value) {
|
|
208
|
-
const out = [];
|
|
209
|
-
let quote = null;
|
|
210
|
-
let start = 0;
|
|
211
|
-
for (let i = 0; i < value.length; i += 1) {
|
|
212
|
-
const ch = value[i];
|
|
213
|
-
if (quote) {
|
|
214
|
-
if (ch === '\\')
|
|
215
|
-
i += 1;
|
|
216
|
-
else if (ch === quote)
|
|
217
|
-
quote = null;
|
|
218
|
-
}
|
|
219
|
-
else if (ch === '"' || ch === "'") {
|
|
220
|
-
quote = ch;
|
|
221
|
-
}
|
|
222
|
-
else if (ch === ',') {
|
|
223
|
-
out.push(value.slice(start, i).trim());
|
|
224
|
-
start = i + 1;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
out.push(value.slice(start).trim());
|
|
228
|
-
return out.filter((part) => part.length > 0);
|
|
229
|
-
}
|
|
230
|
-
function unquote(value) {
|
|
231
|
-
if (value.length >= 2) {
|
|
232
|
-
const first = value[0];
|
|
233
|
-
const last = value[value.length - 1];
|
|
234
|
-
if ((first === '"' && last === '"') || (first === "'" && last === "'")) {
|
|
235
|
-
return value.slice(1, -1).replace(/\\(.)/g, '$1');
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
return value;
|
|
239
|
-
}
|
|
240
149
|
//# sourceMappingURL=yaml.js.map
|
package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C,CAAC;AAC/C,CAAC;AAED,SAAS,OAAO,CAAC,KAAa;IAC5B,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QACtB,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACvB,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACrC,IAAI,CAAC,KAAK,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;YACvE,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/**\n * A front-matter reader for the subset of YAML that specifications actually use.\n *\n * Front matter in an ADR is a flat bag of scalars and lists. Pulling in a full\n * YAML implementation to read `status: accepted` would add a parser with its own\n * CVE history, and would still need wrapping to recover the byte offset of the\n * value - which is the whole reason we parse it ourselves: when a status is\n * wrong, the report has to point at the line that declares it.\n *\n * Supported: scalars, quoted scalars, inline `[a, b]` sequences, block `- item`\n * sequences, one level of nested mapping (flattened to `parent.child`), and `#`\n * comments. Anything richer is preserved as the raw scalar text rather than\n * being silently mangled.\n */\n\nexport interface YamlEntry {\n /** Lower-cased key. Nested keys are flattened with a dot. */\n readonly key: string;\n readonly value: string | readonly string[];\n /** Offset of the key. */\n readonly start: number;\n /** Offset just past the value. */\n readonly end: number;\n /** Offset of the first character of the value, for precise diagnostics. */\n readonly valueStart: number;\n}\n\nconst KEY_LINE = /^(\\s*)([A-Za-z0-9_.$-]+)\\s*:(.*)$/;\nconst SEQUENCE_ITEM = /^(\\s*)-\\s*(.*)$/;\n\n/**\n * Parses front-matter text.\n *\n * @param raw The text between the delimiters.\n * @param baseOffset Offset of `raw` within the containing file, so the returned\n * spans address the file rather than the fragment.\n */\nexport function parseFrontMatter(raw: string, baseOffset = 0): YamlEntry[] {\n const entries: YamlEntry[] = [];\n const lines = splitLines(raw);\n\n for (let i = 0; i < lines.length; i += 1) {\n const line = lines[i] as SplitLine;\n const match = KEY_LINE.exec(line.text);\n if (!match) continue;\n\n const indent = (match[1] as string).length;\n const key = (match[2] as string).toLowerCase();\n const rest = match[3] as string;\n const restStart = line.start + indent + (match[2] as string).length + 1;\n const trimmed = stripComment(rest).trim();\n\n if (trimmed.length > 0) {\n const valueStart = restStart + rest.indexOf(trimmed);\n entries.push({\n key,\n value: parseScalarOrFlow(trimmed),\n start: baseOffset + line.start + indent,\n end: baseOffset + valueStart + trimmed.length,\n valueStart: baseOffset + valueStart,\n });\n continue;\n }\n\n // An empty value opens either a block sequence or a nested mapping.\n const block = readBlock(lines, i + 1, indent);\n if (block.kind === 'sequence') {\n entries.push({\n key,\n value: block.items,\n start: baseOffset + line.start + indent,\n end: baseOffset + block.end,\n valueStart: baseOffset + block.valueStart,\n });\n i = block.lastIndex;\n } else if (block.kind === 'mapping') {\n for (const child of block.entries) {\n entries.push({\n key: `${key}.${child.key}`,\n value: child.value,\n start: baseOffset + child.start,\n end: baseOffset + child.end,\n valueStart: baseOffset + child.valueStart,\n });\n }\n i = block.lastIndex;\n } else {\n entries.push({\n key,\n value: '',\n start: baseOffset + line.start + indent,\n end: baseOffset + line.end,\n valueStart: baseOffset + line.end,\n });\n }\n }\n\n return entries;\n}\n\n/** Collapses parsed entries into the flat record stored on a document node. */\nexport function toRecord(entries: readonly YamlEntry[]): Record<string, string | readonly string[]> {\n const out: Record<string, string | readonly string[]> = {};\n for (const entry of entries) out[entry.key] = entry.value;\n return out;\n}\n\n/** Every value of a key as a flat list, whether it was a scalar or a sequence. */\nexport function valuesOf(entry: YamlEntry | undefined): string[] {\n if (!entry) return [];\n return typeof entry.value === 'string'\n ? entry.value.length > 0\n ? [entry.value]\n : []\n : [...entry.value];\n}\n\n/* -------------------------------------------------------------------------- */\n/* Internals */\n/* -------------------------------------------------------------------------- */\n\ninterface SplitLine {\n readonly text: string;\n readonly start: number;\n readonly end: number;\n}\n\nfunction splitLines(raw: string): SplitLine[] {\n const out: SplitLine[] = [];\n let start = 0;\n for (let i = 0; i <= raw.length; i += 1) {\n if (i === raw.length || raw[i] === '\\n') {\n let end = i;\n if (end > start && raw[end - 1] === '\\r') end -= 1;\n out.push({ text: raw.slice(start, end), start, end });\n start = i + 1;\n }\n }\n if (out.length > 0 && (out[out.length - 1] as SplitLine).text === '' && raw.endsWith('\\n')) out.pop();\n return out;\n}\n\ntype Block =\n | { kind: 'sequence'; items: string[]; end: number; valueStart: number; lastIndex: number }\n | { kind: 'mapping'; entries: YamlEntry[]; lastIndex: number }\n | { kind: 'empty'; lastIndex: number };\n\nfunction readBlock(lines: readonly SplitLine[], from: number, indent: number): Block {\n const items: string[] = [];\n let valueStart = -1;\n let end = -1;\n let last = from - 1;\n\n for (let i = from; i < lines.length; i += 1) {\n const line = lines[i] as SplitLine;\n if (line.text.trim().length === 0) {\n last = i;\n continue;\n }\n const lineIndent = line.text.length - line.text.trimStart().length;\n if (lineIndent <= indent) break;\n\n const seq = SEQUENCE_ITEM.exec(line.text);\n if (!seq) {\n if (items.length > 0) break;\n // A nested mapping: re-parse the indented region as its own document.\n const region = collectRegion(lines, from, indent);\n if (region.text.trim().length === 0) return { kind: 'empty', lastIndex: from - 1 };\n const nested = parseFrontMatter(region.text, region.start);\n return { kind: 'mapping', entries: nested, lastIndex: region.lastIndex };\n }\n\n const value = stripComment(seq[2] as string).trim();\n const offset = line.start + line.text.indexOf(value, (seq[1] as string).length + 1);\n if (valueStart === -1) valueStart = value.length > 0 ? offset : line.start;\n items.push(unquote(value));\n end = line.start + line.text.length;\n last = i;\n }\n\n if (items.length === 0) return { kind: 'empty', lastIndex: from - 1 };\n return { kind: 'sequence', items, end, valueStart, lastIndex: last };\n}\n\nfunction collectRegion(\n lines: readonly SplitLine[],\n from: number,\n indent: number,\n): { text: string; start: number; lastIndex: number } {\n let last = from - 1;\n for (let i = from; i < lines.length; i += 1) {\n const line = lines[i] as SplitLine;\n if (line.text.trim().length === 0) {\n last = i;\n continue;\n }\n const lineIndent = line.text.length - line.text.trimStart().length;\n if (lineIndent <= indent) break;\n last = i;\n }\n if (last < from) return { text: '', start: 0, lastIndex: from - 1 };\n const start = (lines[from] as SplitLine).start;\n const stop = (lines[last] as SplitLine).end;\n const parts: string[] = [];\n for (let i = from; i <= last; i += 1) parts.push((lines[i] as SplitLine).text);\n return { text: parts.join('\\n'), start, lastIndex: last };\n void stop;\n}\n\n/** Drops a trailing `#` comment, respecting quotes. */\nfunction stripComment(value: string): string {\n let quote: string | null = null;\n for (let i = 0; i < value.length; i += 1) {\n const ch = value[i] as string;\n if (quote) {\n if (ch === '\\\\') i += 1;\n else if (ch === quote) quote = null;\n } else if (ch === '\"' || ch === \"'\") {\n quote = ch;\n } else if (ch === '#' && (i === 0 || value[i - 1] === ' ' || value[i - 1] === '\\t')) {\n return value.slice(0, i);\n }\n }\n return value;\n}\n\nfunction parseScalarOrFlow(value: string): string | string[] {\n if (value.startsWith('[') && value.endsWith(']')) {\n const inner = value.slice(1, -1).trim();\n if (inner.length === 0) return [];\n return splitFlow(inner).map(unquote);\n }\n return unquote(value);\n}\n\n/** Splits `a, \"b, c\", d` on commas that are not inside quotes. */\nfunction splitFlow(value: string): string[] {\n const out: string[] = [];\n let quote: string | null = null;\n let start = 0;\n for (let i = 0; i < value.length; i += 1) {\n const ch = value[i] as string;\n if (quote) {\n if (ch === '\\\\') i += 1;\n else if (ch === quote) quote = null;\n } else if (ch === '\"' || ch === \"'\") {\n quote = ch;\n } else if (ch === ',') {\n out.push(value.slice(start, i).trim());\n start = i + 1;\n }\n }\n out.push(value.slice(start).trim());\n return out.filter((part) => part.length > 0);\n}\n\nfunction unquote(value: string): string {\n if (value.length >= 2) {\n const first = value[0];\n const last = value[value.length - 1];\n if ((first === '\"' && last === '\"') || (first === \"'\" && last === \"'\")) {\n return value.slice(1, -1).replace(/\\\\(.)/g, '$1');\n }\n }\n return value;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"yaml.js","sourceRoot":"","sources":["../src/yaml.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,eAAe,EAAE,eAAe,EAA4B,MAAM,sCAAsC,CAAC;AAqClH,MAAM,OAAO,GAAuB,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;AAElE,4EAA4E;AAC5E,MAAM,SAAS,GAAG,kCAAkC,CAAC;AAErD,+CAA+C;AAC/C,MAAM,UAAU,WAAW,CAAC,OAAwB;IAClD,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,CAAC;IAClC,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC5B,0EAA0E;IAC1E,+CAA+C;IAC/C,MAAM,IAAI,GAAG,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IACvF,6EAA6E;IAC7E,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,OAAO,CAAC;IAClC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACjD,OAAO;QACL,OAAO;QACP,QAAQ,EAAE;YACR,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC/B,qEAAqE;gBACrE,kEAAkE;gBAClE,uEAAuE;gBACvE,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,K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AAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;YACzF,KAAK,EAAE,KAAK,CAAC,QAAQ,GAAG,KAAK;YAC7B,GAAG,EAAE,KAAK,CAAC,QAAQ,GAAG,KAAK;YAC3B,UAAU,EAAE,KAAK,CAAC,UAAU,GAAG,KAAK;SACrC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAC/B,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,QAAQ,CAAC,OAA6B;IACpD,MAAM,GAAG,GAA+C,EAAE,CAAC;IAC3D,KAAK,MAAM,KAAK,IAAI,OAAO;QAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC;IAC1D,OAAO,GAAG,CAAC;AACb,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,QAAQ,CAAC,KAA4B;IACnD,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IACtB,OAAO,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ;QACpC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;YACtB,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;YACf,CAAC,CAAC,EAAE;QACN,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC","sourcesContent":["/**\n * What spec-graph reads out of a document's front matter.\n *\n * The reader is spec-core's, copied into `src/vendor/spec-core/markdown/`: the\n * subset of YAML that specifications use - scalars, quoted scalars, inline and\n * block sequences, `#` comments and, as spec-graph reads it, one level of nested\n * mapping flattened to `parent.child` - with the offset of every key and value,\n * because when a status is wrong the report has to point at the line that\n * declares it.\n *\n * Anything richer is recognised and not guessed at: a value continued on the\n * next line, a plain value holding `: `, a block scalar, an anchor. Such a value\n * is not read, and the reason is a parse problem at the value, so a key that\n * says nothing to the graph says why under `--verbose`. Each problem says\n * whether it left something out and which key, for the count a run prints\n * without `--verbose`.\n *\n * What stays here is the shape the rest of spec-graph reads: a key in lower\n * case, which is how a relation key, a status key and `fm.<key>` in a selector\n * have always been compared, and a value that is a string or a list of them.\n */\n\nimport { frontMatterKind, readFrontMatter, type FrontMatter as Read } from './vendor/spec-core/markdown/index.js';\nimport type { ScannedDocument } from './markdown.js';\n\nexport interface YamlEntry {\n /** Lower-cased key. Nested keys are flattened with a dot. */\n readonly key: string;\n readonly value: string | readonly string[];\n /** Offset of the key. */\n readonly start: number;\n /** Offset just past the value. */\n readonly end: number;\n /** Offset of the first character of the value, for precise diagnostics. */\n readonly valueStart: number;\n}\n\n/** Something in the front matter that was not read, and where. */\nexport interface FrontMatterProblem {\n readonly message: string;\n readonly start: number;\n readonly end: number;\n /**\n * Whether it left something out: a value, a line or the whole block. A key\n * written twice is a problem that leaves nothing out, since the last is read.\n */\n readonly unread: boolean;\n /**\n * The key, lower-cased, whose value or line was left out, when the line\n * names one; `null` for a line that names none and for the whole block.\n */\n readonly key: string | null;\n}\n\nexport interface FrontMatterReading {\n readonly entries: readonly YamlEntry[];\n readonly problems: readonly FrontMatterProblem[];\n}\n\nconst NOTHING: FrontMatterReading = { entries: [], problems: [] };\n\n/** A line that reads as `key:` at any indentation, and the key it names. */\nconst KEY_SHAPE = /^[ \\t]*([A-Za-z_][\\w.-]*)[ \\t]*:/;\n\n/** Reads a scanned document's front matter. */\nexport function readEntries(scanned: ScannedDocument): FrontMatterReading {\n const block = scanned.frontMatter;\n if (block === null) return neverClosed(scanned);\n const index = scanned.index;\n // The block and nothing after it: the reader splits what it is given into\n // lines, and the body is none of its business.\n const read = readFrontMatter(scanned.text.slice(0, block.bodyStart), { nested: true });\n // The scan found a closed block, and the reader closes one by the same rule.\n if (read === null) return NOTHING;\n const { entries, problems } = entriesOf(read, 0);\n return {\n entries,\n problems: [\n ...read.problems.map((problem) => {\n // A key written twice is read, the last of it; any other line with a\n // problem is not, and the key it looks like it names is what went\n // missing - ` status: accepted`, indented under nothing, is a status.\n const unread = !read.entries.some((entry) => entry.line === problem.line);\n const text = index.lineText(problem.line + 1);\n return {\n message: `front matter: ${problem.message}`,\n start: index.lineStart(problem.line + 1),\n end: index.lineEnd(problem.line + 1),\n unread,\n key: KEY_SHAPE.exec(text)?.[1]?.toLowerCase() ?? null,\n };\n }),\n ...problems,\n ].sort((a, b) => a.start - b.start),\n };\n}\n\n/**\n * Front matter that opens and never closes, which the scan reads as a rule\n * and Markdown after it, so nothing in it reaches the graph.\n *\n * The scan closes a block by the rule the reader does, so this is the one case\n * it leaves null with a first line that opens one. The usual cause is a closer\n * that only looks like one: `----` and `....` closed front matter here before\n * 0.9.0, and neither is one of YAML's document markers.\n */\nfunction neverClosed(scanned: ScannedDocument): FrontMatterReading {\n const index = scanned.index;\n const kind = frontMatterKind(index.lineText(1));\n if (kind === null) return NOTHING;\n const delimiter = kind === 'yaml' ? '---' : '+++';\n return {\n entries: [],\n problems: [\n {\n message: `front matter: opened here and never closed, so none of it is read - close it with \"${delimiter}\" on a line of its own`,\n start: index.lineStart(1),\n end: index.lineEnd(1),\n unread: true,\n key: null,\n },\n ],\n };\n}\n\n/**\n * Parses front-matter text: what lies between the delimiters, as\n * `FrontMatter.raw` holds it.\n *\n * @param raw The text between the delimiters. It cannot hold a line that would\n * close them, as text a scan read between them never does.\n * @param baseOffset Offset of `raw` within the containing file, so the returned\n * spans address the file rather than the fragment.\n */\nexport function parseFrontMatter(raw: string, baseOffset = 0): YamlEntry[] {\n // The reader reads front matter at the top of a document, so the text goes\n // back between delimiters, and every offset back by the four characters the\n // opening one takes. The line break before the closing one is a blank line\n // when `raw` already ends in one, and a blank line is no key's.\n const read = readFrontMatter(`---\\n${raw}\\n---`, { nested: true });\n // Never null: the text opens with a delimiter and closes with one.\n return read === null ? [] : entriesOf(read, baseOffset - 4).entries;\n}\n\n/** The entries a reading holds, and the values it could not read as problems. */\nfunction entriesOf(read: Read, shift: number): { entries: YamlEntry[]; problems: FrontMatterProblem[] } {\n const entries: YamlEntry[] = [];\n const problems: FrontMatterProblem[] = [];\n for (const entry of read.entries) {\n const { value } = entry;\n if (value.kind === 'unsupported') {\n problems.push({\n message: `front matter: \"${entry.key}\" is not read: ${value.reason}`,\n start: entry.valueStart + shift,\n end: entry.valueEnd + shift,\n unread: true,\n key: entry.key.toLowerCase(),\n });\n continue;\n }\n entries.push({\n key: entry.key.toLowerCase(),\n value: value.kind === 'scalar' ? value.scalar.text : value.items.map((item) => item.text),\n start: entry.keyStart + shift,\n end: entry.valueEnd + shift,\n valueStart: entry.valueStart + shift,\n });\n }\n return { entries, problems };\n}\n\n/** Collapses parsed entries into the flat record stored on a document node. */\nexport function toRecord(entries: readonly YamlEntry[]): Record<string, string | readonly string[]> {\n const out: Record<string, string | readonly string[]> = {};\n for (const entry of entries) out[entry.key] = entry.value;\n return out;\n}\n\n/** Every value of a key as a flat list, whether it was a scalar or a sequence. */\nexport function valuesOf(entry: YamlEntry | undefined): string[] {\n if (!entry) return [];\n return typeof entry.value === 'string'\n ? entry.value.length > 0\n ? [entry.value]\n : []\n : [...entry.value];\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@descent-vtt/spec-graph",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Turn Markdown specs into a verifiable relational graph. Catches ghost handovers, stale premises and broken references in CI.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adr",
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"LICENSE",
|
|
38
38
|
"README.md",
|
|
39
39
|
"bin",
|
|
40
|
-
"dist"
|
|
40
|
+
"dist",
|
|
41
|
+
"src/vendor/spec-core/LICENSE"
|
|
41
42
|
],
|
|
42
43
|
"publishConfig": {
|
|
43
44
|
"access": "public"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 spec-core contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Vendored from spec-core
|
|
2
|
+
|
|
3
|
+
These files are copies of modules from
|
|
4
|
+
[spec-core](https://github.com/DescentVTT/spec-core), byte for byte. Do not edit them here: change
|
|
5
|
+
spec-core, then run `node scripts/vendor.mjs --into <this tool>` there.
|
|
6
|
+
`VENDOR.json` records the commit and the SHA-256 of every file, and this
|
|
7
|
+
tool's tests fail when a file no longer matches its hash. `LICENSE` is
|
|
8
|
+
spec-core's, and ships in this tool's package with the compiled copies.
|
package/dist/regex.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"regex.js","sourceRoot":"","sources":["../src/regex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF,2EAA2E;AAC3E,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,sCAAsC;IAC7B,MAAM,CAAS;IAExB,YAAY,OAAe,EAAE,MAAc;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,GAAG,IAAI,CAAC;AAsBzB,mFAAmF;AACnF,MAAM,GAAG,GAAY,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;AAC/F,MAAM,KAAK,GAAqB,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAC/C,MAAM,IAAI,GAAqB;IAC7B,CAAC,IAAI,EAAE,IAAI,CAAC;IACZ,CAAC,IAAI,EAAE,IAAI,CAAC;IACZ,CAAC,IAAI,EAAE,IAAI,CAAC;IACZ,CAAC,IAAI,EAAE,IAAI,CAAC;CACb,CAAC;AACF,iEAAiE;AACjE,MAAM,KAAK,GAAqB;IAC9B,CAAC,IAAI,EAAE,IAAI,CAAC;IACZ,CAAC,IAAI,EAAE,IAAI,CAAC;IACZ,CAAC,IAAI,EAAE,IAAI,CAAC;IACZ,CAAC,MAAM,EAAE,MAAM,CAAC;IAChB,CAAC,MAA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AAO,CAAC,MAAM,IAAI,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;YACpF,OAAO,CAAC,MAAM,KAAK,KAAK,CAAC,KAAK,CAAC,SAAS,KAAK,eAAe,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/**\n * A regular-expression matcher that cannot backtrack.\n *\n * `~=` is the one predicate in the selector language that used to hand a\n * user-supplied string to `RegExp` and wait. That is tolerable at a prompt,\n * where a human can press Ctrl-C. It is not tolerable in `.spec-graph.json`,\n * where the same string runs unattended in CI against every node in the corpus.\n *\n * The cost is neither theoretical nor exotic. `^([A-Za-z0-9_]+[ ]?)+$` is what\n * somebody writes to say \"the title is words separated by single spaces\", and\n * against a title that does not match, V8 tries one branch per way of cutting\n * each word into pieces:\n *\n * ```text\n * RegExp here\n * the quick brown fox jumps over the lazy dog! 0.9s 11us\n * the quick brown fox jumps over the lazy dog and! 5.4s 12us\n * the quick brown fox jumps over the lazy dog and keeps! 103s 13us\n * ```\n *\n * Each word of k letters can be cut into pieces 2^(k-1) ways, and the engine\n * tries the product of those, which is why adding one five-letter word costs\n * another factor of sixteen. A sixty-character title does not finish this year.\n *\n * So a pattern here is compiled to a **non-deterministic finite automaton** and\n * simulated over the subject one character at a time (Thompson, 1968), keeping\n * a set of live states instead of a stack of choices. Each state is visited at\n * most once per position, which makes the work exactly O(pattern x subject):\n * the right-hand column above, growing with the subject and not with the\n * pattern's ambiguity.\n *\n * What it costs is a dialect. Backreferences and lookaround are not regular and\n * have no place in a linear automaton, so they are **rejected while compiling**,\n * with a message and an offset, rather than accepted and then slow. That is the\n * whole trade: a predicate that finishes, against a short list of constructs\n * that a documentation selector never needed.\n *\n * Matching is unanchored and, by default, case-insensitive, because that is\n * what `~=` has always been - `new RegExp(source, 'i')` and `.test()`. Globs\n * compile to this as well, and a path on a case-sensitive filesystem needs the\n * case respected, which is the one option. There are no capture groups at all:\n * nothing asks where the match was, only whether there was one, which is why\n * this is a plain NFA simulation rather than a Pike VM.\n *\n * See ADR-0017.\n */\n\n/* -------------------------------------------------------------------------- */\n/* Errors */\n/* -------------------------------------------------------------------------- */\n\n/** A pattern that will not compile, and where in it the problem starts. */\nexport class PatternError extends Error {\n /** Offset into the pattern source. */\n readonly offset: number;\n\n constructor(message: string, offset: number) {\n super(message);\n this.name = 'PatternError';\n this.offset = offset;\n }\n}\n\n/**\n * Ceiling on the compiled program.\n *\n * Counted repetition is compiled by copying - `(ab){20}` is twenty copies -\n * which is part of what keeps the simulation flat, and also what makes\n * `(a{99}){99}` into ten thousand states. The bound has to live somewhere, and\n * a number checked while compiling is the only place it can be enforced without\n * measuring anything at match time.\n *\n * Far above any real selector: the widest pattern in this repository's own\n * tests compiles to seventeen states.\n */\nconst MAX_PROGRAM = 4096;\n\n/* -------------------------------------------------------------------------- */\n/* Character sets */\n/* -------------------------------------------------------------------------- */\n\n/** An inclusive range of UTF-16 code units. */\ntype Range = readonly [number, number];\n\n/**\n * A set of code units, as inclusive ranges.\n *\n * Code units rather than code points, because that is what a `RegExp` without\n * the `u` flag matches: `.` consumes one half of a surrogate pair, and so does\n * this. Agreeing with the engine this replaced matters more than being right\n * about astral planes, which no selector in any corpus has asked about.\n */\ninterface CharSet {\n readonly negated: boolean;\n readonly ranges: readonly Range[];\n}\n\n/** `.` - anything but a line terminator, which is the default `RegExp` reading. */\nconst DOT: CharSet = { negated: true, ranges: [[0x0a, 0x0a], [0x0d, 0x0d], [0x2028, 0x2029]] };\nconst DIGIT: readonly Range[] = [[0x30, 0x39]];\nconst WORD: readonly Range[] = [\n [0x30, 0x39],\n [0x41, 0x5a],\n [0x5f, 0x5f],\n [0x61, 0x7a],\n];\n/** `\\s`, taken from the specification rather than guessed at. */\nconst SPACE: readonly Range[] = [\n [0x09, 0x0d],\n [0x20, 0x20],\n [0xa0, 0xa0],\n [0x1680, 0x1680],\n [0x2000, 0x200a],\n [0x2028, 0x2029],\n [0x202f, 0x202f],\n [0x205f, 0x205f],\n [0x3000, 0x3000],\n [0xfeff, 0xfeff],\n];\n\n/**\n * Folds a code unit the way a case-insensitive `RegExp` does.\n *\n * This is `Canonicalize` from the language specification, non-Unicode mode:\n * upper-case the character, keep it unchanged if that produced anything other\n * than one code unit, and keep it unchanged if upper-casing dragged a\n * non-ASCII character into ASCII. The last clause is the one nobody expects and\n * the reason U+017F (long s) does not match `s`.\n */\nfunction canonical(code: number): number {\n // Every subject a glob sees is mostly ASCII, where the answer needs no string.\n // The general path below gives the same answer here, only slower.\n if (code < 128) return code >= 97 && code <= 122 ? code - 32 : code;\n const upper = String.fromCharCode(code).toUpperCase();\n if (upper.length !== 1) return code;\n const folded = upper.charCodeAt(0);\n if (code >= 128 && folded < 128) return code;\n return folded;\n}\n\n/**\n * Whether a set accepts a code unit, case-insensitively.\n *\n * The specification canonicalises both sides: a character matches a set when\n * *some* member of the set folds to the same thing it does. A single-character\n * member can be asked that exactly. A range cannot without a fold table for\n * every code unit, so a range is asked the question backwards - does the\n * character, or either of its own case forms, fall inside it - which is exact\n * for every character whose fold is its own case change, and therefore for\n * every range anyone has written.\n */\nfunction accepts(set: CharSet, code: number): boolean {\n const folded = canonical(code);\n let hit = false;\n for (let i = 0; i < set.ranges.length; i += 1) {\n const [low, high] = set.ranges[i] as Range;\n if (low === high ? low === code || canonical(low) === folded : inRange(low, high, code)) {\n hit = true;\n break;\n }\n }\n return set.negated ? !hit : hit;\n}\n\n/**\n * Whether some member of a range folds to the same thing a code unit does.\n *\n * Asked backwards, by trying the character's own case forms against the raw\n * range - and then checking that the form found there really does fold to the\n * same place, which is the part that is easy to leave out. U+017F upper-cases\n * to `S`, so without that check it matches `[A-Z]`, and it must not: the fold\n * keeps it outside ASCII, which is the same clause `isWordChar` gets wrong if\n * nobody is watching. The differential corpus caught both.\n */\nfunction inRange(low: number, high: number, code: number): boolean {\n if (code >= low && code <= high) return true;\n // An ASCII character's only other case form is its ASCII letter twin, and the\n // two always fold together - so the loop below would ask exactly this.\n if (code < 128) {\n const twin = code >= 65 && code <= 90 ? code + 32 : code >= 97 && code <= 122 ? code - 32 : -1;\n return twin >= low && twin <= high;\n }\n const folded = canonical(code);\n const char = String.fromCharCode(code);\n for (const variant of [char.toLowerCase(), char.toUpperCase()]) {\n if (variant.length !== 1) continue;\n const candidate = variant.charCodeAt(0);\n if (candidate >= low && candidate <= high && canonical(candidate) === folded) return true;\n }\n return false;\n}\n\n/**\n * Whether a set accepts a code unit as written.\n *\n * What `RegExp` does without the `i` flag, and so none of the folding above\n * applies - which also means none of its one divergence does.\n */\nfunction acceptsExactly(set: CharSet, code: number): boolean {\n return within(set.ranges, code) !== set.negated;\n}\n\nfunction within(ranges: readonly Range[], code: number): boolean {\n for (let i = 0; i < ranges.length; i += 1) {\n const range = ranges[i] as Range;\n if (code >= range[0] && code <= range[1]) return true;\n }\n return false;\n}\n\n/**\n * Word characters for `\\b`, which is exactly `\\w` here.\n *\n * The specification does widen this set under case-insensitivity - to every\n * character that folds into it, which is U+017F (long s) and U+212A (the\n * Kelvin sign) - but only in Unicode mode, where `Canonicalize` has no clause\n * keeping a non-ASCII character out of ASCII. This is the non-Unicode dialect,\n * so both stay outside and the table for `\\w` answers for `\\b` as well.\n *\n * Written down because the first version of this function widened the set, and\n * the differential test against `RegExp` is what said otherwise. Reading the\n * clause was not enough; running it was. See ADR-0017.\n */\nfunction isWordChar(code: number): boolean {\n return within(WORD, code);\n}\n\n/* -------------------------------------------------------------------------- */\n/* Syntax tree */\n/* -------------------------------------------------------------------------- */\n\ntype Assertion = 'start' | 'end' | 'word-boundary' | 'not-word-boundary';\n\ntype Node =\n | { readonly kind: 'empty' }\n | { readonly kind: 'char'; readonly set: CharSet }\n | { readonly kind: 'assert'; readonly assertion: Assertion }\n | { readonly kind: 'concat'; readonly parts: readonly Node[] }\n | { readonly kind: 'alternate'; readonly options: readonly Node[] }\n | { readonly kind: 'repeat'; readonly node: Node; readonly min: number; readonly max: number };\n\n/* -------------------------------------------------------------------------- */\n/* Parsing */\n/* -------------------------------------------------------------------------- */\n\nclass PatternParser {\n private readonly source: string;\n private position = 0;\n\n constructor(source: string) {\n this.source = source;\n }\n\n parse(): Node {\n const node = this.parseAlternation();\n // Every character is an atom except the two that close something, and\n // `parseSequence` stops on both, so anything left over is an unopened `)`.\n if (this.position < this.source.length) throw new PatternError('unmatched \")\"', this.position);\n return node;\n }\n\n private parseAlternation(): Node {\n const options: Node[] = [this.parseSequence()];\n while (this.peek() === '|') {\n this.position += 1;\n options.push(this.parseSequence());\n }\n return options.length === 1 ? (options[0] as Node) : { kind: 'alternate', options };\n }\n\n private parseSequence(): Node {\n const parts: Node[] = [];\n for (;;) {\n const char = this.peek();\n if (char === undefined || char === '|' || char === ')') break;\n parts.push(this.parseQuantified());\n }\n if (parts.length === 0) return { kind: 'empty' };\n return parts.length === 1 ? (parts[0] as Node) : { kind: 'concat', parts };\n }\n\n private parseQuantified(): Node {\n const start = this.position;\n // A group makes its contents quantifiable: `RegExp` rejects `\\b*` and\n // accepts `(\\b)*`, which is the same nothing said twice, and this parser\n // treats a group as transparent - so whether one was written is the only\n // thing left that distinguishes the two.\n const grouped = this.peek() === '(';\n const atom = this.parseAtom();\n const bounds = this.parseQuantifier();\n if (bounds === null) return atom;\n if (atom.kind === 'assert' && !grouped) {\n throw new PatternError('nothing to repeat: a quantifier cannot follow an anchor', start);\n }\n return { kind: 'repeat', node: atom, min: bounds.min, max: bounds.max };\n }\n\n /** `*`, `+`, `?`, `{n}`, `{n,}`, `{n,m}`, and a trailing `?` that is ignored. */\n private parseQuantifier(): { min: number; max: number } | null {\n const char = this.peek();\n let bounds: { min: number; max: number } | null = null;\n\n if (char === '*') bounds = { min: 0, max: Infinity };\n else if (char === '+') bounds = { min: 1, max: Infinity };\n else if (char === '?') bounds = { min: 0, max: 1 };\n\n if (bounds !== null) this.position += 1;\n else if (char === '{') bounds = this.parseBraces();\n if (bounds === null) return null;\n\n // Laziness decides *which* match is found, and nothing here asks: the\n // question is whether one exists, and a lazy quantifier accepts the same\n // language as a greedy one.\n if (this.peek() === '?') this.position += 1;\n return bounds;\n }\n\n /**\n * Reads `{n,m}`, or nothing.\n *\n * A `{` that does not open a counted repetition is a literal brace, which is\n * what `RegExp` does with `a{` and what any pattern written against a\n * document full of `{0}` placeholders depends on.\n */\n private parseBraces(): { min: number; max: number } | null {\n const match = /^\\{(\\d+)(?:(,)(\\d*))?\\}/.exec(this.source.slice(this.position));\n if (!match) return null;\n const min = Number(match[1]);\n const max = match[2] === undefined ? min : match[3] === '' ? Infinity : Number(match[3]);\n if (min > max) throw new PatternError('numbers out of order in a counted repetition', this.position);\n this.position += (match[0] as string).length;\n return { min, max };\n }\n\n private parseAtom(): Node {\n const start = this.position;\n const char = this.peek();\n\n switch (char) {\n case undefined:\n throw new PatternError('pattern ends where an expression was expected', start);\n case '(':\n return this.parseGroup();\n case '[':\n return { kind: 'char', set: this.parseClass() };\n case '.':\n this.position += 1;\n return { kind: 'char', set: DOT };\n case '^':\n this.position += 1;\n return { kind: 'assert', assertion: 'start' };\n case '$':\n this.position += 1;\n return { kind: 'assert', assertion: 'end' };\n case '*':\n case '+':\n throw new PatternError(`nothing to repeat before \"${char}\"`, start);\n case '\\\\':\n return this.parseEscape();\n default:\n this.position += 1;\n return { kind: 'char', set: literal(char.charCodeAt(0)) };\n }\n }\n\n /**\n * A group, which is never a capture.\n *\n * `(a)` and `(?:a)` compile to the same automaton because nothing downstream\n * can ask what `(a)` caught. A named group is accepted and its name dropped,\n * so a pattern copied out of somewhere else keeps working.\n */\n private parseGroup(): Node {\n const start = this.position;\n this.position += 1;\n\n if (this.source.startsWith('?:', this.position)) {\n this.position += 2;\n } else if (this.peek() === '?') {\n const named = /^\\?<([A-Za-z_$][\\w$]*)>/.exec(this.source.slice(this.position));\n if (named) {\n this.position += (named[0] as string).length;\n } else if (/^\\?(?:=|!|<=|<!)/.test(this.source.slice(this.position))) {\n throw new PatternError(\n 'lookaround is not supported: an automaton that cannot backtrack cannot look ahead - use ^= $= or *= for a fixed prefix, suffix or substring',\n start,\n );\n } else {\n throw new PatternError('unsupported group: expected (?:...) or (?<name>...)', start);\n }\n }\n\n const inner = this.parseAlternation();\n if (this.peek() !== ')') throw new PatternError('unmatched \"(\"', start);\n this.position += 1;\n return inner;\n }\n\n /**\n * Reads a `[...]` class.\n *\n * `[]` matches nothing and `[^]` matches anything, which reads like a mistake\n * and is what every JavaScript engine does: the class ends at the first `]`,\n * even when that `]` is the first character inside it.\n */\n private parseClass(): CharSet {\n const start = this.position;\n this.position += 1;\n const negated = this.peek() === '^';\n if (negated) this.position += 1;\n\n const ranges: Range[] = [];\n while (this.position < this.source.length && this.peek() !== ']') {\n const low = this.parseClassAtom();\n // A `-` between two single characters is a range. Anywhere else - at\n // either end of the class, or beside a `\\d`-style set, which has no\n // endpoint - it is a literal hyphen, exactly as Annex B has it.\n if (this.peek() !== '-' || this.source[this.position + 1] === ']' || this.position + 1 >= this.source.length) {\n push(ranges, low);\n continue;\n }\n const dash = this.position;\n this.position += 1;\n const high = this.parseClassAtom();\n if (typeof low === 'number' && typeof high === 'number') {\n if (low > high) throw new PatternError('characters out of order in a character class', dash);\n ranges.push([low, high]);\n continue;\n }\n push(ranges, low);\n ranges.push([0x2d, 0x2d]);\n push(ranges, high);\n }\n\n if (this.peek() !== ']') throw new PatternError('unterminated character class', start);\n this.position += 1;\n return { negated, ranges };\n }\n\n /** One member of a class: a code unit, or a whole set for `\\d` and its kind. */\n private parseClassAtom(): number | readonly Range[] {\n if (this.peek() !== '\\\\') {\n const code = (this.peek() as string).charCodeAt(0);\n this.position += 1;\n return code;\n }\n // `\\b` is a backspace inside a class and a word boundary outside one, which\n // is the only place the two readings of an escape diverge.\n if (this.source[this.position + 1] === 'b') {\n this.position += 2;\n return 0x08;\n }\n if (this.source[this.position + 1] === 'B') {\n throw new PatternError('\"\\\\B\" is an assertion, not a character, so it cannot be in a class', this.position);\n }\n const set = this.parseCharacterEscape();\n if (!set.negated && set.ranges.length === 1) {\n const [low, high] = set.ranges[0] as Range;\n if (low === high) return low;\n }\n return set.negated ? invert(set.ranges) : set.ranges;\n }\n\n /** An escape outside a class, where `\\b` and `\\B` are assertions. */\n private parseEscape(): Node {\n const next = this.source[this.position + 1];\n if (next === 'b' || next === 'B') {\n this.position += 2;\n return { kind: 'assert', assertion: next === 'b' ? 'word-boundary' : 'not-word-boundary' };\n }\n return { kind: 'char', set: this.parseCharacterEscape() };\n }\n\n /** Every escape that stands for a character or a set of them. */\n private parseCharacterEscape(): CharSet {\n const start = this.position;\n this.position += 1;\n const char = this.peek();\n if (char === undefined) throw new PatternError('pattern ends with a backslash', start);\n this.position += 1;\n\n switch (char) {\n case 'd':\n return { negated: false, ranges: DIGIT };\n case 'D':\n return { negated: true, ranges: DIGIT };\n case 'w':\n return { negated: false, ranges: WORD };\n case 'W':\n return { negated: true, ranges: WORD };\n case 's':\n return { negated: false, ranges: SPACE };\n case 'S':\n return { negated: true, ranges: SPACE };\n case 'n':\n return literal(0x0a);\n case 'r':\n return literal(0x0d);\n case 't':\n return literal(0x09);\n case 'f':\n return literal(0x0c);\n case 'v':\n return literal(0x0b);\n case '0':\n if (/^\\d/.test(this.source.slice(this.position))) {\n throw new PatternError('an octal escape is not supported - write \\\\xHH or \\\\uHHHH', start);\n }\n return literal(0);\n case 'x':\n return literal(this.readHex(2, start));\n case 'u':\n return literal(this.readHex(4, start));\n case 'c': {\n const letter = this.peek();\n if (letter === undefined || !/[A-Za-z]/.test(letter)) {\n throw new PatternError('expected a letter after \"\\\\c\"', start);\n }\n this.position += 1;\n return literal(letter.charCodeAt(0) % 32);\n }\n case 'k':\n throw new PatternError(\n 'a named backreference is not supported: a backreference is not a regular expression, and this is an automaton',\n start,\n );\n case 'p':\n case 'P':\n throw new PatternError(\n `\"\\\\${char}\" needs a table of Unicode properties, which this matcher does not carry - write the characters out as a [class]`,\n start,\n );\n default:\n if (/[1-9]/.test(char)) {\n throw new PatternError(\n 'a backreference is not supported: it is not a regular expression, and this is an automaton',\n start,\n );\n }\n if (/[A-Za-z]/.test(char)) {\n // `RegExp` reads an unknown letter escape as the letter itself, so\n // `\\A` quietly matches a capital A and `\\z` a lower-case z. Saying so\n // is worth more than agreeing with a rule nobody wanted.\n throw new PatternError(`unknown escape \"\\\\${char}\"`, start);\n }\n return literal(char.charCodeAt(0));\n }\n }\n\n private readHex(digits: number, start: number): number {\n const raw = this.source.slice(this.position, this.position + digits);\n if (raw.length !== digits || !/^[0-9a-fA-F]+$/.test(raw)) {\n throw new PatternError(`expected ${digits} hex digits after \"\\\\${this.source[start + 1] as string}\"`, start);\n }\n this.position += digits;\n return Number.parseInt(raw, 16);\n }\n\n private peek(): string | undefined {\n return this.source[this.position];\n }\n}\n\nfunction literal(code: number): CharSet {\n return { negated: false, ranges: [[code, code]] };\n}\n\nfunction push(ranges: Range[], atom: number | readonly Range[]): void {\n if (typeof atom === 'number') ranges.push([atom, atom]);\n else ranges.push(...atom);\n}\n\n/**\n * Complement of a range list, so `[\\D]` can sit inside a class.\n *\n * A negated escape is a set with no endpoints, and a class is a union of\n * ranges, so the only way to put one inside the other is to spell out what it\n * leaves.\n */\nfunction invert(ranges: readonly Range[]): readonly Range[] {\n const sorted = [...ranges].sort((a, b) => a[0] - b[0]);\n const out: Range[] = [];\n let cursor = 0;\n for (const [low, high] of sorted) {\n if (low > cursor) out.push([cursor, low - 1]);\n cursor = Math.max(cursor, high + 1);\n }\n if (cursor <= 0xffff) out.push([cursor, 0xffff]);\n return out;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Compilation */\n/* -------------------------------------------------------------------------- */\n\ninterface Split {\n readonly op: 'split';\n /** Where the first branch starts. */\n x: number;\n /** Where the second branch starts. */\n y: number;\n}\n\ninterface Jump {\n readonly op: 'jump';\n to: number;\n}\n\ntype Instruction =\n | { readonly op: 'char'; readonly set: CharSet }\n | Split\n | Jump\n | { readonly op: 'assert'; readonly assertion: Assertion }\n | { readonly op: 'match' };\n\nclass Compiler {\n readonly code: Instruction[] = [];\n\n private add<T extends Instruction>(instruction: T): T {\n if (this.code.length >= MAX_PROGRAM) {\n throw new PatternError(\n `pattern is too large: counted repetition is compiled by copying, and this needs more than ${MAX_PROGRAM} states`,\n 0,\n );\n }\n this.code.push(instruction);\n return instruction;\n }\n\n get here(): number {\n return this.code.length;\n }\n\n emitMatch(): void {\n this.add({ op: 'match' });\n }\n\n compile(node: Node): void {\n switch (node.kind) {\n case 'empty':\n return;\n case 'char':\n this.add({ op: 'char', set: node.set });\n return;\n case 'assert':\n this.add({ op: 'assert', assertion: node.assertion });\n return;\n case 'concat':\n for (const part of node.parts) this.compile(part);\n return;\n case 'alternate': {\n // One split per option but the last. Each split falls through to its\n // own branch and points its second arm at the next split; each branch\n // ends in a jump past all of them.\n const ends: Jump[] = [];\n for (let i = 0; i < node.options.length - 1; i += 1) {\n const split = this.add({ op: 'split', x: 0, y: 0 });\n split.x = this.here;\n this.compile(node.options[i] as Node);\n ends.push(this.add({ op: 'jump', to: 0 }));\n split.y = this.here;\n }\n this.compile(node.options[node.options.length - 1] as Node);\n for (const end of ends) end.to = this.here;\n return;\n }\n case 'repeat':\n this.repeat(node.node, node.min, node.max);\n return;\n }\n }\n\n private repeat(node: Node, min: number, max: number): void {\n for (let i = 0; i < min; i += 1) this.compile(node);\n\n if (max === Infinity) {\n const split = this.add({ op: 'split', x: 0, y: 0 });\n const body = this.here;\n split.x = body;\n this.compile(node);\n this.add({ op: 'jump', to: body - 1 });\n split.y = this.here;\n return;\n }\n\n // `{2,5}` is two copies and then three optional ones, each able to leave\n // for the far end rather than for the next copy.\n const exits: Split[] = [];\n for (let i = min; i < max; i += 1) {\n const split = this.add({ op: 'split', x: 0, y: 0 });\n split.x = this.here;\n exits.push(split);\n this.compile(node);\n }\n for (const split of exits) split.y = this.here;\n }\n}\n\n/* -------------------------------------------------------------------------- */\n/* Simulation */\n/* -------------------------------------------------------------------------- */\n\n/**\n * A compiled pattern. Reusable and safe to cache.\n *\n * Not reentrant, which nothing can ask of it: `test` is synchronous and calls\n * out to nothing, and the buffers it keeps between subjects are what make it\n * cheap enough to run against every path a walk visits.\n */\nexport interface Matcher {\n /** True when the pattern matches anywhere in the subject. */\n test(subject: string): boolean;\n /** State count. Published for the size test, and for nothing else. */\n readonly size: number;\n}\n\nexport interface PatternOptions {\n /** Fold case the way the `i` flag does. On unless set to `false`. */\n readonly ignoreCase?: boolean | undefined;\n}\n\n/**\n * Compiles a pattern into a matcher.\n *\n * Throws {@link PatternError} on anything it cannot run in linear time, which\n * is the point: the alternative to a message here is a build that stops.\n */\nexport function compilePattern(source: string, options: PatternOptions = {}): Matcher {\n const tree = new PatternParser(source).parse();\n const compiler = new Compiler();\n compiler.compile(tree);\n compiler.emitMatch();\n // A pattern that begins by asserting the start of the subject cannot match\n // anywhere else, so the simulation stops seeding new threads at every\n // position. Nothing depends on this being noticed - it is the difference\n // between one pass and two over a long body.\n const machine = new Machine(compiler.code, startsAnchored(tree), options.ignoreCase !== false);\n return {\n size: compiler.code.length,\n test: (subject: string): boolean => machine.test(subject),\n };\n}\n\n/** True when every path through the pattern opens by asserting the start. */\nfunction startsAnchored(node: Node): boolean {\n switch (node.kind) {\n case 'assert':\n return node.assertion === 'start';\n case 'concat': {\n const first = node.parts[0];\n return first !== undefined && startsAnchored(first);\n }\n case 'alternate':\n return node.options.every((option) => startsAnchored(option));\n case 'repeat':\n return node.min > 0 && startsAnchored(node.node);\n default:\n return false;\n }\n}\n\nconst OP_CHAR = 0;\nconst OP_SPLIT = 1;\nconst OP_JUMP = 2;\nconst OP_ASSERT = 3;\nconst OP_MATCH = 4;\n\n/** Fills the slots of states that are not characters, where nothing reads it. */\nconst NOTHING: CharSet = { negated: false, ranges: [] };\n\n/**\n * The simulation, over the program flattened into typed arrays.\n *\n * The compiler's instructions are objects of five shapes, and one loop reading\n * `op` off all five is a megamorphic property read on every step. Simulated that\n * way, with a fresh visited table per subject, a glob cost about 3.5\n * microseconds a path and a path that failed on its first character still paid\n * half a microsecond for the allocation. Flat arrays and buffers kept between\n * subjects bring those to 0.6 and 0.04 - `RegExp` takes 0.06 - which matters\n * because a walk tests every path it visits against every pattern.\n */\nclass Machine {\n private readonly ops: Uint8Array;\n /** A split's first branch, or a jump's target. */\n private readonly first: Int32Array;\n /** A split's second branch. */\n private readonly second: Int32Array;\n private readonly sets: CharSet[];\n private readonly assertions: Assertion[];\n private readonly anchored: boolean;\n private readonly ignoreCase: boolean;\n\n /**\n * The position each state was last reached at. One visit per state per\n * position is exactly what turns the exponent into a product.\n */\n private readonly visited: Int32Array;\n /** Each visit pushes at most two states, so this cannot overflow. */\n private readonly stack: Int32Array;\n private live: Int32Array;\n private next: Int32Array;\n\n constructor(code: readonly Instruction[], anchored: boolean, ignoreCase: boolean) {\n const size = code.length;\n this.ops = new Uint8Array(size);\n this.first = new Int32Array(size);\n this.second = new Int32Array(size);\n this.sets = new Array<CharSet>(size).fill(NOTHING);\n this.assertions = new Array<Assertion>(size).fill('start');\n this.anchored = anchored;\n this.ignoreCase = ignoreCase;\n this.visited = new Int32Array(size).fill(-1);\n this.stack = new Int32Array(2 * size + 1);\n this.live = new Int32Array(size);\n this.next = new Int32Array(size);\n\n code.forEach((instruction, pc) => {\n switch (instruction.op) {\n case 'char':\n this.ops[pc] = OP_CHAR;\n this.sets[pc] = instruction.set;\n break;\n case 'split':\n this.ops[pc] = OP_SPLIT;\n this.first[pc] = instruction.x;\n this.second[pc] = instruction.y;\n break;\n case 'jump':\n this.ops[pc] = OP_JUMP;\n this.first[pc] = instruction.to;\n break;\n case 'assert':\n this.ops[pc] = OP_ASSERT;\n this.assertions[pc] = instruction.assertion;\n break;\n case 'match':\n this.ops[pc] = OP_MATCH;\n break;\n }\n });\n }\n\n test(subject: string): boolean {\n const length = subject.length;\n this.visited.fill(-1);\n\n let live = this.live;\n let next = this.next;\n let alive = 0;\n\n for (let position = 0; position <= length; position += 1) {\n if (position === 0 || !this.anchored) {\n alive = this.seed(live, alive, 0, subject, position);\n if (alive < 0) return true;\n } else if (alive === 0) {\n // An anchored pattern gets one chance, and every thread from it has died.\n return false;\n }\n\n if (position === length) return false;\n const char = subject.charCodeAt(position);\n let arriving = 0;\n for (let i = 0; i < alive; i += 1) {\n const pc = live[i] as number;\n const set = this.sets[pc] as CharSet;\n if (!(this.ignoreCase ? accepts(set, char) : acceptsExactly(set, char))) continue;\n arriving = this.seed(next, arriving, pc + 1, subject, position + 1);\n if (arriving < 0) return true;\n }\n const spent = live;\n live = next;\n next = spent;\n alive = arriving;\n }\n\n return false;\n }\n\n /**\n * Follows every zero-width transition out of one state, appending the\n * character states it reaches to `list`.\n *\n * Returns the new length of the list, or -1 the moment a thread reaches the\n * end of the pattern: the only question is whether a match exists, so there\n * is no leftmost-longest to settle and no captures to keep, and the first\n * thread to arrive is the answer.\n *\n * A stray thread at state 0 changes no answer: an unanchored pattern seeds it\n * at every position anyway, and an anchored one opens by asserting the start.\n * That makes two mutants here equivalent, with no test to write - the loop\n * running once past an empty stack, and a jump read as a split, both of which\n * add exactly that thread.\n */\n private seed(list: Int32Array, length: number, start: number, subject: string, position: number): number {\n const { ops, first, second, visited, stack } = this;\n let count = length;\n let top = 0;\n stack[top++] = start;\n while (top > 0) {\n const pc = stack[--top] as number;\n if (visited[pc] === position) continue;\n visited[pc] = position;\n switch (ops[pc]) {\n case OP_MATCH:\n return -1;\n case OP_JUMP:\n stack[top++] = first[pc] as number;\n break;\n case OP_SPLIT:\n stack[top++] = second[pc] as number;\n stack[top++] = first[pc] as number;\n break;\n case OP_ASSERT:\n if (holds(this.assertions[pc] as Assertion, subject, position)) stack[top++] = pc + 1;\n break;\n default:\n list[count++] = pc;\n }\n }\n return count;\n }\n}\n\nfunction holds(assertion: Assertion, subject: string, position: number): boolean {\n switch (assertion) {\n case 'start':\n return position === 0;\n case 'end':\n return position === subject.length;\n default: {\n const before = position > 0 && isWordChar(subject.charCodeAt(position - 1));\n const after = position < subject.length && isWordChar(subject.charCodeAt(position));\n return (before !== after) === (assertion === 'word-boundary');\n }\n }\n}\n"]}
|