@pattern-algebra/core 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +571 -0
- package/dist/automaton/complement.d.ts +20 -0
- package/dist/automaton/complement.d.ts.map +1 -0
- package/dist/automaton/complement.js +36 -0
- package/dist/automaton/complement.js.map +1 -0
- package/dist/automaton/complement.test.d.ts +2 -0
- package/dist/automaton/complement.test.d.ts.map +1 -0
- package/dist/automaton/complement.test.js +114 -0
- package/dist/automaton/complement.test.js.map +1 -0
- package/dist/automaton/determinize.d.ts +41 -0
- package/dist/automaton/determinize.d.ts.map +1 -0
- package/dist/automaton/determinize.js +310 -0
- package/dist/automaton/determinize.js.map +1 -0
- package/dist/automaton/determinize.test.d.ts +2 -0
- package/dist/automaton/determinize.test.d.ts.map +1 -0
- package/dist/automaton/determinize.test.js +134 -0
- package/dist/automaton/determinize.test.js.map +1 -0
- package/dist/automaton/emptiness.d.ts +41 -0
- package/dist/automaton/emptiness.d.ts.map +1 -0
- package/dist/automaton/emptiness.js +262 -0
- package/dist/automaton/emptiness.js.map +1 -0
- package/dist/automaton/emptiness.test.d.ts +2 -0
- package/dist/automaton/emptiness.test.d.ts.map +1 -0
- package/dist/automaton/emptiness.test.js +154 -0
- package/dist/automaton/emptiness.test.js.map +1 -0
- package/dist/automaton/index.d.ts +10 -0
- package/dist/automaton/index.d.ts.map +1 -0
- package/dist/automaton/index.js +11 -0
- package/dist/automaton/index.js.map +1 -0
- package/dist/automaton/intersect.d.ts +35 -0
- package/dist/automaton/intersect.d.ts.map +1 -0
- package/dist/automaton/intersect.js +302 -0
- package/dist/automaton/intersect.js.map +1 -0
- package/dist/automaton/pattern-algebra.d.ts +62 -0
- package/dist/automaton/pattern-algebra.d.ts.map +1 -0
- package/dist/automaton/pattern-algebra.js +309 -0
- package/dist/automaton/pattern-algebra.js.map +1 -0
- package/dist/automaton/pattern-algebra.test.d.ts +2 -0
- package/dist/automaton/pattern-algebra.test.d.ts.map +1 -0
- package/dist/automaton/pattern-algebra.test.js +223 -0
- package/dist/automaton/pattern-algebra.test.js.map +1 -0
- package/dist/compile/automaton-builder.d.ts +47 -0
- package/dist/compile/automaton-builder.d.ts.map +1 -0
- package/dist/compile/automaton-builder.js +211 -0
- package/dist/compile/automaton-builder.js.map +1 -0
- package/dist/compile/compiler.d.ts +32 -0
- package/dist/compile/compiler.d.ts.map +1 -0
- package/dist/compile/compiler.js +47 -0
- package/dist/compile/compiler.js.map +1 -0
- package/dist/compile/index.d.ts +8 -0
- package/dist/compile/index.d.ts.map +1 -0
- package/dist/compile/index.js +8 -0
- package/dist/compile/index.js.map +1 -0
- package/dist/compile/quick-reject.d.ts +28 -0
- package/dist/compile/quick-reject.d.ts.map +1 -0
- package/dist/compile/quick-reject.js +147 -0
- package/dist/compile/quick-reject.js.map +1 -0
- package/dist/containment/analysis.d.ts +60 -0
- package/dist/containment/analysis.d.ts.map +1 -0
- package/dist/containment/analysis.js +378 -0
- package/dist/containment/analysis.js.map +1 -0
- package/dist/containment/containment.d.ts +23 -0
- package/dist/containment/containment.d.ts.map +1 -0
- package/dist/containment/containment.js +681 -0
- package/dist/containment/containment.js.map +1 -0
- package/dist/containment/containment.test.d.ts +2 -0
- package/dist/containment/containment.test.d.ts.map +1 -0
- package/dist/containment/containment.test.js +209 -0
- package/dist/containment/containment.test.js.map +1 -0
- package/dist/containment/index.d.ts +7 -0
- package/dist/containment/index.d.ts.map +1 -0
- package/dist/containment/index.js +7 -0
- package/dist/containment/index.js.map +1 -0
- package/dist/core-alpha.d.ts +1253 -0
- package/dist/core-beta.d.ts +1253 -0
- package/dist/core-public.d.ts +1253 -0
- package/dist/core-unstripped.d.ts +1253 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/match/index.d.ts +8 -0
- package/dist/match/index.d.ts.map +1 -0
- package/dist/match/index.js +8 -0
- package/dist/match/index.js.map +1 -0
- package/dist/match/matcher.d.ts +40 -0
- package/dist/match/matcher.d.ts.map +1 -0
- package/dist/match/matcher.js +256 -0
- package/dist/match/matcher.js.map +1 -0
- package/dist/match/matcher.test.d.ts +2 -0
- package/dist/match/matcher.test.d.ts.map +1 -0
- package/dist/match/matcher.test.js +185 -0
- package/dist/match/matcher.test.js.map +1 -0
- package/dist/match/path-utils.d.ts +132 -0
- package/dist/match/path-utils.d.ts.map +1 -0
- package/dist/match/path-utils.js +223 -0
- package/dist/match/path-utils.js.map +1 -0
- package/dist/match/path-utils.test.d.ts +2 -0
- package/dist/match/path-utils.test.d.ts.map +1 -0
- package/dist/match/path-utils.test.js +193 -0
- package/dist/match/path-utils.test.js.map +1 -0
- package/dist/match/segment-matcher.d.ts +25 -0
- package/dist/match/segment-matcher.d.ts.map +1 -0
- package/dist/match/segment-matcher.js +267 -0
- package/dist/match/segment-matcher.js.map +1 -0
- package/dist/parse/brace-expansion.d.ts +34 -0
- package/dist/parse/brace-expansion.d.ts.map +1 -0
- package/dist/parse/brace-expansion.js +294 -0
- package/dist/parse/brace-expansion.js.map +1 -0
- package/dist/parse/brace-expansion.test.d.ts +2 -0
- package/dist/parse/brace-expansion.test.d.ts.map +1 -0
- package/dist/parse/brace-expansion.test.js +105 -0
- package/dist/parse/brace-expansion.test.js.map +1 -0
- package/dist/parse/index.d.ts +8 -0
- package/dist/parse/index.d.ts.map +1 -0
- package/dist/parse/index.js +8 -0
- package/dist/parse/index.js.map +1 -0
- package/dist/parse/parser.d.ts +15 -0
- package/dist/parse/parser.d.ts.map +1 -0
- package/dist/parse/parser.js +526 -0
- package/dist/parse/parser.js.map +1 -0
- package/dist/parse/parser.test.d.ts +2 -0
- package/dist/parse/parser.test.d.ts.map +1 -0
- package/dist/parse/parser.test.js +266 -0
- package/dist/parse/parser.test.js.map +1 -0
- package/dist/parse/validator.d.ts +30 -0
- package/dist/parse/validator.d.ts.map +1 -0
- package/dist/parse/validator.js +115 -0
- package/dist/parse/validator.js.map +1 -0
- package/dist/parse/validator.test.d.ts +2 -0
- package/dist/parse/validator.test.d.ts.map +1 -0
- package/dist/parse/validator.test.js +45 -0
- package/dist/parse/validator.test.js.map +1 -0
- package/dist/types/ast.d.ts +158 -0
- package/dist/types/ast.d.ts.map +1 -0
- package/dist/types/ast.js +2 -0
- package/dist/types/ast.js.map +1 -0
- package/dist/types/automaton.d.ts +150 -0
- package/dist/types/automaton.d.ts.map +1 -0
- package/dist/types/automaton.js +2 -0
- package/dist/types/automaton.js.map +1 -0
- package/dist/types/containment.d.ts +257 -0
- package/dist/types/containment.d.ts.map +1 -0
- package/dist/types/containment.js +5 -0
- package/dist/types/containment.js.map +1 -0
- package/dist/types/errors.d.ts +37 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +24 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { PatternError } from './errors';
|
|
2
|
+
/**
|
|
3
|
+
* Root pattern node - the entry point for any parsed pattern.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface PathPattern {
|
|
7
|
+
/** Original pattern string for error messages and debugging */
|
|
8
|
+
readonly source: string;
|
|
9
|
+
/** Parsed structure */
|
|
10
|
+
readonly root: PatternNode;
|
|
11
|
+
/** Whether this is an absolute pattern (starts with / or ~) */
|
|
12
|
+
readonly isAbsolute: boolean;
|
|
13
|
+
/** Whether this is a negation pattern (starts with !) */
|
|
14
|
+
readonly isNegation: boolean;
|
|
15
|
+
/** Validation errors, if any */
|
|
16
|
+
readonly errors?: readonly PatternError[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A node in the pattern AST. Patterns are sequences of segments or alternations.
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export type PatternNode = SegmentSequence | Alternation;
|
|
23
|
+
/**
|
|
24
|
+
* A sequence of path segments (the most common case).
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* "src/**\/*.ts" becomes:
|
|
28
|
+
* segments: [Literal("src"), Globstar, Wildcard("*.ts")]
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export interface SegmentSequence {
|
|
33
|
+
readonly type: 'sequence';
|
|
34
|
+
readonly segments: readonly Segment[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Brace expansion creates alternation between pattern branches.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* "\{src,lib\}/**\/*.ts" becomes:
|
|
41
|
+
* Alternation([
|
|
42
|
+
* SegmentSequence([Literal("src"), Globstar, Wildcard("*.ts")]),
|
|
43
|
+
* SegmentSequence([Literal("lib"), Globstar, Wildcard("*.ts")])
|
|
44
|
+
* ])
|
|
45
|
+
*
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
export interface Alternation {
|
|
49
|
+
readonly type: 'alternation';
|
|
50
|
+
readonly branches: readonly PatternNode[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A segment represents one path component between slashes.
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
export type Segment = LiteralSegment | WildcardSegment | GlobstarSegment | CharClassSegment | CompositeSegment;
|
|
57
|
+
/**
|
|
58
|
+
* An exact literal match for a path segment.
|
|
59
|
+
*
|
|
60
|
+
* @example "package.json" matches only "package.json"
|
|
61
|
+
*
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
export interface LiteralSegment {
|
|
65
|
+
readonly type: 'literal';
|
|
66
|
+
readonly value: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A segment containing wildcards (* or ?).
|
|
70
|
+
*
|
|
71
|
+
* Compiles to a regex pattern for the segment.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* "*.ts" -> parts: [{ type: "star" }, { type: "literal", value: ".ts" }]
|
|
75
|
+
* "test-*-spec.js" -> complex pattern
|
|
76
|
+
*
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
export interface WildcardSegment {
|
|
80
|
+
readonly type: 'wildcard';
|
|
81
|
+
/** Original pattern text for this segment */
|
|
82
|
+
readonly pattern: string;
|
|
83
|
+
/** Components for efficient prefix/suffix matching */
|
|
84
|
+
readonly parts: readonly WildcardPart[];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* A part of a wildcard segment pattern.
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
export type WildcardPart = {
|
|
91
|
+
readonly type: 'literal';
|
|
92
|
+
readonly value: string;
|
|
93
|
+
} | {
|
|
94
|
+
readonly type: 'star';
|
|
95
|
+
} | {
|
|
96
|
+
readonly type: 'question';
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* The ** globstar - matches zero or more complete segments.
|
|
100
|
+
* @public
|
|
101
|
+
*/
|
|
102
|
+
export interface GlobstarSegment {
|
|
103
|
+
readonly type: 'globstar';
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* A character class like [a-z] or [!0-9].
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
109
|
+
export interface CharClassSegment {
|
|
110
|
+
readonly type: 'charclass';
|
|
111
|
+
/** Whether this is a negated class (e.g., [!abc] or [^abc]) */
|
|
112
|
+
readonly negated: boolean;
|
|
113
|
+
/** Character ranges (e.g., a-z, 0-9) */
|
|
114
|
+
readonly ranges: readonly CharRange[];
|
|
115
|
+
/** Individual characters not in ranges */
|
|
116
|
+
readonly chars: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* A character range within a character class.
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
export interface CharRange {
|
|
123
|
+
/** Single character - start of range */
|
|
124
|
+
readonly start: string;
|
|
125
|
+
/** Single character - end of range */
|
|
126
|
+
readonly end: string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* A segment composed of multiple parts (literal + wildcard + charclass).
|
|
130
|
+
*
|
|
131
|
+
* @example "test-[0-9]*-spec.ts" is a composite of:
|
|
132
|
+
* - literal "test-"
|
|
133
|
+
* - charclass [0-9]
|
|
134
|
+
* - star *
|
|
135
|
+
* - literal "-spec.ts"
|
|
136
|
+
*
|
|
137
|
+
* @public
|
|
138
|
+
*/
|
|
139
|
+
export interface CompositeSegment {
|
|
140
|
+
readonly type: 'composite';
|
|
141
|
+
readonly parts: readonly SegmentPart[];
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* A part of a composite segment.
|
|
145
|
+
* @public
|
|
146
|
+
*/
|
|
147
|
+
export type SegmentPart = {
|
|
148
|
+
readonly type: 'literal';
|
|
149
|
+
readonly value: string;
|
|
150
|
+
} | {
|
|
151
|
+
readonly type: 'star';
|
|
152
|
+
} | {
|
|
153
|
+
readonly type: 'question';
|
|
154
|
+
} | {
|
|
155
|
+
readonly type: 'charclass';
|
|
156
|
+
readonly spec: CharClassSegment;
|
|
157
|
+
};
|
|
158
|
+
//# sourceMappingURL=ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/types/ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAM5C;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IAEvB,uBAAuB;IACvB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;IAE1B,+DAA+D;IAC/D,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;IAE5B,yDAAyD;IACzD,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;IAE5B,gCAAgC;IAChC,QAAQ,CAAC,MAAM,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;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;IAE1B,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IAEzB,wCAAwC;IACxC,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAA;IAErC,0CAA0C;IAC1C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,wCAAwC;IACxC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,sCAAsC;IACtC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CACrB;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;IAC1B,QAAQ,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,CAAA;CACvC;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACpD;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GAC7B;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../src/types/ast.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import type { PathPattern } from './ast';
|
|
2
|
+
/**
|
|
3
|
+
* A compiled pattern ready for efficient matching.
|
|
4
|
+
*
|
|
5
|
+
* Patterns are compiled to a form optimized for:
|
|
6
|
+
* 1. Fast rejection of non-matching paths
|
|
7
|
+
* 2. Minimal backtracking during matching
|
|
8
|
+
* 3. Support for containment analysis
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export interface CompiledPattern {
|
|
13
|
+
/** Original source pattern */
|
|
14
|
+
readonly source: string;
|
|
15
|
+
/** Parsed AST (for containment analysis) */
|
|
16
|
+
readonly ast: PathPattern;
|
|
17
|
+
/**
|
|
18
|
+
* Quick-reject filters applied before full matching.
|
|
19
|
+
* If any filter fails, the path definitely doesn't match.
|
|
20
|
+
*/
|
|
21
|
+
readonly quickReject: QuickRejectFilter;
|
|
22
|
+
/**
|
|
23
|
+
* Segment automaton for matching.
|
|
24
|
+
* Operates on path segments, not characters.
|
|
25
|
+
*/
|
|
26
|
+
readonly automaton: SegmentAutomaton;
|
|
27
|
+
/** Whether pattern can match paths of any depth (contains **) */
|
|
28
|
+
readonly isUnbounded: boolean;
|
|
29
|
+
/** Minimum number of segments this pattern requires */
|
|
30
|
+
readonly minSegments: number;
|
|
31
|
+
/** Maximum segments (undefined if unbounded) */
|
|
32
|
+
readonly maxSegments?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Quick rejection filters for fast path elimination.
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export interface QuickRejectFilter {
|
|
39
|
+
/** If pattern requires specific prefix, check it first */
|
|
40
|
+
readonly requiredPrefix?: string;
|
|
41
|
+
/** If pattern requires specific suffix, check it first */
|
|
42
|
+
readonly requiredSuffix?: string;
|
|
43
|
+
/** Minimum path length (characters) */
|
|
44
|
+
readonly minLength?: number;
|
|
45
|
+
/** Required literal segments that must appear somewhere */
|
|
46
|
+
readonly requiredLiterals?: readonly string[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A finite automaton that operates on path segments rather than characters.
|
|
50
|
+
*
|
|
51
|
+
* Key insight: treating segments as tokens rather than character-by-character
|
|
52
|
+
* matching dramatically simplifies the automaton and enables efficient
|
|
53
|
+
* containment checking.
|
|
54
|
+
*
|
|
55
|
+
* Alphabet:
|
|
56
|
+
* - Each literal segment is a symbol
|
|
57
|
+
* - "*" matches any single segment (wildcard transition)
|
|
58
|
+
* - "**" is an epsilon loop (zero or more segments)
|
|
59
|
+
*
|
|
60
|
+
* This representation supports:
|
|
61
|
+
* - O(n) matching where n is number of path segments
|
|
62
|
+
* - Standard automaton operations (union, intersection, complement)
|
|
63
|
+
* - Containment checking via (A ∩ B̄ = ∅)
|
|
64
|
+
*
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
export interface SegmentAutomaton {
|
|
68
|
+
/** All states in the automaton */
|
|
69
|
+
readonly states: readonly AutomatonState[];
|
|
70
|
+
/** Index of the initial state */
|
|
71
|
+
readonly initialState: number;
|
|
72
|
+
/** Indices of accepting (final) states */
|
|
73
|
+
readonly acceptingStates: readonly number[];
|
|
74
|
+
/** Whether this automaton is deterministic */
|
|
75
|
+
readonly isDeterministic: boolean;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A state in the segment automaton.
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
export interface AutomatonState {
|
|
82
|
+
/** Unique identifier for this state (index in the states array) */
|
|
83
|
+
readonly id: number;
|
|
84
|
+
/** Transitions from this state */
|
|
85
|
+
readonly transitions: readonly AutomatonTransition[];
|
|
86
|
+
/** Is this an accepting state? */
|
|
87
|
+
readonly accepting: boolean;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* A transition in the segment automaton.
|
|
91
|
+
* @public
|
|
92
|
+
*/
|
|
93
|
+
export type AutomatonTransition = LiteralTransition | WildcardTransition | GlobstarTransition | EpsilonTransition;
|
|
94
|
+
/**
|
|
95
|
+
* Transition on an exact segment match.
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
export interface LiteralTransition {
|
|
99
|
+
readonly type: 'literal';
|
|
100
|
+
readonly segment: string;
|
|
101
|
+
/** Target state ID */
|
|
102
|
+
readonly target: number;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* A pattern matcher that can test if a segment matches.
|
|
106
|
+
* This can be either a native RegExp or a composite pattern.
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
109
|
+
export interface SegmentMatcher {
|
|
110
|
+
/** Test if a string matches the pattern */
|
|
111
|
+
test(str: string): boolean;
|
|
112
|
+
/** The pattern source for debugging/serialization */
|
|
113
|
+
readonly source: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Transition matching any single segment (from * or ?).
|
|
117
|
+
* May have constraints from character classes or wildcards.
|
|
118
|
+
* @public
|
|
119
|
+
*/
|
|
120
|
+
export interface WildcardTransition {
|
|
121
|
+
readonly type: 'wildcard';
|
|
122
|
+
/** Pattern for segment matching (from *.ts, test-*, etc.) */
|
|
123
|
+
readonly pattern: RegExp | SegmentMatcher;
|
|
124
|
+
/** Original pattern string for serialization/debugging */
|
|
125
|
+
readonly patternSource: string;
|
|
126
|
+
readonly target: number;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Globstar transition for ** (matches zero or more segments).
|
|
130
|
+
*
|
|
131
|
+
* Modeled as: epsilon to exit OR consume one segment and stay.
|
|
132
|
+
* @public
|
|
133
|
+
*/
|
|
134
|
+
export interface GlobstarTransition {
|
|
135
|
+
readonly type: 'globstar';
|
|
136
|
+
/** Self-loop state (stays in same state consuming segments) */
|
|
137
|
+
readonly selfLoop: number;
|
|
138
|
+
/** Exit state (moves forward without consuming) */
|
|
139
|
+
readonly exit: number;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Epsilon transition (no input consumed).
|
|
143
|
+
* Used for NFA construction and alternation.
|
|
144
|
+
* @public
|
|
145
|
+
*/
|
|
146
|
+
export interface EpsilonTransition {
|
|
147
|
+
readonly type: 'epsilon';
|
|
148
|
+
readonly target: number;
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=automaton.d.ts.map
|
|
@@ -0,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AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"automaton.js","sourceRoot":"","sources":["../../src/types/automaton.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Describes the relationship between two pattern sets.
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export type PatternRelationship = 'subset' | 'equal' | 'superset' | 'overlapping' | 'disjoint';
|
|
6
|
+
/**
|
|
7
|
+
* Categories of reasons why containment may fail.
|
|
8
|
+
* Used to provide structured explanation data.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export type ContainmentFailureReason = 'depth_mismatch' | 'prefix_mismatch' | 'suffix_mismatch' | 'segment_mismatch' | 'charclass_mismatch' | 'negation_conflict' | 'alternation_escape';
|
|
12
|
+
/**
|
|
13
|
+
* A witness path that demonstrates a containment property.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export interface WitnessPath {
|
|
17
|
+
/** The actual path string */
|
|
18
|
+
readonly path: string;
|
|
19
|
+
/** Which pattern(s) this path matches */
|
|
20
|
+
readonly matchesA: boolean;
|
|
21
|
+
readonly matchesB: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* For counterexamples, the segment index where patterns diverge.
|
|
24
|
+
* Useful for highlighting the specific point of difference.
|
|
25
|
+
*/
|
|
26
|
+
readonly divergenceIndex?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Human-oriented classification of this witness.
|
|
29
|
+
*/
|
|
30
|
+
readonly category: WitnessCategory;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Classification of witness paths for explanation generation.
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export type WitnessCategory = 'counterexample' | 'reverse_counterexample' | 'shared' | 'neither';
|
|
37
|
+
/**
|
|
38
|
+
* Structured explanation of why two patterns have a particular relationship.
|
|
39
|
+
* Provides sufficient data for downstream systems to generate human-readable explanations.
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export interface ContainmentExplanation {
|
|
43
|
+
/**
|
|
44
|
+
* High-level categorization of why containment fails (if it does).
|
|
45
|
+
* Empty array if A ⊆ B.
|
|
46
|
+
*/
|
|
47
|
+
readonly failureReasons: readonly ContainmentFailureReason[];
|
|
48
|
+
/**
|
|
49
|
+
* Segment-by-segment comparison showing where patterns differ.
|
|
50
|
+
* Each entry describes one position in the path.
|
|
51
|
+
*/
|
|
52
|
+
readonly segmentComparison: readonly SegmentComparisonEntry[];
|
|
53
|
+
/**
|
|
54
|
+
* Structural differences between the patterns.
|
|
55
|
+
*/
|
|
56
|
+
readonly structuralDiffs: StructuralDifferences;
|
|
57
|
+
/**
|
|
58
|
+
* Witness paths that demonstrate the relationship.
|
|
59
|
+
* Includes counterexamples, shared paths, and illustrative examples.
|
|
60
|
+
*/
|
|
61
|
+
readonly witnesses: readonly WitnessPath[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Comparison of what patterns allow at a specific segment position.
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
export interface SegmentComparisonEntry {
|
|
68
|
+
/** Segment position (0-indexed from path root) */
|
|
69
|
+
readonly position: number;
|
|
70
|
+
/** What pattern A allows at this position */
|
|
71
|
+
readonly patternAAllows: SegmentConstraint;
|
|
72
|
+
/** What pattern B allows at this position */
|
|
73
|
+
readonly patternBAllows: SegmentConstraint;
|
|
74
|
+
/** Whether A's constraint is a subset of B's at this position */
|
|
75
|
+
readonly aSubsetOfB: boolean;
|
|
76
|
+
/** Brief description of the difference (if any) */
|
|
77
|
+
readonly difference?: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Describes what a pattern allows at a segment position.
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
export interface SegmentConstraint {
|
|
84
|
+
/** The type of constraint */
|
|
85
|
+
readonly type: SegmentConstraintType;
|
|
86
|
+
/** For literal: the exact value required */
|
|
87
|
+
readonly literalValue?: string;
|
|
88
|
+
/** For wildcard: the pattern (e.g., "*.ts") */
|
|
89
|
+
readonly wildcardPattern?: string;
|
|
90
|
+
/** For charclass: description of allowed characters */
|
|
91
|
+
readonly charclassDescription?: string;
|
|
92
|
+
/** Whether this position can be skipped (due to ** before it) */
|
|
93
|
+
readonly optional: boolean;
|
|
94
|
+
/** Whether this position can repeat (is within a ** range) */
|
|
95
|
+
readonly repeatable: boolean;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Types of segment constraints.
|
|
99
|
+
* @public
|
|
100
|
+
*/
|
|
101
|
+
export type SegmentConstraintType = 'literal' | 'wildcard' | 'charclass' | 'any' | 'any_sequence' | 'end' | 'unreachable';
|
|
102
|
+
/**
|
|
103
|
+
* High-level structural differences between patterns.
|
|
104
|
+
* @public
|
|
105
|
+
*/
|
|
106
|
+
export interface StructuralDifferences {
|
|
107
|
+
/** Whether patterns have different depth bounds */
|
|
108
|
+
readonly depthDifference: DepthComparison;
|
|
109
|
+
/** Whether patterns require different prefixes */
|
|
110
|
+
readonly prefixDifference: PrefixComparison;
|
|
111
|
+
/** Whether patterns require different suffixes */
|
|
112
|
+
readonly suffixDifference: SuffixComparison;
|
|
113
|
+
/** Whether one pattern is anchored and the other isn't */
|
|
114
|
+
readonly anchoringDifference: AnchoringComparison;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Comparison of pattern depth constraints.
|
|
118
|
+
* @public
|
|
119
|
+
*/
|
|
120
|
+
export interface DepthComparison {
|
|
121
|
+
/** Whether the depth constraints differ between patterns */
|
|
122
|
+
readonly differ: boolean;
|
|
123
|
+
/** Minimum segment depth for pattern A */
|
|
124
|
+
readonly patternAMin: number;
|
|
125
|
+
/** Maximum segment depth for pattern A (or 'unbounded' for **) */
|
|
126
|
+
readonly patternAMax: number | 'unbounded';
|
|
127
|
+
/** Minimum segment depth for pattern B */
|
|
128
|
+
readonly patternBMin: number;
|
|
129
|
+
/** Maximum segment depth for pattern B (or 'unbounded' for **) */
|
|
130
|
+
readonly patternBMax: number | 'unbounded';
|
|
131
|
+
/** Human-readable explanation of the difference */
|
|
132
|
+
readonly explanation?: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Comparison of required path prefixes.
|
|
136
|
+
* @public
|
|
137
|
+
*/
|
|
138
|
+
export interface PrefixComparison {
|
|
139
|
+
/** Whether the required prefixes differ between patterns */
|
|
140
|
+
readonly differ: boolean;
|
|
141
|
+
/** Required prefix for pattern A (if any) */
|
|
142
|
+
readonly patternAPrefix?: string;
|
|
143
|
+
/** Required prefix for pattern B (if any) */
|
|
144
|
+
readonly patternBPrefix?: string;
|
|
145
|
+
/** Human-readable explanation of the difference */
|
|
146
|
+
readonly explanation?: string;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Comparison of required path suffixes (e.g., file extensions).
|
|
150
|
+
* @public
|
|
151
|
+
*/
|
|
152
|
+
export interface SuffixComparison {
|
|
153
|
+
/** Whether the required suffixes differ between patterns */
|
|
154
|
+
readonly differ: boolean;
|
|
155
|
+
/** Required suffix for pattern A (e.g., ".ts") */
|
|
156
|
+
readonly patternASuffix?: string;
|
|
157
|
+
/** Required suffix for pattern B (e.g., ".js") */
|
|
158
|
+
readonly patternBSuffix?: string;
|
|
159
|
+
/** Human-readable explanation of the difference */
|
|
160
|
+
readonly explanation?: string;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Comparison of pattern anchoring (absolute vs relative).
|
|
164
|
+
* @public
|
|
165
|
+
*/
|
|
166
|
+
export interface AnchoringComparison {
|
|
167
|
+
/** Whether the anchoring differs between patterns */
|
|
168
|
+
readonly differ: boolean;
|
|
169
|
+
/** Whether pattern A is absolute (starts with / or ~) */
|
|
170
|
+
readonly patternAAbsolute: boolean;
|
|
171
|
+
/** Whether pattern B is absolute (starts with / or ~) */
|
|
172
|
+
readonly patternBAbsolute: boolean;
|
|
173
|
+
/** Human-readable explanation of the difference */
|
|
174
|
+
readonly explanation?: string;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Result of checking whether pattern A is contained within pattern B.
|
|
178
|
+
*
|
|
179
|
+
* A ⊆ B means: every path that matches A also matches B.
|
|
180
|
+
*
|
|
181
|
+
* This type provides rich structured data to enable downstream systems
|
|
182
|
+
* to generate human-readable explanations of containment results.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* - "src/*.ts" ⊆ "src/**" (true)
|
|
186
|
+
* - "src/**" ⊆ "src/*.ts" (false)
|
|
187
|
+
* - "*.ts" ⊆ "*" (true)
|
|
188
|
+
* - "\{src,lib\}/*.ts" ⊆ "**\/*.ts" (true)
|
|
189
|
+
*
|
|
190
|
+
* @public
|
|
191
|
+
*/
|
|
192
|
+
export interface ContainmentResult {
|
|
193
|
+
/** The first pattern being compared */
|
|
194
|
+
readonly patternA: string;
|
|
195
|
+
/** The second pattern being compared */
|
|
196
|
+
readonly patternB: string;
|
|
197
|
+
/** Is A a subset of B? (A ⊆ B) */
|
|
198
|
+
readonly isSubset: boolean;
|
|
199
|
+
/** Is B a subset of A? (B ⊆ A) */
|
|
200
|
+
readonly isSuperset: boolean;
|
|
201
|
+
/** Is A equal to B (mutual containment)? */
|
|
202
|
+
readonly isEqual: boolean;
|
|
203
|
+
/** Do the patterns have any overlap? (A ∩ B ≠ ∅) */
|
|
204
|
+
readonly hasOverlap: boolean;
|
|
205
|
+
/** Relationship classification */
|
|
206
|
+
readonly relationship: PatternRelationship;
|
|
207
|
+
/**
|
|
208
|
+
* Primary counterexample: a path that matches A but not B.
|
|
209
|
+
* Present when isSubset is false.
|
|
210
|
+
*/
|
|
211
|
+
readonly counterexample?: string;
|
|
212
|
+
/**
|
|
213
|
+
* Reverse counterexample: a path that matches B but not A.
|
|
214
|
+
* Present when isSuperset is false.
|
|
215
|
+
*/
|
|
216
|
+
readonly reverseCounterexample?: string;
|
|
217
|
+
/**
|
|
218
|
+
* Structured explanation data for generating human-readable descriptions.
|
|
219
|
+
*/
|
|
220
|
+
readonly explanation: ContainmentExplanation;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* A human-readable description of a set of paths.
|
|
224
|
+
* @public
|
|
225
|
+
*/
|
|
226
|
+
export interface PatternDescription {
|
|
227
|
+
/** Is this set empty? */
|
|
228
|
+
readonly isEmpty: boolean;
|
|
229
|
+
/** Example paths from this set (if non-empty) */
|
|
230
|
+
readonly examples?: readonly string[];
|
|
231
|
+
/** Pattern representation (if expressible as a single pattern) */
|
|
232
|
+
readonly pattern?: string;
|
|
233
|
+
/** Natural language description */
|
|
234
|
+
readonly description: string;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Detailed analysis of two patterns' relationship.
|
|
238
|
+
*
|
|
239
|
+
* Provides comprehensive data for understanding how two patterns relate,
|
|
240
|
+
* including the intersection and set differences.
|
|
241
|
+
*
|
|
242
|
+
* @public
|
|
243
|
+
*/
|
|
244
|
+
export interface PatternAnalysis {
|
|
245
|
+
readonly patternA: string;
|
|
246
|
+
readonly patternB: string;
|
|
247
|
+
readonly relationship: PatternRelationship;
|
|
248
|
+
/** Full containment result with explanation */
|
|
249
|
+
readonly containment: ContainmentResult;
|
|
250
|
+
/** Description of paths matching both patterns */
|
|
251
|
+
readonly intersection: PatternDescription;
|
|
252
|
+
/** Description of paths matching A but not B */
|
|
253
|
+
readonly aMinusB: PatternDescription;
|
|
254
|
+
/** Description of paths matching B but not A */
|
|
255
|
+
readonly bMinusA: PatternDescription;
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=containment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containment.d.ts","sourceRoot":"","sources":["../../src/types/containment.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,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
|
+
{"version":3,"file":"containment.js","sourceRoot":"","sources":["../../src/types/containment.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,uBAAuB;AACvB,gFAAgF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error codes for pattern validation failures.
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export type PatternErrorCode = 'INVALID_GLOBSTAR' | 'UNCLOSED_BRACKET' | 'UNCLOSED_BRACE' | 'EMPTY_CHARCLASS' | 'INVALID_RANGE' | 'EXPANSION_LIMIT' | 'NESTED_BRACES' | 'INVALID_ESCAPE' | 'BANNED_FEATURE' | 'INVALID_REGEX' | 'UNSAFE_REGEX' | 'DFA_STATE_LIMIT';
|
|
6
|
+
/**
|
|
7
|
+
* A pattern validation error with location information.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export interface PatternError {
|
|
11
|
+
/** Error classification code */
|
|
12
|
+
readonly code: PatternErrorCode;
|
|
13
|
+
/** Human-readable error description */
|
|
14
|
+
readonly message: string;
|
|
15
|
+
/** Character position in source where error starts */
|
|
16
|
+
readonly position?: number;
|
|
17
|
+
/** Length of the problematic section */
|
|
18
|
+
readonly length?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Error thrown when automaton operations exceed configured limits.
|
|
22
|
+
*
|
|
23
|
+
* This typically occurs during DFA construction when a pattern
|
|
24
|
+
* would result in exponential state explosion.
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export declare class AutomatonLimitError extends Error {
|
|
29
|
+
/** Error classification code */
|
|
30
|
+
readonly code: PatternErrorCode;
|
|
31
|
+
/** The limit that was exceeded */
|
|
32
|
+
readonly limit: number;
|
|
33
|
+
/** The actual value that exceeded the limit */
|
|
34
|
+
readonly actual: number;
|
|
35
|
+
constructor(code: PatternErrorCode, message: string, limit: number, actual: number);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GACxB,kBAAkB,GAClB,kBAAkB,GAClB,gBAAgB,GAChB,iBAAiB,GACjB,eAAe,GACf,iBAAiB,GACjB,eAAe,GACf,gBAAgB,GAChB,gBAAgB,GAChB,eAAe,GACf,cAAc,GACd,iBAAiB,CAAA;AAErB;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,gCAAgC;IAChC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAA;IAE/B,uCAAuC;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAExB,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAE1B,wCAAwC;IACxC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;;;;;;GAOG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,gCAAgC;IAChC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAA;IAE/B,kCAAkC;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IAEtB,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;gBAEX,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAOnF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when automaton operations exceed configured limits.
|
|
3
|
+
*
|
|
4
|
+
* This typically occurs during DFA construction when a pattern
|
|
5
|
+
* would result in exponential state explosion.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export class AutomatonLimitError extends Error {
|
|
10
|
+
/** Error classification code */
|
|
11
|
+
code;
|
|
12
|
+
/** The limit that was exceeded */
|
|
13
|
+
limit;
|
|
14
|
+
/** The actual value that exceeded the limit */
|
|
15
|
+
actual;
|
|
16
|
+
constructor(code, message, limit, actual) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.name = 'AutomatonLimitError';
|
|
19
|
+
this.code = code;
|
|
20
|
+
this.limit = limit;
|
|
21
|
+
this.actual = actual;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=errors.js.map
|