extra-parser 0.6.0 → 0.6.1
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 +38 -26
- package/lib/index.d.ts +2 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/match-repetitions.d.ts +7 -0
- package/lib/match-repetitions.js +36 -0
- package/lib/match-repetitions.js.map +1 -0
- package/lib/match-sequence.d.ts +1 -11
- package/lib/match-sequence.js.map +1 -1
- package/lib/types.d.ts +10 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,6 +47,32 @@ interface ITokenPattern<Token extends IToken = IToken> {
|
|
|
47
47
|
interface INodePattern<Token extends IToken = IToken, Node extends INode = INode> {
|
|
48
48
|
(tokens: ReadonlyArray<Token>): Awaitable<INodePatternMatch<Node> | Falsy>
|
|
49
49
|
}
|
|
50
|
+
|
|
51
|
+
type MapSequenceToPatterns<Sequence extends ReadonlyArray<IToken | INode>> = {
|
|
52
|
+
[Index in keyof Sequence]:
|
|
53
|
+
[Sequence[Index]] extends [infer Element]
|
|
54
|
+
? (
|
|
55
|
+
Element extends IToken
|
|
56
|
+
? string
|
|
57
|
+
: Element extends INode
|
|
58
|
+
? INodePattern<IToken, Element>
|
|
59
|
+
: never
|
|
60
|
+
)
|
|
61
|
+
: never
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
type MapSequenceToMatches<Sequence extends ReadonlyArray<IToken | INode>> = {
|
|
65
|
+
[Index in keyof Sequence]:
|
|
66
|
+
[Sequence[Index]] extends [infer Element]
|
|
67
|
+
? (
|
|
68
|
+
Element extends IToken
|
|
69
|
+
? IToken
|
|
70
|
+
: Element extends INode
|
|
71
|
+
? INodePatternMatch<Element>
|
|
72
|
+
: never
|
|
73
|
+
)
|
|
74
|
+
: never
|
|
75
|
+
}
|
|
50
76
|
```
|
|
51
77
|
|
|
52
78
|
### tokenize
|
|
@@ -97,38 +123,24 @@ function matchAnyOf<
|
|
|
97
123
|
|
|
98
124
|
#### matchSequence
|
|
99
125
|
```ts
|
|
100
|
-
type MapSequenceToPatterns<Sequence extends ReadonlyArray<IToken | INode>> = {
|
|
101
|
-
[Index in keyof Sequence]:
|
|
102
|
-
[Sequence[Index]] extends [infer Element]
|
|
103
|
-
? (
|
|
104
|
-
Element extends IToken
|
|
105
|
-
? string
|
|
106
|
-
: Element extends INode
|
|
107
|
-
? INodePattern<IToken, Element>
|
|
108
|
-
: never
|
|
109
|
-
)
|
|
110
|
-
: never
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
type MapSequenceToMatches<Sequence extends ReadonlyArray<IToken | INode>> = {
|
|
114
|
-
[Index in keyof Sequence]:
|
|
115
|
-
[Sequence[Index]] extends [infer Element]
|
|
116
|
-
? (
|
|
117
|
-
Element extends IToken
|
|
118
|
-
? IToken
|
|
119
|
-
: Element extends INode
|
|
120
|
-
? INodePatternMatch<Element>
|
|
121
|
-
: never
|
|
122
|
-
)
|
|
123
|
-
: never
|
|
124
|
-
}
|
|
125
|
-
|
|
126
126
|
function matchSequence<Sequence extends ReadonlyArray<IToken | INode>>(
|
|
127
127
|
patterns: MapSequenceToPatterns<Sequence>
|
|
128
128
|
, tokens: ReadonlyArray<IToken>
|
|
129
129
|
): Promise<MapSequenceToMatches<Sequence> | Falsy>
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
+
#### matchRepetitions
|
|
133
|
+
```ts
|
|
134
|
+
function matchRepetitions<Sequence extends ReadonlyArray<IToken | INode>>(
|
|
135
|
+
patterns: MapSequenceToPatterns<Sequence>
|
|
136
|
+
, tokens: ReadonlyArray<IToken>
|
|
137
|
+
, options?: {
|
|
138
|
+
minimumRepetitions?: number = 1
|
|
139
|
+
maximumRepetitions?: number = Infinity
|
|
140
|
+
}
|
|
141
|
+
): Promise<Flatten<Array<MapSequenceToMatches<Sequence>>> | Falsy>
|
|
142
|
+
```
|
|
143
|
+
|
|
132
144
|
### createTokenPatternFromRegExp
|
|
133
145
|
```ts
|
|
134
146
|
function createTokenPatternFromRegExp<Token extends IToken>(
|
package/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { IToken, ITokenPattern, ITokenPatternMatch, INode, INodePattern, INodePatternMatch } from './types';
|
|
2
2
|
export * from './tokenize';
|
|
3
3
|
export * from './parse';
|
|
4
4
|
export * from './consume-token';
|
|
5
5
|
export * from './consume-node';
|
|
6
6
|
export { matchSequence } from './match-sequence';
|
|
7
|
+
export * from './match-repetitions';
|
|
7
8
|
export * from './match-any-of';
|
|
8
9
|
export * from './create-token-pattern-from-regexp';
|
|
9
10
|
export * from './create-unary-operator-expression-node-pattern';
|
package/lib/index.js
CHANGED
|
@@ -15,13 +15,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.matchSequence = void 0;
|
|
18
|
-
__exportStar(require("./types"), exports);
|
|
19
18
|
__exportStar(require("./tokenize"), exports);
|
|
20
19
|
__exportStar(require("./parse"), exports);
|
|
21
20
|
__exportStar(require("./consume-token"), exports);
|
|
22
21
|
__exportStar(require("./consume-node"), exports);
|
|
23
22
|
var match_sequence_1 = require("./match-sequence");
|
|
24
23
|
Object.defineProperty(exports, "matchSequence", { enumerable: true, get: function () { return match_sequence_1.matchSequence; } });
|
|
24
|
+
__exportStar(require("./match-repetitions"), exports);
|
|
25
25
|
__exportStar(require("./match-any-of"), exports);
|
|
26
26
|
__exportStar(require("./create-token-pattern-from-regexp"), exports);
|
|
27
27
|
__exportStar(require("./create-unary-operator-expression-node-pattern"), exports);
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAQA,6CAA0B;AAC1B,0CAAuB;AACvB,kDAA+B;AAC/B,iDAA8B;AAC9B,mDAAgD;AAAvC,+GAAA,aAAa,OAAA;AACtB,sDAAmC;AACnC,iDAA8B;AAC9B,qEAAkD;AAClD,kFAA+D;AAC/D,mFAAgE;AAChE,2EAAwD;AACxD,yEAAsD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Falsy } from '@blackglory/prelude';
|
|
2
|
+
import { Flatten } from 'hotypes';
|
|
3
|
+
import { IToken, INode, MapSequenceToPatterns, MapSequenceToMatches } from './types';
|
|
4
|
+
export declare function matchRepetitions<Sequence extends ReadonlyArray<IToken | INode>>(patterns: MapSequenceToPatterns<Sequence>, tokens: ReadonlyArray<IToken>, { minimumRepetitions, maximumRepetitions }?: {
|
|
5
|
+
minimumRepetitions?: number;
|
|
6
|
+
maximumRepetitions?: number;
|
|
7
|
+
}): Promise<Flatten<Array<MapSequenceToMatches<Sequence>>> | Falsy>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.matchRepetitions = void 0;
|
|
4
|
+
const prelude_1 = require("@blackglory/prelude");
|
|
5
|
+
const match_sequence_1 = require("./match-sequence");
|
|
6
|
+
async function matchRepetitions(patterns, tokens, { minimumRepetitions = 1, maximumRepetitions = Infinity } = {}) {
|
|
7
|
+
(0, prelude_1.assert)(Number.isInteger(minimumRepetitions), 'The minimum repetiions must be an integer');
|
|
8
|
+
(0, prelude_1.assert)(minimumRepetitions >= 0, 'The minimum repetitions must be greater than or equal to 0');
|
|
9
|
+
(0, prelude_1.assert)(Number.isInteger(maximumRepetitions) || maximumRepetitions === Infinity, 'The maxmium repetiions must be an integer or an Infinity');
|
|
10
|
+
(0, prelude_1.assert)(maximumRepetitions >= minimumRepetitions, 'The maximum repetitions must be greater than or equal to the minimum repetitions');
|
|
11
|
+
const results = [];
|
|
12
|
+
const mutableTokens = (0, prelude_1.toArray)(tokens);
|
|
13
|
+
for (let i = 0; i < minimumRepetitions; i++) {
|
|
14
|
+
const matches = await (0, match_sequence_1.matchSequence)(patterns, mutableTokens);
|
|
15
|
+
if ((0, prelude_1.isntFalsy)(matches)) {
|
|
16
|
+
results.push(matches);
|
|
17
|
+
mutableTokens.splice(0, matches.length);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
for (let i = minimumRepetitions; i < maximumRepetitions; i++) {
|
|
24
|
+
const matches = await (0, match_sequence_1.matchSequence)(patterns, mutableTokens);
|
|
25
|
+
if ((0, prelude_1.isntFalsy)(matches)) {
|
|
26
|
+
results.push(matches);
|
|
27
|
+
mutableTokens.splice(0, matches.length);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return results.flat();
|
|
34
|
+
}
|
|
35
|
+
exports.matchRepetitions = matchRepetitions;
|
|
36
|
+
//# sourceMappingURL=match-repetitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-repetitions.js","sourceRoot":"","sources":["../src/match-repetitions.ts"],"names":[],"mappings":";;;AAAA,iDAAuE;AAGvE,qDAAgD;AAEzC,KAAK,UAAU,gBAAgB,CACpC,QAAyC,EACzC,MAA6B,EAC7B,EACE,kBAAkB,GAAG,CAAC,EACtB,kBAAkB,GAAG,QAAQ,KAI3B,EAAE;IAEN,IAAA,gBAAM,EAAC,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC,EAAE,2CAA2C,CAAC,CAAA;IACzF,IAAA,gBAAM,EACJ,kBAAkB,IAAI,CAAC,EACvB,4DAA4D,CAC7D,CAAA;IACD,IAAA,gBAAM,EACJ,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,kBAAkB,KAAK,QAAQ,EACvE,0DAA0D,CAC3D,CAAA;IACD,IAAA,gBAAM,EACJ,kBAAkB,IAAI,kBAAkB,EACxC,kFAAkF,CACnF,CAAA;IAED,MAAM,OAAO,GAA0C,EAAE,CAAA;IACzD,MAAM,aAAa,GAAG,IAAA,iBAAO,EAAC,MAAM,CAAC,CAAA;IAErC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,kBAAkB,EAAE,CAAC,EAAE,EAAE;QAC3C,MAAM,OAAO,GAAG,MAAM,IAAA,8BAAa,EAAC,QAAQ,EAAE,aAAa,CAAC,CAAA;QAC5D,IAAI,IAAA,mBAAS,EAAC,OAAO,CAAC,EAAE;YACtB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YACrB,aAAa,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;SACxC;aAAM;YACL,OAAM;SACP;KACF;IAED,KAAK,IAAI,CAAC,GAAG,kBAAkB,EAAE,CAAC,GAAG,kBAAkB,EAAE,CAAC,EAAE,EAAE;QAC5D,MAAM,OAAO,GAAG,MAAM,IAAA,8BAAa,EAAC,QAAQ,EAAE,aAAa,CAAC,CAAA;QAC5D,IAAI,IAAA,mBAAS,EAAC,OAAO,CAAC,EAAE;YACtB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YACrB,aAAa,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;SACxC;aAAM;YACL,MAAK;SACN;KACF;IAED,OAAO,OAAO,CAAC,IAAI,EAAoD,CAAA;AACzE,CAAC;AAjDD,4CAiDC"}
|
package/lib/match-sequence.d.ts
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import { NonEmptyArray, Falsy } from '@blackglory/prelude';
|
|
2
|
-
import { IToken, INode, INodePattern,
|
|
3
|
-
declare type MapSequenceToPatterns<Sequence extends ReadonlyArray<IToken | INode>> = {
|
|
4
|
-
[Index in keyof Sequence]: [
|
|
5
|
-
Sequence[Index]
|
|
6
|
-
] extends [infer Element] ? (Element extends IToken ? string : Element extends INode ? INodePattern<IToken, Element> : never) : never;
|
|
7
|
-
};
|
|
8
|
-
declare type MapSequenceToMatches<Sequence extends ReadonlyArray<IToken | INode>> = {
|
|
9
|
-
[Index in keyof Sequence]: [
|
|
10
|
-
Sequence[Index]
|
|
11
|
-
] extends [infer Element] ? (Element extends IToken ? IToken : Element extends INode ? INodePatternMatch<Element> : never) : never;
|
|
12
|
-
};
|
|
2
|
+
import { IToken, INode, INodePattern, MapSequenceToPatterns, MapSequenceToMatches } from './types';
|
|
13
3
|
export declare function matchSequence<Sequence extends ReadonlyArray<IToken | INode>>(patterns: MapSequenceToPatterns<Sequence>, tokens: ReadonlyArray<IToken>): Promise<MapSequenceToMatches<Sequence> | Falsy>;
|
|
14
4
|
declare type SubPatterns = [INodePattern<IToken, INode>, string] | NonEmptyArray<string> | NonEmptyArray<INodePattern<IToken, INode>>;
|
|
15
5
|
export declare function splitPatterns<Sequence extends ReadonlyArray<IToken | INode>>(patterns: MapSequenceToPatterns<Sequence>): IterableIterator<SubPatterns>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"match-sequence.js","sourceRoot":"","sources":["../src/match-sequence.ts"],"names":[],"mappings":";;;AAAA,iDAO4B;AAC5B,yDAAkD;
|
|
1
|
+
{"version":3,"file":"match-sequence.js","sourceRoot":"","sources":["../src/match-sequence.ts"],"names":[],"mappings":";;;AAAA,iDAO4B;AAC5B,yDAAkD;AASlD,mDAA8C;AAC9C,iDAA4C;AAWrC,KAAK,UAAU,aAAa,CACjC,QAAyC,EACzC,MAA6B;IAE7B,IAAI,YAAY,CAAC,QAAQ,CAAC,EAAE;QAC1B,MAAM,OAAO,GAAkB,EAAE,CAAA;QAEjC,MAAM,aAAa,GAAG,IAAA,iBAAO,EAAC,MAAM,CAAC,CAAA;QACrC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;YAC9B,MAAM,KAAK,GAAG,I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MAAM,eAAe,CAAC,MAAM,CAAC,CAAC,EAAE,kBAAkB,CAA0B,CAAA;aAC7E;SACF;aAAM,IAAI,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE;YAC5C,MAAM,YAAY,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;YACnE,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE;gBACvB,MAAM,eAAe,CAAC,MAAM,CAAC,CAAC,CAE7B,CAAA;aACF;iBAAM;gBACL,MAAM,eAAe,CAAC,MAAM,CAAC,CAAC,EAAE,YAAY,GAAG,CAAC,CAG/C,CAAA;aACF;SACF;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;SACpC;KACF;AACH,CAAC;AA7BD,sCA6BC;AAED,SAAS,YAAY,CAAC,GAA2B;IAC/C,OAAO,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;AAC/B,CAAC;AAED,SAAS,WAAW,CAAC,GAAY;IAC/B,OAAO,IAAA,kBAAQ,EAAC,GAAG,CAAC,CAAA;AACtB,CAAC;AAED,SAAS,cAAc,CACrB,GAA2B;IAE3B,OAAO,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;AACjC,CAAC;AAED,SAAS,aAAa,CACpB,GAAY;IAEZ,OAAO,IAAA,oBAAU,EAAC,GAAG,CAAC,CAAA;AACxB,CAAC;AAED,SAAS,qBAAqB,CAC5B,GAA2B;IAE3B,OAAO,GAAG,CAAC,MAAM,KAAK,CAAC;WAChB,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;WACrB,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;AAC5B,CAAC"}
|
package/lib/types.d.ts
CHANGED
|
@@ -20,3 +20,13 @@ export interface ITokenPattern<Token extends IToken = IToken> {
|
|
|
20
20
|
export interface INodePattern<Token extends IToken = IToken, Node extends INode = INode> {
|
|
21
21
|
(tokens: ReadonlyArray<Token>): Awaitable<INodePatternMatch<Node> | Falsy>;
|
|
22
22
|
}
|
|
23
|
+
export declare type MapSequenceToPatterns<Sequence extends ReadonlyArray<IToken | INode>> = {
|
|
24
|
+
[Index in keyof Sequence]: [
|
|
25
|
+
Sequence[Index]
|
|
26
|
+
] extends [infer Element] ? (Element extends IToken ? string : Element extends INode ? INodePattern<IToken, Element> : never) : never;
|
|
27
|
+
};
|
|
28
|
+
export declare type MapSequenceToMatches<Sequence extends ReadonlyArray<IToken | INode>> = {
|
|
29
|
+
[Index in keyof Sequence]: [
|
|
30
|
+
Sequence[Index]
|
|
31
|
+
] extends [infer Element] ? (Element extends IToken ? IToken : Element extends INode ? INodePatternMatch<Element> : never) : never;
|
|
32
|
+
};
|