@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glob.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/pattern/glob.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EACL,OAAO,EACP,WAAW,EACX,OAAO,EACP,cAAc,GAIf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAkB,MAAM,cAAc,CAAC;AA2CpF,MAAM,OAAO,SAAU,SAAQ,KAAK;IACzB,MAAM,CAAS;IACxB,YAAY,MAAc,EAAE,MAAc;QACxC,KAAK,CAAC,iBAAiB,MAA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;QACxC,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxE,IAAI,CAAC,MAAM,CAAC,EAAE;YAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,OAAO,MAAM,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;QAC7E,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO;QACL,EAAE,EAAE,IAAI;QACR,IAAI,EAAE;YACJ,OAAO;YACP,KAAK,CAAC,IAAY;gBAChB,IAAI,QAAQ,GAAG,KAAK,CAAC;gBACrB,KAAK,MAAM,KAAK,IAAI,OAAO;oBAAE,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;wBAAE,QAAQ,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC;gBACnF,OAAO,QAAQ,CAAC;YAClB,CAAC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Globs, in the three dialects the spec-* tools speak, compiled to one kind of\n * automaton.\n *\n * The syntax is the part people type: `*`, `**`, `?`, `[abc]`, `[!a-z]`,\n * `{a,b}`, and `\\` to escape. What differs between the tools is not the\n * syntax but what a pattern is matched against, and those differences are\n * deliberate, so each has a name (docs/adr/0003-glob-dialects.md):\n *\n * - `path` - the whole repository-relative path, anchored at the root. A\n * pattern with no glob syntax names a file, a directory, or either, as the\n * caller says; `src/auth` may cover `src/auth/login.ts`.\n * - `ripgrep` - as ripgrep's `-g`: a pattern with no `/` is matched against\n * the last segment at any depth, so `*.ts` matches `src/deep/a.ts`; one with\n * a `/` is matched against the whole path.\n * - `gitignore` - as an exclusion list reads: a pattern matches a path or any\n * directory above it, so `tests` excludes everything under any `tests`; one\n * with a `/` other than a trailing one is anchored at the root, and a\n * leading `/` only anchors.\n *\n * Shared by all three:\n *\n * - `**` is a globstar only as a whole segment. `a/**\\/b` matches `a/b` and\n * `a/x/y/b`; a trailing `/**` matches everything inside a directory and not\n * the directory itself. Two stars inside a name, `**.md`, are refused: the\n * tools read it three ways, and the quiet reading narrowed their scope.\n * - `*`, `?` and classes never match `/`, and `*` matches a leading dot.\n * - Case is the caller's decision, stated every time. A result must not\n * depend on the host it ran on.\n * - A malformed pattern is an error, never a literal. An unclosed `[` or `{`,\n * an extended glob, a `..` - each is refused with a reason, because a typo\n * read as a literal is a scope that silently matches nothing. An extended\n * glob is a group holding a `|`, `+(a|b)`: without one, `C++(notes).md` is\n * a name with parentheses in it, as ripgrep and `.gitignore` read it.\n */\n\nimport {\n Builder,\n findWitness,\n Matcher,\n WITNESS_BUDGET,\n type Automaton,\n type Fragment,\n type Witness,\n} from './automaton.js';\nimport { ANY, classSet, literalSet, SEPARATOR, type CodeRange } from './charset.js';\n\nexport type GlobDialect = 'path' | 'ripgrep' | 'gitignore';\n\n/** How a `path` pattern with no glob syntax is read. */\nexport type LiteralReading = 'file' | 'directory' | 'either';\n\nexport interface GlobOptions {\n readonly dialect: GlobDialect;\n /** Whether `A` and `a` differ. No default: the caller decides, every time. */\n readonly caseSensitive: boolean;\n /**\n * `path` dialect only: how a pattern with no glob syntax is read - as a\n * file, as a directory and everything beneath it, or as either. A function\n * is asked per literal path, for a caller that knows the tree. `either` when\n * unset. A trailing `/` always means a directory.\n */\n readonly literal?: LiteralReading | ((path: string) => LiteralReading) | undefined;\n /**\n * `escape` (the default): `\\` escapes the next character, and a `\\` before a\n * letter or digit is refused as a Windows separator typed by mistake.\n * `separator`: every `\\` is a `/`, for patterns typed on a Windows shell.\n */\n readonly backslash?: 'escape' | 'separator' | undefined;\n}\n\nexport interface Glob {\n readonly source: string;\n readonly dialect: GlobDialect;\n readonly caseSensitive: boolean;\n /**\n * The directories a walk must enter to find every match: one per\n * alternative, the leading literal segments. `''` for an alternative that\n * can match at any depth.\n */\n readonly bases: readonly string[];\n readonly automaton: Automaton;\n /** Whether a canonical path - POSIX, no `.`, no empty or trailing segment - matches. */\n match(path: string): boolean;\n}\n\nexport type GlobParse = { readonly ok: true; readonly glob: Glob } | { readonly ok: false; readonly error: string };\n\nexport class GlobError extends Error {\n readonly source: string;\n constructor(source: string, reason: string) {\n super(`invalid glob \"${source}\": ${reason}`);\n this.name = 'GlobError';\n this.source = source;\n }\n}\n\n/** More alternatives than this is a pattern nobody meant. */\nexport const MAX_ALTERNATIVES = 256;\n\ntype Token =\n | { readonly kind: 'literal'; readonly point: number }\n | { readonly kind: 'any' }\n | { readonly kind: 'star' }\n | { readonly kind: 'class'; readonly negated: boolean; readonly ranges: readonly CodeRange[] };\n\ntype Segment = { readonly kind: 'globstar' } | { readonly kind: 'name'; readonly tokens: readonly Token[] };\n\ninterface Alternative {\n readonly segments: readonly Segment[];\n /** Written with a `/` somewhere other than at its end. */\n readonly slashed: boolean;\n}\n\n/** Whether a string uses glob syntax at all. */\nexport function isGlobSyntax(source: string): boolean {\n return /[*?[\\]{}]/.test(source);\n}\n\n/** Parses and compiles a glob, or says why it cannot. */\nexport function parseGlob(source: string, options: GlobOptions): GlobParse {\n const result = build(source, options);\n return typeof result === 'string' ? { ok: false, error: result } : { ok: true, glob: result };\n}\n\n/** Parses and compiles a glob, throwing {@link GlobError} when it cannot. */\nexport function compileGlob(source: string, options: GlobOptions): Glob {\n const result = build(source, options);\n if (typeof result === 'string') throw new GlobError(source, result);\n return result;\n}\n\nfunction build(source: string, options: GlobOptions): Glob | string {\n const escapes = options.backslash !== 'separator';\n let pattern = source.trim();\n if (!escapes) pattern = pattern.replace(/\\\\/g, '/');\n if (pattern.length === 0) return 'the pattern is empty';\n if (pattern.startsWith('!')) return 'a negated pattern is a list entry, not a glob; narrow the positive pattern';\n if (/(?:^|[^\\\\])[?*+@!]\\([^)]*\\|/.test(pattern)) return EXTGLOB;\n while (pattern.startsWith('./')) pattern = pattern.slice(2);\n\n // A leading slash roots a pattern at the filesystem's root in the path and\n // ripgrep dialects, and only anchors it at the repository root in gitignore.\n let rooted = false;\n let anchored = false;\n if (pattern.startsWith('/')) {\n if (options.dialect === 'gitignore') anchored = true;\n else rooted = true;\n pattern = pattern.replace(/^\\/+/, '');\n }\n // A trailing slash means a directory's contents, except in an exclusion,\n // where `build/` and `build` exclude the same things.\n if (pattern.endsWith('/')) {\n pattern = pattern.replace(/\\/+$/, '');\n if (options.dialect !== 'gitignore') pattern = `${pattern}/**`;\n }\n if (pattern.length === 0) return 'the pattern names the root itself, not a path under it';\n\n const expanded = expandBraces(pattern, escapes);\n if (typeof expanded === 'string') return expanded;\n\n const alternatives: Alternative[] = [];\n for (const text of expanded) {\n const parsed = parseAlternative(text, escapes);\n if (typeof parsed === 'string') return parsed;\n alternatives.push(parsed);\n }\n\n const builder = new Builder();\n const fragments: Fragment[] = [];\n const bases: string[] = [];\n for (const alternative of alternatives) {\n const compiled = compileAlternative(builder, alternative, options, rooted, anchored);\n fragments.push(compiled.fragment);\n bases.push(compiled.base);\n }\n const automaton = builder.finish(builder.either(fragments), options.caseSensitive);\n let matcher: Matcher | null = null;\n return {\n source,\n dialect: options.dialect,\n caseSensitive: options.caseSensitive,\n bases: [...new Set(bases)],\n automaton,\n match(path: string): boolean {\n matcher ??= new Matcher(automaton);\n return matcher.test(path);\n },\n };\n}\n\n/* ------------------------------------------------------------------ braces */\n\n/**\n * Expands `{a,b}` groups into the patterns they stand for, or says why the\n * pattern is malformed.\n *\n * Classes and escapes are skipped while looking for braces and commas, so\n * `{[,]x,y}` is two alternatives, `[,]x` and `y`. A lone `}` is a literal: it\n * cannot be read as anything else. An unclosed `{` is an error.\n */\nfunction expandBraces(pattern: string, escapes: boolean): string[] | string {\n let depth = 0;\n let open = -1;\n for (let i = 0; i < pattern.length; i += 1) {\n const ch = pattern.charAt(i);\n if (ch === '\\\\' && escapes) {\n i += 1;\n continue;\n }\n if (ch === '[') {\n const close = classEnd(pattern, i, escapes);\n if (close > 0) i = close;\n continue;\n }\n if (ch === '{') {\n if (depth === 0) open = i;\n depth += 1;\n continue;\n }\n if (ch !== '}' || depth === 0) continue;\n depth -= 1;\n if (depth > 0) continue;\n const prefix = pattern.slice(0, open);\n const suffix = pattern.slice(i + 1);\n const results: string[] = [];\n for (const option of splitOptions(pattern.slice(open + 1, i), escapes)) {\n const expanded = expandBraces(`${prefix}${option}${suffix}`, escapes);\n if (typeof expanded === 'string') return expanded;\n results.push(...expanded);\n if (results.length > MAX_ALTERNATIVES) return `the braces expand to more than ${MAX_ALTERNATIVES} patterns`;\n }\n return results;\n }\n if (depth > 0) return 'a \"{\" is never closed';\n return [pattern];\n}\n\n/** Splits a brace body on its top-level commas. */\nfunction splitOptions(body: string, escapes: boolean): string[] {\n const parts: string[] = [];\n let depth = 0;\n let start = 0;\n for (let i = 0; i < body.length; i += 1) {\n const ch = body.charAt(i);\n if (ch === '\\\\' && escapes) {\n i += 1;\n } else if (ch === '[') {\n const close = classEnd(body, i, escapes);\n if (close > 0) i = close;\n } else if (ch === '{') {\n depth += 1;\n } else if (ch === '}') {\n depth -= 1;\n } else if (ch === ',' && depth === 0) {\n parts.push(body.slice(start, i));\n start = i + 1;\n }\n }\n parts.push(body.slice(start));\n return parts;\n}\n\n/** The index of the `]` closing a class opened at `open`, or -1 when none does within the segment. */\nfunction classEnd(pattern: string, open: number, escapes: boolean): number {\n let i = open + 1;\n if (pattern.charAt(i) === '!' || pattern.charAt(i) === '^') i += 1;\n // The first member is always a member, even `]`.\n if (pattern.charAt(i) === ']') i += 1;\n for (; i < pattern.length; i += 1) {\n const ch = pattern.charAt(i);\n if (ch === '\\\\' && escapes) {\n i += 1;\n continue;\n }\n if (ch === '/') return -1;\n if (ch === ']') return i;\n }\n return -1;\n}\n\n/* ---------------------------------------------------------------- segments */\n\nfunction parseAlternative(text: string, escapes: boolean): Alternative | string {\n const segments: Segment[] = [];\n const raw = text.split('/');\n for (const part of raw) {\n if (part === '' || part === '.') continue;\n if (part === '..') return 'a pattern cannot climb out of its root with \"..\"';\n if (part === '**') {\n if (segments[segments.length - 1]?.kind !== 'globstar') segments.push({ kind: 'globstar' });\n continue;\n }\n const tokens = tokenize(part, escapes);\n if (typeof tokens === 'string') return tokens;\n segments.push({ kind: 'name', tokens });\n }\n if (segments.length === 0) return 'the pattern names no path';\n return { segments, slashed: raw.filter((part) => part !== '' && part !== '.').length > 1 };\n}\n\nconst EXTGLOB = 'extended globs such as \"+(a|b)\" are not supported: write alternatives as \"{a,b}\", and a literal parenthesis as \"[(]\"';\nconst GLOBSTAR_IN_NAME = '\"**\" means any number of directories only as a whole segment: write \"docs/**/*.md\" for any depth, or \"*.md\" for one level';\n\nfunction tokenize(segment: string, escapes: boolean): Token[] | string {\n const tokens: Token[] = [];\n const chars = Array.from(segment);\n for (let i = 0; i < chars.length; i += 1) {\n const ch = chars[i] as string;\n if (ch === '\\\\' && escapes) {\n const next = chars[i + 1];\n if (next === undefined || /[A-Za-z0-9]/.test(next)) {\n return '\"\\\\\" escapes glob syntax; separate directories with \"/\"';\n }\n tokens.push({ kind: 'literal', point: next.codePointAt(0) as number });\n i += 1;\n } else if (ch === '*') {\n // Two stars inside a name are refused rather than read as one. The\n // tools this replaces read `docs/**.md` three ways - recursive, one\n // level, and as ripgrep does - and reading it as one level silently\n // dropped every nested document from a run that used to include them.\n if (chars[i + 1] === '*') return GLOBSTAR_IN_NAME;\n tokens.push({ kind: 'star' });\n } else if (ch === '?') {\n tokens.push({ kind: 'any' });\n } else if (ch === '[') {\n const parsed = readClass(chars, i, escapes);\n if (typeof parsed === 'string') return parsed;\n tokens.push(parsed.token);\n i = parsed.end;\n } else {\n tokens.push({ kind: 'literal', point: ch.codePointAt(0) as number });\n }\n }\n return tokens;\n}\n\nfunction readClass(chars: readonly string[], open: number, escapes: boolean): { token: Token; end: number } | string {\n let i = open + 1;\n let negated = false;\n if (chars[i] === '!' || chars[i] === '^') {\n negated = true;\n i += 1;\n }\n const ranges: CodeRange[] = [];\n let first = true;\n for (; i < chars.length; i += 1) {\n const ch = chars[i] as string;\n if (ch === ']' && !first) return { token: { kind: 'class', negated, ranges }, end: i };\n first = false;\n let low = ch;\n if (ch === '\\\\' && escapes && chars[i + 1] !== undefined) {\n i += 1;\n low = chars[i] as string;\n }\n let high = low;\n if (chars[i + 1] === '-' && chars[i + 2] !== undefined && chars[i + 2] !== ']') {\n i += 2;\n high = chars[i] as string;\n if (high === '\\\\' && escapes && chars[i + 1] !== undefined) {\n i += 1;\n high = chars[i] as string;\n }\n }\n const from = low.codePointAt(0) as number;\n const to = high.codePointAt(0) as number;\n if (to < from) return `the range \"${low}-${high}\" runs backwards`;\n ranges.push([from, to]);\n }\n return 'a \"[\" is never closed';\n}\n\n/* --------------------------------------------------------------- compiling */\n\nfunction literalText(segments: readonly Segment[]): string | null {\n const names: string[] = [];\n for (const segment of segments) {\n if (segment.kind !== 'name') return null;\n let name = '';\n for (const token of segment.tokens) {\n if (token.kind !== 'literal') return null;\n name += String.fromCodePoint(token.point);\n }\n names.push(name);\n }\n return names.join('/');\n}\n\n/** One segment name: at least one character, none of them `/`. */\nfunction name(b: Builder): Fragment {\n return b.plus(b.char(ANY));\n}\n\n/** Zero or more whole directories: `(name/)*`. */\nfunction anyDirectories(b: Builder): Fragment {\n return b.star(b.sequence([name(b), b.char(SEPARATOR)]));\n}\n\n/** One or more whole segments below a path: `/name(/name)*`. */\nfunction beneath(b: Builder): Fragment {\n return b.sequence([b.char(SEPARATOR), name(b), b.star(b.sequence([b.char(SEPARATOR), name(b)]))]);\n}\n\nfunction tokens(b: Builder, list: readonly Token[]): Fragment {\n return b.sequence(\n list.map((token) => {\n switch (token.kind) {\n case 'literal':\n return b.char(literalSet(token.point));\n case 'any':\n return b.char(ANY);\n case 'star':\n return b.star(b.char(ANY));\n case 'class':\n return b.char(classSet(token.ranges, token.negated));\n }\n }),\n );\n}\n\nfunction segmentsFragment(b: Builder, segments: readonly Segment[]): Fragment {\n const parts: Fragment[] = [];\n segments.forEach((segment, i) => {\n const last = i === segments.length - 1;\n if (segment.kind === 'globstar') {\n // Inside a path a globstar is any number of whole directories, the\n // separator after them included; at its end, at least one segment.\n parts.push(last ? b.sequence([name(b), b.star(b.sequence([b.char(SEPARATOR), name(b)]))]) : anyDirectories(b));\n return;\n }\n parts.push(tokens(b, segment.tokens));\n if (!last) parts.push(b.char(SEPARATOR));\n });\n return b.sequence(parts);\n}\n\nfunction compileAlternative(\n b: Builder,\n alternative: Alternative,\n options: GlobOptions,\n rooted: boolean,\n anchored: boolean,\n): { fragment: Fragment; base: string } {\n const { segments } = alternative;\n const body = segmentsFragment(b, segments);\n const root = rooted ? '/' : '';\n const literal = literalText(segments);\n const leading = leadingLiteral(segments);\n\n if (options.dialect === 'gitignore') {\n const floating = !anchored && !alternative.slashed;\n const parts = [body, b.optional(beneath(b))];\n if (floating) parts.unshift(anyDirectories(b));\n const base = literal !== null ? leading.slice(0, -1) : leading;\n return { fragment: b.sequence(parts), base: floating ? '' : base.join('/') };\n }\n\n if (options.dialect === 'ripgrep' && !rooted && !alternative.slashed) {\n return { fragment: b.sequence([anyDirectories(b), body]), base: '' };\n }\n\n const parts = rooted ? [b.char(SEPARATOR), body] : [body];\n if (options.dialect === 'path' && literal !== null) {\n const reading = typeof options.literal === 'function' ? options.literal(root + literal) : options.literal ?? 'either';\n if (reading === 'directory') {\n parts.push(beneath(b));\n return { fragment: b.sequence(parts), base: root + literal };\n }\n if (reading === 'either') parts.push(b.optional(beneath(b)));\n }\n // A literal path may be a file, whose base is the directory holding it.\n const base = literal !== null ? leading.slice(0, -1) : leading;\n return { fragment: b.sequence(parts), base: root + base.join('/') };\n}\n\nfunction leadingLiteral(segments: readonly Segment[]): string[] {\n const out: string[] = [];\n for (const segment of segments) {\n const text = literalText([segment]);\n if (text === null) break;\n out.push(text);\n }\n return out;\n}\n\n/* ---------------------------------------------------------------- questions */\n\nfunction assertComparable(globs: readonly Glob[]): void {\n for (const glob of globs) {\n if (!glob.caseSensitive) throw new Error(`\"${glob.source}\" ignores case; scopes are compared case-sensitively`);\n }\n}\n\n/**\n * A shortest path every glob in `include` matches and no glob in `exclude`\n * does: the file two scopes would both write, less what either protects.\n * `none` is a proof that there is no such path. Case-sensitive globs only.\n */\nexport function globWitness(\n include: readonly Glob[],\n exclude: readonly Glob[] = [],\n budget: number = WITNESS_BUDGET,\n): Witness {\n assertComparable([...include, ...exclude]);\n return findWitness(\n include.map((glob) => glob.automaton),\n exclude.map((glob) => glob.automaton),\n budget,\n );\n}\n\n/**\n * Whether every path `inner` matches is matched by one of `outer`: `true`,\n * `false`, or `undecided` when the search met its budget.\n */\nexport function globCovers(\n outer: readonly Glob[],\n inner: Glob,\n budget: number = WITNESS_BUDGET,\n): boolean | 'undecided' {\n const witness = globWitness([inner], outer, budget);\n return witness.kind === 'undecided' ? 'undecided' : witness.kind === 'none';\n}\n\n/* -------------------------------------------------------------------- lists */\n\nexport interface GlobList {\n /** Whether a path is in: the last entry that matches it decides, and a `!` entry takes it out. */\n match(path: string): boolean;\n readonly entries: readonly { readonly negated: boolean; readonly glob: Glob }[];\n}\n\nexport type GlobListParse = { readonly ok: true; readonly list: GlobList } | { readonly ok: false; readonly error: string };\n\n/**\n * A list of patterns read the way a `.gitignore` reads: in order, each entry\n * deciding the paths it matches, a leading `!` taking them back out.\n */\nexport function parseGlobList(patterns: readonly string[], options: GlobOptions): GlobListParse {\n const entries: { negated: boolean; glob: Glob }[] = [];\n for (const pattern of patterns) {\n const trimmed = pattern.trim();\n const negated = trimmed.startsWith('!');\n const parsed = parseGlob(negated ? trimmed.slice(1) : trimmed, options);\n if (!parsed.ok) return { ok: false, error: `\"${pattern}\": ${parsed.error}` };\n entries.push({ negated, glob: parsed.glob });\n }\n return {\n ok: true,\n list: {\n entries,\n match(path: string): boolean {\n let included = false;\n for (const entry of entries) if (entry.glob.match(path)) included = !entry.negated;\n return included;\n },\n },\n };\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { compileGlob, globCovers, globWitness, isGlobSyntax, parseGlob, parseGlobList, GlobError, MAX_ALTERNATIVES } from './glob.js';
|
|
2
|
+
export type { Glob, GlobDialect, GlobList, GlobListParse, GlobOptions, GlobParse, LiteralReading } from './glob.js';
|
|
3
|
+
export { AutomatonTooLarge, MAX_STATES, WITNESS_BUDGET } from './automaton.js';
|
|
4
|
+
export type { Witness } from './automaton.js';
|
|
5
|
+
export { compileRegex, RegexError } from './regex.js';
|
|
6
|
+
export type { RegexMatcher, RegexOptions } from './regex.js';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { compileGlob, globCovers, globWitness, isGlobSyntax, parseGlob, parseGlobList, GlobError, MAX_ALTERNATIVES } from './glob.js';
|
|
2
|
+
export { AutomatonTooLarge, MAX_STATES, WITNESS_BUDGET } from './automaton.js';
|
|
3
|
+
export { compileRegex, RegexError } from './regex.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/pattern/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAEtI,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE/E,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC","sourcesContent":["export { compileGlob, globCovers, globWitness, isGlobSyntax, parseGlob, parseGlobList, GlobError, MAX_ALTERNATIVES } from './glob.js';\nexport type { Glob, GlobDialect, GlobList, GlobListParse, GlobOptions, GlobParse, LiteralReading } from './glob.js';\nexport { AutomatonTooLarge, MAX_STATES, WITNESS_BUDGET } from './automaton.js';\nexport type { Witness } from './automaton.js';\nexport { compileRegex, RegexError } from './regex.js';\nexport type { RegexMatcher, RegexOptions } from './regex.js';\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A regular-expression matcher that cannot backtrack.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Written for spec-graph, whose `~=` selector used to hand a user-supplied
|
|
5
|
+
* string to `RegExp` and wait (spec-graph ADR-0017), and moved here so that
|
|
6
|
+
* every tool that accepts a pattern from configuration or from a document can
|
|
7
|
+
* run it unattended in CI without a pattern deciding how long CI takes.
|
|
8
8
|
*
|
|
9
9
|
* The cost is neither theoretical nor exotic. `^([A-Za-z0-9_]+[ ]?)+$` is what
|
|
10
10
|
* somebody writes to say "the title is words separated by single spaces", and
|
|
@@ -18,34 +18,25 @@
|
|
|
18
18
|
* the quick brown fox jumps over the lazy dog and keeps! 103s 13us
|
|
19
19
|
* ```
|
|
20
20
|
*
|
|
21
|
-
*
|
|
22
|
-
* tries the product of those, which is why adding one five-letter word costs
|
|
23
|
-
* another factor of sixteen. A sixty-character title does not finish this year.
|
|
24
|
-
*
|
|
25
|
-
* So a pattern here is compiled to a **non-deterministic finite automaton** and
|
|
21
|
+
* So a pattern here is compiled to a non-deterministic finite automaton and
|
|
26
22
|
* simulated over the subject one character at a time (Thompson, 1968), keeping
|
|
27
23
|
* a set of live states instead of a stack of choices. Each state is visited at
|
|
28
|
-
* most once per position, which makes the work
|
|
29
|
-
*
|
|
30
|
-
* pattern's ambiguity.
|
|
24
|
+
* most once per position, which makes the work O(pattern x subject), growing
|
|
25
|
+
* with the subject and not with the pattern's ambiguity.
|
|
31
26
|
*
|
|
32
27
|
* What it costs is a dialect. Backreferences and lookaround are not regular and
|
|
33
|
-
* have no place in a linear automaton, so they are
|
|
34
|
-
* with a message and an offset, rather than accepted and then slow.
|
|
35
|
-
* whole trade: a predicate that finishes, against a short list of constructs
|
|
36
|
-
* that a documentation selector never needed.
|
|
37
|
-
*
|
|
38
|
-
* Matching is unanchored and, by default, case-insensitive, because that is
|
|
39
|
-
* what `~=` has always been - `new RegExp(source, 'i')` and `.test()`. Globs
|
|
40
|
-
* compile to this as well, and a path on a case-sensitive filesystem needs the
|
|
41
|
-
* case respected, which is the one option. There are no capture groups at all:
|
|
42
|
-
* nothing asks where the match was, only whether there was one, which is why
|
|
43
|
-
* this is a plain NFA simulation rather than a Pike VM.
|
|
28
|
+
* have no place in a linear automaton, so they are rejected while compiling,
|
|
29
|
+
* with a message and an offset, rather than accepted and then slow.
|
|
44
30
|
*
|
|
45
|
-
*
|
|
31
|
+
* The dialect is JavaScript's without the `u` flag, character for character,
|
|
32
|
+
* and is held to that by a differential test against `RegExp`: code units,
|
|
33
|
+
* not code points, and `i` folding by the specification's `Canonicalize`.
|
|
34
|
+
* Matching is unanchored and, unless `ignoreCase: false` is passed,
|
|
35
|
+
* case-insensitive, which is what spec-graph's `~=` has always been. There
|
|
36
|
+
* are no captures: nothing asks where a match was, only whether there was one.
|
|
46
37
|
*/
|
|
47
38
|
/** A pattern that will not compile, and where in it the problem starts. */
|
|
48
|
-
export declare class
|
|
39
|
+
export declare class RegexError extends Error {
|
|
49
40
|
/** Offset into the pattern source. */
|
|
50
41
|
readonly offset: number;
|
|
51
42
|
constructor(message: string, offset: number);
|
|
@@ -57,20 +48,20 @@ export declare class PatternError extends Error {
|
|
|
57
48
|
* out to nothing, and the buffers it keeps between subjects are what make it
|
|
58
49
|
* cheap enough to run against every path a walk visits.
|
|
59
50
|
*/
|
|
60
|
-
export interface
|
|
51
|
+
export interface RegexMatcher {
|
|
61
52
|
/** True when the pattern matches anywhere in the subject. */
|
|
62
53
|
test(subject: string): boolean;
|
|
63
54
|
/** State count. Published for the size test, and for nothing else. */
|
|
64
55
|
readonly size: number;
|
|
65
56
|
}
|
|
66
|
-
export interface
|
|
57
|
+
export interface RegexOptions {
|
|
67
58
|
/** Fold case the way the `i` flag does. On unless set to `false`. */
|
|
68
59
|
readonly ignoreCase?: boolean | undefined;
|
|
69
60
|
}
|
|
70
61
|
/**
|
|
71
62
|
* Compiles a pattern into a matcher.
|
|
72
63
|
*
|
|
73
|
-
* Throws {@link
|
|
64
|
+
* Throws {@link RegexError} on anything it cannot run in linear time, which
|
|
74
65
|
* is the point: the alternative to a message here is a build that stops.
|
|
75
66
|
*/
|
|
76
|
-
export declare function
|
|
67
|
+
export declare function compileRegex(source: string, options?: RegexOptions): RegexMatcher;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A regular-expression matcher that cannot backtrack.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Written for spec-graph, whose `~=` selector used to hand a user-supplied
|
|
5
|
+
* string to `RegExp` and wait (spec-graph ADR-0017), and moved here so that
|
|
6
|
+
* every tool that accepts a pattern from configuration or from a document can
|
|
7
|
+
* run it unattended in CI without a pattern deciding how long CI takes.
|
|
8
8
|
*
|
|
9
9
|
* The cost is neither theoretical nor exotic. `^([A-Za-z0-9_]+[ ]?)+$` is what
|
|
10
10
|
* somebody writes to say "the title is words separated by single spaces", and
|
|
@@ -18,42 +18,33 @@
|
|
|
18
18
|
* the quick brown fox jumps over the lazy dog and keeps! 103s 13us
|
|
19
19
|
* ```
|
|
20
20
|
*
|
|
21
|
-
*
|
|
22
|
-
* tries the product of those, which is why adding one five-letter word costs
|
|
23
|
-
* another factor of sixteen. A sixty-character title does not finish this year.
|
|
24
|
-
*
|
|
25
|
-
* So a pattern here is compiled to a **non-deterministic finite automaton** and
|
|
21
|
+
* So a pattern here is compiled to a non-deterministic finite automaton and
|
|
26
22
|
* simulated over the subject one character at a time (Thompson, 1968), keeping
|
|
27
23
|
* a set of live states instead of a stack of choices. Each state is visited at
|
|
28
|
-
* most once per position, which makes the work
|
|
29
|
-
*
|
|
30
|
-
* pattern's ambiguity.
|
|
24
|
+
* most once per position, which makes the work O(pattern x subject), growing
|
|
25
|
+
* with the subject and not with the pattern's ambiguity.
|
|
31
26
|
*
|
|
32
27
|
* What it costs is a dialect. Backreferences and lookaround are not regular and
|
|
33
|
-
* have no place in a linear automaton, so they are
|
|
34
|
-
* with a message and an offset, rather than accepted and then slow.
|
|
35
|
-
* whole trade: a predicate that finishes, against a short list of constructs
|
|
36
|
-
* that a documentation selector never needed.
|
|
37
|
-
*
|
|
38
|
-
* Matching is unanchored and, by default, case-insensitive, because that is
|
|
39
|
-
* what `~=` has always been - `new RegExp(source, 'i')` and `.test()`. Globs
|
|
40
|
-
* compile to this as well, and a path on a case-sensitive filesystem needs the
|
|
41
|
-
* case respected, which is the one option. There are no capture groups at all:
|
|
42
|
-
* nothing asks where the match was, only whether there was one, which is why
|
|
43
|
-
* this is a plain NFA simulation rather than a Pike VM.
|
|
28
|
+
* have no place in a linear automaton, so they are rejected while compiling,
|
|
29
|
+
* with a message and an offset, rather than accepted and then slow.
|
|
44
30
|
*
|
|
45
|
-
*
|
|
31
|
+
* The dialect is JavaScript's without the `u` flag, character for character,
|
|
32
|
+
* and is held to that by a differential test against `RegExp`: code units,
|
|
33
|
+
* not code points, and `i` folding by the specification's `Canonicalize`.
|
|
34
|
+
* Matching is unanchored and, unless `ignoreCase: false` is passed,
|
|
35
|
+
* case-insensitive, which is what spec-graph's `~=` has always been. There
|
|
36
|
+
* are no captures: nothing asks where a match was, only whether there was one.
|
|
46
37
|
*/
|
|
47
38
|
/* -------------------------------------------------------------------------- */
|
|
48
39
|
/* Errors */
|
|
49
40
|
/* -------------------------------------------------------------------------- */
|
|
50
41
|
/** A pattern that will not compile, and where in it the problem starts. */
|
|
51
|
-
export class
|
|
42
|
+
export class RegexError extends Error {
|
|
52
43
|
/** Offset into the pattern source. */
|
|
53
44
|
offset;
|
|
54
45
|
constructor(message, offset) {
|
|
55
46
|
super(message);
|
|
56
|
-
this.name = '
|
|
47
|
+
this.name = 'RegexError';
|
|
57
48
|
this.offset = offset;
|
|
58
49
|
}
|
|
59
50
|
}
|
|
@@ -195,7 +186,7 @@ function within(ranges, code) {
|
|
|
195
186
|
*
|
|
196
187
|
* Written down because the first version of this function widened the set, and
|
|
197
188
|
* the differential test against `RegExp` is what said otherwise. Reading the
|
|
198
|
-
* clause was not enough; running it was. See ADR-0017.
|
|
189
|
+
* clause was not enough; running it was. See spec-graph ADR-0017.
|
|
199
190
|
*/
|
|
200
191
|
function isWordChar(code) {
|
|
201
192
|
return within(WORD, code);
|
|
@@ -214,7 +205,7 @@ class PatternParser {
|
|
|
214
205
|
// Every character is an atom except the two that close something, and
|
|
215
206
|
// `parseSequence` stops on both, so anything left over is an unopened `)`.
|
|
216
207
|
if (this.position < this.source.length)
|
|
217
|
-
throw new
|
|
208
|
+
throw new RegexError('unmatched ")"', this.position);
|
|
218
209
|
return node;
|
|
219
210
|
}
|
|
220
211
|
parseAlternation() {
|
|
@@ -249,7 +240,7 @@ class PatternParser {
|
|
|
249
240
|
if (bounds === null)
|
|
250
241
|
return atom;
|
|
251
242
|
if (atom.kind === 'assert' && !grouped) {
|
|
252
|
-
throw new
|
|
243
|
+
throw new RegexError('nothing to repeat: a quantifier cannot follow an anchor', start);
|
|
253
244
|
}
|
|
254
245
|
return { kind: 'repeat', node: atom, min: bounds.min, max: bounds.max };
|
|
255
246
|
}
|
|
@@ -290,7 +281,7 @@ class PatternParser {
|
|
|
290
281
|
const min = Number(match[1]);
|
|
291
282
|
const max = match[2] === undefined ? min : match[3] === '' ? Infinity : Number(match[3]);
|
|
292
283
|
if (min > max)
|
|
293
|
-
throw new
|
|
284
|
+
throw new RegexError('numbers out of order in a counted repetition', this.position);
|
|
294
285
|
this.position += match[0].length;
|
|
295
286
|
return { min, max };
|
|
296
287
|
}
|
|
@@ -299,7 +290,7 @@ class PatternParser {
|
|
|
299
290
|
const char = this.peek();
|
|
300
291
|
switch (char) {
|
|
301
292
|
case undefined:
|
|
302
|
-
throw new
|
|
293
|
+
throw new RegexError('pattern ends where an expression was expected', start);
|
|
303
294
|
case '(':
|
|
304
295
|
return this.parseGroup();
|
|
305
296
|
case '[':
|
|
@@ -315,7 +306,7 @@ class PatternParser {
|
|
|
315
306
|
return { kind: 'assert', assertion: 'end' };
|
|
316
307
|
case '*':
|
|
317
308
|
case '+':
|
|
318
|
-
throw new
|
|
309
|
+
throw new RegexError(`nothing to repeat before "${char}"`, start);
|
|
319
310
|
case '\\':
|
|
320
311
|
return this.parseEscape();
|
|
321
312
|
default:
|
|
@@ -342,15 +333,15 @@ class PatternParser {
|
|
|
342
333
|
this.position += named[0].length;
|
|
343
334
|
}
|
|
344
335
|
else if (/^\?(?:=|!|<=|<!)/.test(this.source.slice(this.position))) {
|
|
345
|
-
throw new
|
|
336
|
+
throw new RegexError('lookaround is not supported: an automaton that cannot backtrack cannot look ahead - use ^= $= or *= for a fixed prefix, suffix or substring', start);
|
|
346
337
|
}
|
|
347
338
|
else {
|
|
348
|
-
throw new
|
|
339
|
+
throw new RegexError('unsupported group: expected (?:...) or (?<name>...)', start);
|
|
349
340
|
}
|
|
350
341
|
}
|
|
351
342
|
const inner = this.parseAlternation();
|
|
352
343
|
if (this.peek() !== ')')
|
|
353
|
-
throw new
|
|
344
|
+
throw new RegexError('unmatched "("', start);
|
|
354
345
|
this.position += 1;
|
|
355
346
|
return inner;
|
|
356
347
|
}
|
|
@@ -382,7 +373,7 @@ class PatternParser {
|
|
|
382
373
|
const high = this.parseClassAtom();
|
|
383
374
|
if (typeof low === 'number' && typeof high === 'number') {
|
|
384
375
|
if (low > high)
|
|
385
|
-
throw new
|
|
376
|
+
throw new RegexError('characters out of order in a character class', dash);
|
|
386
377
|
ranges.push([low, high]);
|
|
387
378
|
continue;
|
|
388
379
|
}
|
|
@@ -391,7 +382,7 @@ class PatternParser {
|
|
|
391
382
|
push(ranges, high);
|
|
392
383
|
}
|
|
393
384
|
if (this.peek() !== ']')
|
|
394
|
-
throw new
|
|
385
|
+
throw new RegexError('unterminated character class', start);
|
|
395
386
|
this.position += 1;
|
|
396
387
|
return { negated, ranges };
|
|
397
388
|
}
|
|
@@ -409,7 +400,7 @@ class PatternParser {
|
|
|
409
400
|
return 0x08;
|
|
410
401
|
}
|
|
411
402
|
if (this.source[this.position + 1] === 'B') {
|
|
412
|
-
throw new
|
|
403
|
+
throw new RegexError('"\\B" is an assertion, not a character, so it cannot be in a class', this.position);
|
|
413
404
|
}
|
|
414
405
|
const set = this.parseCharacterEscape();
|
|
415
406
|
if (!set.negated && set.ranges.length === 1) {
|
|
@@ -434,7 +425,7 @@ class PatternParser {
|
|
|
434
425
|
this.position += 1;
|
|
435
426
|
const char = this.peek();
|
|
436
427
|
if (char === undefined)
|
|
437
|
-
throw new
|
|
428
|
+
throw new RegexError('pattern ends with a backslash', start);
|
|
438
429
|
this.position += 1;
|
|
439
430
|
switch (char) {
|
|
440
431
|
case 'd':
|
|
@@ -461,7 +452,7 @@ class PatternParser {
|
|
|
461
452
|
return literal(0x0b);
|
|
462
453
|
case '0':
|
|
463
454
|
if (/^\d/.test(this.source.slice(this.position))) {
|
|
464
|
-
throw new
|
|
455
|
+
throw new RegexError('an octal escape is not supported - write \\xHH or \\uHHHH', start);
|
|
465
456
|
}
|
|
466
457
|
return literal(0);
|
|
467
458
|
case 'x':
|
|
@@ -471,25 +462,25 @@ class PatternParser {
|
|
|
471
462
|
case 'c': {
|
|
472
463
|
const letter = this.peek();
|
|
473
464
|
if (letter === undefined || !/[A-Za-z]/.test(letter)) {
|
|
474
|
-
throw new
|
|
465
|
+
throw new RegexError('expected a letter after "\\c"', start);
|
|
475
466
|
}
|
|
476
467
|
this.position += 1;
|
|
477
468
|
return literal(letter.charCodeAt(0) % 32);
|
|
478
469
|
}
|
|
479
470
|
case 'k':
|
|
480
|
-
throw new
|
|
471
|
+
throw new RegexError('a named backreference is not supported: a backreference is not a regular expression, and this is an automaton', start);
|
|
481
472
|
case 'p':
|
|
482
473
|
case 'P':
|
|
483
|
-
throw new
|
|
474
|
+
throw new RegexError(`"\\${char}" needs a table of Unicode properties, which this matcher does not carry - write the characters out as a [class]`, start);
|
|
484
475
|
default:
|
|
485
476
|
if (/[1-9]/.test(char)) {
|
|
486
|
-
throw new
|
|
477
|
+
throw new RegexError('a backreference is not supported: it is not a regular expression, and this is an automaton', start);
|
|
487
478
|
}
|
|
488
479
|
if (/[A-Za-z]/.test(char)) {
|
|
489
480
|
// `RegExp` reads an unknown letter escape as the letter itself, so
|
|
490
481
|
// `\A` quietly matches a capital A and `\z` a lower-case z. Saying so
|
|
491
482
|
// is worth more than agreeing with a rule nobody wanted.
|
|
492
|
-
throw new
|
|
483
|
+
throw new RegexError(`unknown escape "\\${char}"`, start);
|
|
493
484
|
}
|
|
494
485
|
return literal(char.charCodeAt(0));
|
|
495
486
|
}
|
|
@@ -497,7 +488,7 @@ class PatternParser {
|
|
|
497
488
|
readHex(digits, start) {
|
|
498
489
|
const raw = this.source.slice(this.position, this.position + digits);
|
|
499
490
|
if (raw.length !== digits || !/^[0-9a-fA-F]+$/.test(raw)) {
|
|
500
|
-
throw new
|
|
491
|
+
throw new RegexError(`expected ${digits} hex digits after "\\${this.source[start + 1]}"`, start);
|
|
501
492
|
}
|
|
502
493
|
this.position += digits;
|
|
503
494
|
return Number.parseInt(raw, 16);
|
|
@@ -539,7 +530,7 @@ class Compiler {
|
|
|
539
530
|
code = [];
|
|
540
531
|
add(instruction) {
|
|
541
532
|
if (this.code.length >= MAX_PROGRAM) {
|
|
542
|
-
throw new
|
|
533
|
+
throw new RegexError(`pattern is too large: counted repetition is compiled by copying, and this needs more than ${MAX_PROGRAM} states`, 0);
|
|
543
534
|
}
|
|
544
535
|
this.code.push(instruction);
|
|
545
536
|
return instruction;
|
|
@@ -614,10 +605,10 @@ class Compiler {
|
|
|
614
605
|
/**
|
|
615
606
|
* Compiles a pattern into a matcher.
|
|
616
607
|
*
|
|
617
|
-
* Throws {@link
|
|
608
|
+
* Throws {@link RegexError} on anything it cannot run in linear time, which
|
|
618
609
|
* is the point: the alternative to a message here is a build that stops.
|
|
619
610
|
*/
|
|
620
|
-
export function
|
|
611
|
+
export function compileRegex(source, options = {}) {
|
|
621
612
|
const tree = new PatternParser(source).parse();
|
|
622
613
|
const compiler = new Compiler();
|
|
623
614
|
compiler.compile(tree);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regex.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/pattern/regex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF,2EAA2E;AAC3E,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnC,sCAAsC;IAC7B,MAAM,CAAS;IAExB,YAAY,OAAe,EAAE,MAAc;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,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,CA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AC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC;YAC5E,MAAM,KAAK,GAAG,QAAQ,GAAG,OAAO,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 * Written for spec-graph, whose `~=` selector used to hand a user-supplied\n * string to `RegExp` and wait (spec-graph ADR-0017), and moved here so that\n * every tool that accepts a pattern from configuration or from a document can\n * run it unattended in CI without a pattern deciding how long CI takes.\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 * 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 O(pattern x subject), growing\n * with the subject and not with the 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.\n *\n * The dialect is JavaScript's without the `u` flag, character for character,\n * and is held to that by a differential test against `RegExp`: code units,\n * not code points, and `i` folding by the specification's `Canonicalize`.\n * Matching is unanchored and, unless `ignoreCase: false` is passed,\n * case-insensitive, which is what spec-graph's `~=` has always been. There\n * are no captures: nothing asks where a match was, only whether there was one.\n */\n\n/* -------------------------------------------------------------------------- */\n/* Errors */\n/* -------------------------------------------------------------------------- */\n\n/** A pattern that will not compile, and where in it the problem starts. */\nexport class RegexError 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 = 'RegexError';\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 spec-graph 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 RegexError('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 RegexError('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 RegexError('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 RegexError('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 RegexError(`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 RegexError(\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 RegexError('unsupported group: expected (?:...) or (?<name>...)', start);\n }\n }\n\n const inner = this.parseAlternation();\n if (this.peek() !== ')') throw new RegexError('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 RegexError('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 RegexError('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 RegexError('\"\\\\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 RegexError('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 RegexError('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 RegexError('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 RegexError(\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 RegexError(\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 RegexError(\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 RegexError(`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 RegexError(`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 RegexError(\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 RegexMatcher {\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 RegexOptions {\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 RegexError} 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 compileRegex(source: string, options: RegexOptions = {}): RegexMatcher {\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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/text/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,QAAQ,EACR,UAAU,EACV,UAAU,EACV,MAAM,EACN,UAAU,EACV,WAAW,EACX,UAAU,EACV,QAAQ,GACT,MAAM,YAAY,CAAC","sourcesContent":["export {\n createLineIndex,\n inRanges,\n lineEnding,\n lineStarts,\n locate,\n maskRanges,\n mergeRanges,\n splitLines,\n stripBom,\n} from './lines.js';\nexport type { LineIndex, Position, Range } from './lines.js';\n"]}
|