@renovatebot/good-enough-parser 1.1.24 → 1.2.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 +6 -6
- package/dist/cjs/index.d.ts +4 -4
- package/dist/cjs/index.js +7 -7
- package/dist/cjs/lang/groovy.d.ts +6 -6
- package/dist/cjs/lang/groovy.js +83 -83
- package/dist/cjs/lang/index.d.ts +20 -20
- package/dist/cjs/lang/index.js +56 -56
- package/dist/cjs/lang/python.d.ts +6 -6
- package/dist/cjs/lang/python.js +73 -73
- package/dist/cjs/lang/scala.d.ts +6 -6
- package/dist/cjs/lang/scala.js +71 -71
- package/dist/cjs/lang/starlark.d.ts +6 -6
- package/dist/cjs/lang/starlark.js +58 -58
- package/dist/cjs/lang/types.d.ts +6 -6
- package/dist/cjs/lang/types.js +2 -2
- package/dist/cjs/lexer/bracket.d.ts +6 -6
- package/dist/cjs/lexer/bracket.js +57 -57
- package/dist/cjs/lexer/comment.d.ts +3 -3
- package/dist/cjs/lexer/comment.js +44 -44
- package/dist/cjs/lexer/index.d.ts +5 -5
- package/dist/cjs/lexer/index.js +155 -155
- package/dist/cjs/lexer/number.d.ts +2 -2
- package/dist/cjs/lexer/number.js +18 -18
- package/dist/cjs/lexer/operator.d.ts +2 -2
- package/dist/cjs/lexer/operator.js +24 -24
- package/dist/cjs/lexer/rules.d.ts +4 -4
- package/dist/cjs/lexer/rules.js +74 -74
- package/dist/cjs/lexer/string.d.ts +2 -2
- package/dist/cjs/lexer/string.js +181 -181
- package/dist/cjs/lexer/symbol.d.ts +2 -2
- package/dist/cjs/lexer/symbol.js +18 -18
- package/dist/cjs/lexer/token.d.ts +3 -3
- package/dist/cjs/lexer/token.js +64 -64
- package/dist/cjs/lexer/types.d.ts +142 -142
- package/dist/cjs/lexer/types.js +2 -2
- package/dist/cjs/parser/cursor.d.ts +2 -2
- package/dist/cjs/parser/cursor.js +13 -13
- package/dist/cjs/parser/index.d.ts +3 -3
- package/dist/cjs/parser/index.js +19 -19
- package/dist/cjs/parser/tree.d.ts +4 -4
- package/dist/cjs/parser/tree.js +246 -246
- package/dist/cjs/parser/types.d.ts +33 -33
- package/dist/cjs/parser/types.js +2 -2
- package/dist/cjs/query/builder.d.ts +144 -144
- package/dist/cjs/query/builder.js +332 -332
- package/dist/cjs/query/handler.d.ts +2 -2
- package/dist/cjs/query/handler.js +10 -10
- package/dist/cjs/query/index.d.ts +2 -2
- package/dist/cjs/query/index.js +32 -32
- package/dist/cjs/query/matchers/abstract-matcher.d.ts +9 -9
- package/dist/cjs/query/matchers/abstract-matcher.js +36 -36
- package/dist/cjs/query/matchers/alt-matcher.d.ts +10 -10
- package/dist/cjs/query/matchers/alt-matcher.js +33 -33
- package/dist/cjs/query/matchers/anchor-matcher.d.ts +17 -17
- package/dist/cjs/query/matchers/anchor-matcher.js +50 -50
- package/dist/cjs/query/matchers/comment-matcher.d.ts +10 -10
- package/dist/cjs/query/matchers/comment-matcher.js +39 -39
- package/dist/cjs/query/matchers/index.d.ts +6 -6
- package/dist/cjs/query/matchers/index.js +22 -22
- package/dist/cjs/query/matchers/many-matcher.d.ts +13 -13
- package/dist/cjs/query/matchers/many-matcher.js +61 -61
- package/dist/cjs/query/matchers/num-matcher.d.ts +8 -8
- package/dist/cjs/query/matchers/num-matcher.js +34 -34
- package/dist/cjs/query/matchers/op-matcher.d.ts +8 -8
- package/dist/cjs/query/matchers/op-matcher.js +34 -34
- package/dist/cjs/query/matchers/seq-matcher.d.ts +14 -14
- package/dist/cjs/query/matchers/seq-matcher.js +76 -76
- package/dist/cjs/query/matchers/str-matcher.d.ts +38 -38
- package/dist/cjs/query/matchers/str-matcher.js +108 -108
- package/dist/cjs/query/matchers/sym-matcher.d.ts +8 -8
- package/dist/cjs/query/matchers/sym-matcher.js +34 -34
- package/dist/cjs/query/matchers/tree-matcher.d.ts +23 -23
- package/dist/cjs/query/matchers/tree-matcher.js +121 -121
- package/dist/cjs/query/options.d.ts +10 -10
- package/dist/cjs/query/options.js +149 -149
- package/dist/cjs/query/regex.d.ts +1 -1
- package/dist/cjs/query/regex.js +13 -13
- package/dist/cjs/query/types.d.ts +100 -100
- package/dist/cjs/query/types.js +2 -2
- package/dist/cjs/util/clone.d.ts +1 -1
- package/dist/cjs/util/clone.js +5 -5
- package/dist/cjs/util/regex.d.ts +1 -1
- package/dist/cjs/util/regex.js +7 -7
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +8 -8
- package/dist/esm/lang/groovy.d.ts +6 -6
- package/dist/esm/lang/groovy.js +80 -80
- package/dist/esm/lang/index.d.ts +20 -20
- package/dist/esm/lang/index.js +37 -37
- package/dist/esm/lang/python.d.ts +6 -6
- package/dist/esm/lang/python.js +70 -70
- package/dist/esm/lang/scala.d.ts +6 -6
- package/dist/esm/lang/scala.js +68 -68
- package/dist/esm/lang/starlark.d.ts +6 -6
- package/dist/esm/lang/starlark.js +55 -55
- package/dist/esm/lang/types.d.ts +6 -6
- package/dist/esm/lang/types.js +1 -1
- package/dist/esm/lexer/bracket.d.ts +6 -6
- package/dist/esm/lexer/bracket.js +49 -49
- package/dist/esm/lexer/comment.d.ts +3 -3
- package/dist/esm/lexer/comment.js +39 -39
- package/dist/esm/lexer/index.d.ts +5 -5
- package/dist/esm/lexer/index.js +136 -136
- package/dist/esm/lexer/number.d.ts +2 -2
- package/dist/esm/lexer/number.js +14 -14
- package/dist/esm/lexer/operator.d.ts +2 -2
- package/dist/esm/lexer/operator.js +20 -20
- package/dist/esm/lexer/rules.d.ts +4 -4
- package/dist/esm/lexer/rules.js +69 -69
- package/dist/esm/lexer/string.d.ts +2 -2
- package/dist/esm/lexer/string.js +177 -177
- package/dist/esm/lexer/symbol.d.ts +2 -2
- package/dist/esm/lexer/symbol.js +14 -14
- package/dist/esm/lexer/token.d.ts +3 -3
- package/dist/esm/lexer/token.js +60 -60
- package/dist/esm/lexer/types.d.ts +142 -142
- package/dist/esm/lexer/types.js +1 -1
- package/dist/esm/parser/cursor.d.ts +2 -2
- package/dist/esm/parser/cursor.js +9 -9
- package/dist/esm/parser/index.d.ts +3 -3
- package/dist/esm/parser/index.js +3 -3
- package/dist/esm/parser/tree.d.ts +4 -4
- package/dist/esm/parser/tree.js +241 -241
- package/dist/esm/parser/types.d.ts +33 -33
- package/dist/esm/parser/types.js +1 -1
- package/dist/esm/query/builder.d.ts +144 -144
- package/dist/esm/query/builder.js +304 -304
- package/dist/esm/query/handler.d.ts +2 -2
- package/dist/esm/query/handler.js +6 -6
- package/dist/esm/query/index.d.ts +2 -2
- package/dist/esm/query/index.js +2 -2
- package/dist/esm/query/matchers/abstract-matcher.d.ts +9 -9
- package/dist/esm/query/matchers/abstract-matcher.js +32 -32
- package/dist/esm/query/matchers/alt-matcher.d.ts +10 -10
- package/dist/esm/query/matchers/alt-matcher.js +29 -29
- package/dist/esm/query/matchers/anchor-matcher.d.ts +17 -17
- package/dist/esm/query/matchers/anchor-matcher.js +44 -44
- package/dist/esm/query/matchers/comment-matcher.d.ts +10 -10
- package/dist/esm/query/matchers/comment-matcher.js +35 -35
- package/dist/esm/query/matchers/index.d.ts +6 -6
- package/dist/esm/query/matchers/index.js +6 -6
- package/dist/esm/query/matchers/many-matcher.d.ts +13 -13
- package/dist/esm/query/matchers/many-matcher.js +57 -57
- package/dist/esm/query/matchers/num-matcher.d.ts +8 -8
- package/dist/esm/query/matchers/num-matcher.js +30 -30
- package/dist/esm/query/matchers/op-matcher.d.ts +8 -8
- package/dist/esm/query/matchers/op-matcher.js +30 -30
- package/dist/esm/query/matchers/seq-matcher.d.ts +14 -14
- package/dist/esm/query/matchers/seq-matcher.js +72 -72
- package/dist/esm/query/matchers/str-matcher.d.ts +38 -38
- package/dist/esm/query/matchers/str-matcher.js +102 -102
- package/dist/esm/query/matchers/sym-matcher.d.ts +8 -8
- package/dist/esm/query/matchers/sym-matcher.js +30 -30
- package/dist/esm/query/matchers/tree-matcher.d.ts +23 -23
- package/dist/esm/query/matchers/tree-matcher.js +117 -117
- package/dist/esm/query/options.d.ts +10 -10
- package/dist/esm/query/options.js +139 -139
- package/dist/esm/query/regex.d.ts +1 -1
- package/dist/esm/query/regex.js +9 -9
- package/dist/esm/query/types.d.ts +100 -100
- package/dist/esm/query/types.js +1 -1
- package/dist/esm/util/clone.d.ts +1 -1
- package/dist/esm/util/clone.js +1 -1
- package/dist/esm/util/regex.d.ts +1 -1
- package/dist/esm/util/regex.js +3 -3
- package/package.json +3 -3
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ManyMatcher = void 0;
|
|
4
|
-
const abstract_matcher_1 = require("./abstract-matcher");
|
|
5
|
-
class ManyMatcher extends abstract_matcher_1.AbstractMatcher {
|
|
6
|
-
constructor({ matcher, min, max }) {
|
|
7
|
-
super();
|
|
8
|
-
this.idx = 0;
|
|
9
|
-
this.matches = [];
|
|
10
|
-
if (min < 0) {
|
|
11
|
-
throw new Error(`Invalid minimal bound: ${min}`);
|
|
12
|
-
}
|
|
13
|
-
if (max !== null && min > max) {
|
|
14
|
-
throw new Error(`Invalid boundaries: ${min} > ${max}`);
|
|
15
|
-
}
|
|
16
|
-
this.manyOf = matcher;
|
|
17
|
-
this.min = min;
|
|
18
|
-
this.max = max;
|
|
19
|
-
}
|
|
20
|
-
nextRound(checkpoints) {
|
|
21
|
-
const results = [];
|
|
22
|
-
for (const oldCheckpoint of checkpoints) {
|
|
23
|
-
const newCheckpoint = this.manyOf.match(oldCheckpoint);
|
|
24
|
-
if (!newCheckpoint) {
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
const matchResults = [newCheckpoint];
|
|
28
|
-
let nextResult = this.manyOf.nextMatch();
|
|
29
|
-
while (nextResult) {
|
|
30
|
-
matchResults.push(nextResult);
|
|
31
|
-
nextResult = this.manyOf.nextMatch();
|
|
32
|
-
}
|
|
33
|
-
results.unshift(...matchResults);
|
|
34
|
-
}
|
|
35
|
-
return results;
|
|
36
|
-
}
|
|
37
|
-
match(checkpoint) {
|
|
38
|
-
var _a;
|
|
39
|
-
this.idx = 0;
|
|
40
|
-
let roundResults = [checkpoint];
|
|
41
|
-
this.matches = this.min === 0 ? [checkpoint] : [];
|
|
42
|
-
let round = 1;
|
|
43
|
-
while (this.max !== null ? round <= this.max : true) {
|
|
44
|
-
roundResults = this.nextRound(roundResults);
|
|
45
|
-
if (roundResults.length) {
|
|
46
|
-
this.matches.unshift(...roundResults);
|
|
47
|
-
round += 1;
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return (_a = this.matches[this.idx]) !== null && _a !== void 0 ? _a : null;
|
|
54
|
-
}
|
|
55
|
-
nextMatch() {
|
|
56
|
-
var _a;
|
|
57
|
-
this.idx += 1;
|
|
58
|
-
return (_a = this.matches[this.idx]) !== null && _a !== void 0 ? _a : null;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.ManyMatcher = ManyMatcher;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ManyMatcher = void 0;
|
|
4
|
+
const abstract_matcher_1 = require("./abstract-matcher");
|
|
5
|
+
class ManyMatcher extends abstract_matcher_1.AbstractMatcher {
|
|
6
|
+
constructor({ matcher, min, max }) {
|
|
7
|
+
super();
|
|
8
|
+
this.idx = 0;
|
|
9
|
+
this.matches = [];
|
|
10
|
+
if (min < 0) {
|
|
11
|
+
throw new Error(`Invalid minimal bound: ${min}`);
|
|
12
|
+
}
|
|
13
|
+
if (max !== null && min > max) {
|
|
14
|
+
throw new Error(`Invalid boundaries: ${min} > ${max}`);
|
|
15
|
+
}
|
|
16
|
+
this.manyOf = matcher;
|
|
17
|
+
this.min = min;
|
|
18
|
+
this.max = max;
|
|
19
|
+
}
|
|
20
|
+
nextRound(checkpoints) {
|
|
21
|
+
const results = [];
|
|
22
|
+
for (const oldCheckpoint of checkpoints) {
|
|
23
|
+
const newCheckpoint = this.manyOf.match(oldCheckpoint);
|
|
24
|
+
if (!newCheckpoint) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const matchResults = [newCheckpoint];
|
|
28
|
+
let nextResult = this.manyOf.nextMatch();
|
|
29
|
+
while (nextResult) {
|
|
30
|
+
matchResults.push(nextResult);
|
|
31
|
+
nextResult = this.manyOf.nextMatch();
|
|
32
|
+
}
|
|
33
|
+
results.unshift(...matchResults);
|
|
34
|
+
}
|
|
35
|
+
return results;
|
|
36
|
+
}
|
|
37
|
+
match(checkpoint) {
|
|
38
|
+
var _a;
|
|
39
|
+
this.idx = 0;
|
|
40
|
+
let roundResults = [checkpoint];
|
|
41
|
+
this.matches = this.min === 0 ? [checkpoint] : [];
|
|
42
|
+
let round = 1;
|
|
43
|
+
while (this.max !== null ? round <= this.max : true) {
|
|
44
|
+
roundResults = this.nextRound(roundResults);
|
|
45
|
+
if (roundResults.length) {
|
|
46
|
+
this.matches.unshift(...roundResults);
|
|
47
|
+
round += 1;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return (_a = this.matches[this.idx]) !== null && _a !== void 0 ? _a : null;
|
|
54
|
+
}
|
|
55
|
+
nextMatch() {
|
|
56
|
+
var _a;
|
|
57
|
+
this.idx += 1;
|
|
58
|
+
return (_a = this.matches[this.idx]) !== null && _a !== void 0 ? _a : null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.ManyMatcher = ManyMatcher;
|
|
62
62
|
//# sourceMappingURL=many-matcher.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Checkpoint, NumMatcherHandler, NumMatcherOptions, NumMatcherValue } from '../types';
|
|
2
|
-
import { AbstractMatcher } from './abstract-matcher';
|
|
3
|
-
export declare class NumMatcher<Ctx> extends AbstractMatcher<Ctx> {
|
|
4
|
-
readonly num: NumMatcherValue;
|
|
5
|
-
readonly handler: NumMatcherHandler<Ctx>;
|
|
6
|
-
constructor({ value, handler }: NumMatcherOptions<Ctx>);
|
|
7
|
-
match(checkpoint: Checkpoint<Ctx>): Checkpoint<Ctx> | null;
|
|
8
|
-
}
|
|
1
|
+
import type { Checkpoint, NumMatcherHandler, NumMatcherOptions, NumMatcherValue } from '../types';
|
|
2
|
+
import { AbstractMatcher } from './abstract-matcher';
|
|
3
|
+
export declare class NumMatcher<Ctx> extends AbstractMatcher<Ctx> {
|
|
4
|
+
readonly num: NumMatcherValue;
|
|
5
|
+
readonly handler: NumMatcherHandler<Ctx>;
|
|
6
|
+
constructor({ value, handler }: NumMatcherOptions<Ctx>);
|
|
7
|
+
match(checkpoint: Checkpoint<Ctx>): Checkpoint<Ctx> | null;
|
|
8
|
+
}
|
|
9
9
|
//# sourceMappingURL=num-matcher.d.ts.map
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NumMatcher = void 0;
|
|
4
|
-
const handler_1 = require("../handler");
|
|
5
|
-
const regex_1 = require("../regex");
|
|
6
|
-
const abstract_matcher_1 = require("./abstract-matcher");
|
|
7
|
-
class NumMatcher extends abstract_matcher_1.AbstractMatcher {
|
|
8
|
-
constructor({ value, handler }) {
|
|
9
|
-
super();
|
|
10
|
-
this.num = value;
|
|
11
|
-
this.handler = (0, handler_1.safeHandler)(handler);
|
|
12
|
-
}
|
|
13
|
-
match(checkpoint) {
|
|
14
|
-
let context = checkpoint.context;
|
|
15
|
-
let cursor = this.seekNext(checkpoint.cursor);
|
|
16
|
-
const node = cursor.node;
|
|
17
|
-
if ((node === null || node === void 0 ? void 0 : node.type) === 'number') {
|
|
18
|
-
let isMatched = true;
|
|
19
|
-
if (typeof this.num === 'string') {
|
|
20
|
-
isMatched = this.num === node.value;
|
|
21
|
-
}
|
|
22
|
-
else if ((0, regex_1.isRegex)(this.num)) {
|
|
23
|
-
isMatched = this.num.test(node.value);
|
|
24
|
-
}
|
|
25
|
-
if (isMatched) {
|
|
26
|
-
context = this.handler(context, node);
|
|
27
|
-
cursor = this.moveRight(cursor);
|
|
28
|
-
return { cursor, context };
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.NumMatcher = NumMatcher;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NumMatcher = void 0;
|
|
4
|
+
const handler_1 = require("../handler");
|
|
5
|
+
const regex_1 = require("../regex");
|
|
6
|
+
const abstract_matcher_1 = require("./abstract-matcher");
|
|
7
|
+
class NumMatcher extends abstract_matcher_1.AbstractMatcher {
|
|
8
|
+
constructor({ value, handler }) {
|
|
9
|
+
super();
|
|
10
|
+
this.num = value;
|
|
11
|
+
this.handler = (0, handler_1.safeHandler)(handler);
|
|
12
|
+
}
|
|
13
|
+
match(checkpoint) {
|
|
14
|
+
let context = checkpoint.context;
|
|
15
|
+
let cursor = this.seekNext(checkpoint.cursor);
|
|
16
|
+
const node = cursor.node;
|
|
17
|
+
if ((node === null || node === void 0 ? void 0 : node.type) === 'number') {
|
|
18
|
+
let isMatched = true;
|
|
19
|
+
if (typeof this.num === 'string') {
|
|
20
|
+
isMatched = this.num === node.value;
|
|
21
|
+
}
|
|
22
|
+
else if ((0, regex_1.isRegex)(this.num)) {
|
|
23
|
+
isMatched = this.num.test(node.value);
|
|
24
|
+
}
|
|
25
|
+
if (isMatched) {
|
|
26
|
+
context = this.handler(context, node);
|
|
27
|
+
cursor = this.moveRight(cursor);
|
|
28
|
+
return { cursor, context };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.NumMatcher = NumMatcher;
|
|
35
35
|
//# sourceMappingURL=num-matcher.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Checkpoint, OpMatcherHandler, OpMatcherOptions, OpMatcherValue } from '../types';
|
|
2
|
-
import { AbstractMatcher } from './abstract-matcher';
|
|
3
|
-
export declare class OpMatcher<Ctx> extends AbstractMatcher<Ctx> {
|
|
4
|
-
readonly op: OpMatcherValue;
|
|
5
|
-
readonly handler: OpMatcherHandler<Ctx>;
|
|
6
|
-
constructor({ value, handler }: OpMatcherOptions<Ctx>);
|
|
7
|
-
match(checkpoint: Checkpoint<Ctx>): Checkpoint<Ctx> | null;
|
|
8
|
-
}
|
|
1
|
+
import type { Checkpoint, OpMatcherHandler, OpMatcherOptions, OpMatcherValue } from '../types';
|
|
2
|
+
import { AbstractMatcher } from './abstract-matcher';
|
|
3
|
+
export declare class OpMatcher<Ctx> extends AbstractMatcher<Ctx> {
|
|
4
|
+
readonly op: OpMatcherValue;
|
|
5
|
+
readonly handler: OpMatcherHandler<Ctx>;
|
|
6
|
+
constructor({ value, handler }: OpMatcherOptions<Ctx>);
|
|
7
|
+
match(checkpoint: Checkpoint<Ctx>): Checkpoint<Ctx> | null;
|
|
8
|
+
}
|
|
9
9
|
//# sourceMappingURL=op-matcher.d.ts.map
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OpMatcher = void 0;
|
|
4
|
-
const handler_1 = require("../handler");
|
|
5
|
-
const regex_1 = require("../regex");
|
|
6
|
-
const abstract_matcher_1 = require("./abstract-matcher");
|
|
7
|
-
class OpMatcher extends abstract_matcher_1.AbstractMatcher {
|
|
8
|
-
constructor({ value, handler }) {
|
|
9
|
-
super();
|
|
10
|
-
this.op = value;
|
|
11
|
-
this.handler = (0, handler_1.safeHandler)(handler);
|
|
12
|
-
}
|
|
13
|
-
match(checkpoint) {
|
|
14
|
-
let context = checkpoint.context;
|
|
15
|
-
let cursor = this.seekNext(checkpoint.cursor);
|
|
16
|
-
const node = cursor.node;
|
|
17
|
-
if ((node === null || node === void 0 ? void 0 : node.type) === 'operator') {
|
|
18
|
-
let isMatched = true;
|
|
19
|
-
if (typeof this.op === 'string') {
|
|
20
|
-
isMatched = this.op === node.value;
|
|
21
|
-
}
|
|
22
|
-
else if ((0, regex_1.isRegex)(this.op)) {
|
|
23
|
-
isMatched = this.op.test(node.value);
|
|
24
|
-
}
|
|
25
|
-
if (isMatched) {
|
|
26
|
-
context = this.handler(context, node);
|
|
27
|
-
cursor = this.moveRight(cursor);
|
|
28
|
-
return { cursor, context };
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.OpMatcher = OpMatcher;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpMatcher = void 0;
|
|
4
|
+
const handler_1 = require("../handler");
|
|
5
|
+
const regex_1 = require("../regex");
|
|
6
|
+
const abstract_matcher_1 = require("./abstract-matcher");
|
|
7
|
+
class OpMatcher extends abstract_matcher_1.AbstractMatcher {
|
|
8
|
+
constructor({ value, handler }) {
|
|
9
|
+
super();
|
|
10
|
+
this.op = value;
|
|
11
|
+
this.handler = (0, handler_1.safeHandler)(handler);
|
|
12
|
+
}
|
|
13
|
+
match(checkpoint) {
|
|
14
|
+
let context = checkpoint.context;
|
|
15
|
+
let cursor = this.seekNext(checkpoint.cursor);
|
|
16
|
+
const node = cursor.node;
|
|
17
|
+
if ((node === null || node === void 0 ? void 0 : node.type) === 'operator') {
|
|
18
|
+
let isMatched = true;
|
|
19
|
+
if (typeof this.op === 'string') {
|
|
20
|
+
isMatched = this.op === node.value;
|
|
21
|
+
}
|
|
22
|
+
else if ((0, regex_1.isRegex)(this.op)) {
|
|
23
|
+
isMatched = this.op.test(node.value);
|
|
24
|
+
}
|
|
25
|
+
if (isMatched) {
|
|
26
|
+
context = this.handler(context, node);
|
|
27
|
+
cursor = this.moveRight(cursor);
|
|
28
|
+
return { cursor, context };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.OpMatcher = OpMatcher;
|
|
35
35
|
//# sourceMappingURL=op-matcher.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { Checkpoint, Matcher, SeqMatcherOptions } from '../types';
|
|
2
|
-
import { AbstractMatcher } from './abstract-matcher';
|
|
3
|
-
export declare class SeqMatcher<Ctx> extends AbstractMatcher<Ctx> {
|
|
4
|
-
readonly seq: Matcher<Ctx>[];
|
|
5
|
-
readonly length: number;
|
|
6
|
-
private checkpoint;
|
|
7
|
-
private idx;
|
|
8
|
-
constructor({ matchers }: SeqMatcherOptions<Ctx>);
|
|
9
|
-
private isMatchingComplete;
|
|
10
|
-
private matchForward;
|
|
11
|
-
private backtrack;
|
|
12
|
-
match(checkpoint: Checkpoint<Ctx>): Checkpoint<Ctx> | null;
|
|
13
|
-
nextMatch(): Checkpoint<Ctx> | null;
|
|
14
|
-
}
|
|
1
|
+
import type { Checkpoint, Matcher, SeqMatcherOptions } from '../types';
|
|
2
|
+
import { AbstractMatcher } from './abstract-matcher';
|
|
3
|
+
export declare class SeqMatcher<Ctx> extends AbstractMatcher<Ctx> {
|
|
4
|
+
readonly seq: Matcher<Ctx>[];
|
|
5
|
+
readonly length: number;
|
|
6
|
+
private checkpoint;
|
|
7
|
+
private idx;
|
|
8
|
+
constructor({ matchers }: SeqMatcherOptions<Ctx>);
|
|
9
|
+
private isMatchingComplete;
|
|
10
|
+
private matchForward;
|
|
11
|
+
private backtrack;
|
|
12
|
+
match(checkpoint: Checkpoint<Ctx>): Checkpoint<Ctx> | null;
|
|
13
|
+
nextMatch(): Checkpoint<Ctx> | null;
|
|
14
|
+
}
|
|
15
15
|
//# sourceMappingURL=seq-matcher.d.ts.map
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SeqMatcher = void 0;
|
|
4
|
-
const abstract_matcher_1 = require("./abstract-matcher");
|
|
5
|
-
class SeqMatcher extends abstract_matcher_1.AbstractMatcher {
|
|
6
|
-
constructor({ matchers }) {
|
|
7
|
-
super();
|
|
8
|
-
this.checkpoint = null;
|
|
9
|
-
this.idx = 0;
|
|
10
|
-
this.seq = matchers;
|
|
11
|
-
this.length = this.seq.length;
|
|
12
|
-
}
|
|
13
|
-
isMatchingComplete() {
|
|
14
|
-
return this.idx === this.length;
|
|
15
|
-
}
|
|
16
|
-
matchForward() {
|
|
17
|
-
if (this.checkpoint) {
|
|
18
|
-
while (this.idx < this.length) {
|
|
19
|
-
const matcher = this.seq[this.idx];
|
|
20
|
-
const checkpoint = matcher.match(this.checkpoint);
|
|
21
|
-
if (!checkpoint) {
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
24
|
-
this.checkpoint = checkpoint;
|
|
25
|
-
this.idx += 1;
|
|
26
|
-
}
|
|
27
|
-
if (this.isMatchingComplete()) {
|
|
28
|
-
return this.checkpoint;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
backtrack() {
|
|
34
|
-
while (this.idx > 0) {
|
|
35
|
-
this.idx -= 1;
|
|
36
|
-
const matcher = this.seq[this.idx];
|
|
37
|
-
const match = matcher.nextMatch();
|
|
38
|
-
if (match) {
|
|
39
|
-
this.checkpoint = match;
|
|
40
|
-
this.idx += 1;
|
|
41
|
-
return match;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
match(checkpoint) {
|
|
47
|
-
this.idx = 0;
|
|
48
|
-
this.checkpoint = checkpoint;
|
|
49
|
-
while (!this.isMatchingComplete()) {
|
|
50
|
-
const forwardMatch = this.matchForward();
|
|
51
|
-
if (!forwardMatch) {
|
|
52
|
-
const backwardMatch = this.backtrack();
|
|
53
|
-
if (!backwardMatch) {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return this.checkpoint;
|
|
59
|
-
}
|
|
60
|
-
nextMatch() {
|
|
61
|
-
if (!this.backtrack()) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
while (!this.isMatchingComplete()) {
|
|
65
|
-
const forwardMatch = this.matchForward();
|
|
66
|
-
if (!forwardMatch) {
|
|
67
|
-
const backwardMatch = this.backtrack();
|
|
68
|
-
if (!backwardMatch) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return this.checkpoint;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
exports.SeqMatcher = SeqMatcher;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SeqMatcher = void 0;
|
|
4
|
+
const abstract_matcher_1 = require("./abstract-matcher");
|
|
5
|
+
class SeqMatcher extends abstract_matcher_1.AbstractMatcher {
|
|
6
|
+
constructor({ matchers }) {
|
|
7
|
+
super();
|
|
8
|
+
this.checkpoint = null;
|
|
9
|
+
this.idx = 0;
|
|
10
|
+
this.seq = matchers;
|
|
11
|
+
this.length = this.seq.length;
|
|
12
|
+
}
|
|
13
|
+
isMatchingComplete() {
|
|
14
|
+
return this.idx === this.length;
|
|
15
|
+
}
|
|
16
|
+
matchForward() {
|
|
17
|
+
if (this.checkpoint) {
|
|
18
|
+
while (this.idx < this.length) {
|
|
19
|
+
const matcher = this.seq[this.idx];
|
|
20
|
+
const checkpoint = matcher.match(this.checkpoint);
|
|
21
|
+
if (!checkpoint) {
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
this.checkpoint = checkpoint;
|
|
25
|
+
this.idx += 1;
|
|
26
|
+
}
|
|
27
|
+
if (this.isMatchingComplete()) {
|
|
28
|
+
return this.checkpoint;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
backtrack() {
|
|
34
|
+
while (this.idx > 0) {
|
|
35
|
+
this.idx -= 1;
|
|
36
|
+
const matcher = this.seq[this.idx];
|
|
37
|
+
const match = matcher.nextMatch();
|
|
38
|
+
if (match) {
|
|
39
|
+
this.checkpoint = match;
|
|
40
|
+
this.idx += 1;
|
|
41
|
+
return match;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
match(checkpoint) {
|
|
47
|
+
this.idx = 0;
|
|
48
|
+
this.checkpoint = checkpoint;
|
|
49
|
+
while (!this.isMatchingComplete()) {
|
|
50
|
+
const forwardMatch = this.matchForward();
|
|
51
|
+
if (!forwardMatch) {
|
|
52
|
+
const backwardMatch = this.backtrack();
|
|
53
|
+
if (!backwardMatch) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return this.checkpoint;
|
|
59
|
+
}
|
|
60
|
+
nextMatch() {
|
|
61
|
+
if (!this.backtrack()) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
while (!this.isMatchingComplete()) {
|
|
65
|
+
const forwardMatch = this.matchForward();
|
|
66
|
+
if (!forwardMatch) {
|
|
67
|
+
const backwardMatch = this.backtrack();
|
|
68
|
+
if (!backwardMatch) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return this.checkpoint;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.SeqMatcher = SeqMatcher;
|
|
77
77
|
//# sourceMappingURL=seq-matcher.js.map
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import type { StringValueToken } from '../../lexer/types';
|
|
2
|
-
import type { TemplateTree } from '../../parser/types';
|
|
3
|
-
import type { Checkpoint, Matcher, NodeHandler, StrTplOptionsBase, StrTreeHandler, StrTreeOptionsBase } from '../types';
|
|
4
|
-
import { AbstractMatcher } from './abstract-matcher';
|
|
5
|
-
export type StrContentMatcherValue = string | RegExp | null;
|
|
6
|
-
export type StrContentMatcherHandler<Ctx> = (ctx: Ctx, token: StringValueToken) => Ctx;
|
|
7
|
-
export interface StrContentMatcherOptions<Ctx> {
|
|
8
|
-
value: StrContentMatcherValue;
|
|
9
|
-
handler: StrContentMatcherHandler<Ctx> | null;
|
|
10
|
-
}
|
|
11
|
-
export declare class StrContentMatcher<Ctx> extends AbstractMatcher<Ctx> {
|
|
12
|
-
readonly content: StrContentMatcherValue;
|
|
13
|
-
readonly handler: StrContentMatcherHandler<Ctx>;
|
|
14
|
-
constructor({ value, handler }: StrContentMatcherOptions<Ctx>);
|
|
15
|
-
match(checkpoint: Checkpoint<Ctx>): Checkpoint<Ctx> | null;
|
|
16
|
-
}
|
|
17
|
-
interface StrTplMatcherOptions<Ctx> extends StrTplOptionsBase<Ctx> {
|
|
18
|
-
matcher: Matcher<Ctx>;
|
|
19
|
-
}
|
|
20
|
-
export declare class StrTplMatcher<Ctx> extends AbstractMatcher<Ctx> {
|
|
21
|
-
readonly matcher: Matcher<Ctx>;
|
|
22
|
-
readonly preHandler: NodeHandler<Ctx, TemplateTree>;
|
|
23
|
-
readonly postHandler: NodeHandler<Ctx, TemplateTree>;
|
|
24
|
-
constructor(config: StrTplMatcherOptions<Ctx>);
|
|
25
|
-
match(checkpoint: Checkpoint<Ctx>): Checkpoint<Ctx> | null;
|
|
26
|
-
}
|
|
27
|
-
export type StrNodeChildMatcher<Ctx> = StrContentMatcher<Ctx> | StrTplMatcher<Ctx>;
|
|
28
|
-
export interface StrMatcherOptions<Ctx> extends StrTreeOptionsBase<Ctx> {
|
|
29
|
-
matchers: StrNodeChildMatcher<Ctx>[] | null;
|
|
30
|
-
}
|
|
31
|
-
export declare class StrNodeMatcher<Ctx> extends AbstractMatcher<Ctx> {
|
|
32
|
-
matchers: StrNodeChildMatcher<Ctx>[] | null;
|
|
33
|
-
readonly preHandler: StrTreeHandler<Ctx>;
|
|
34
|
-
readonly postHandler: StrTreeHandler<Ctx>;
|
|
35
|
-
constructor(opts: StrMatcherOptions<Ctx>);
|
|
36
|
-
match(checkpoint: Checkpoint<Ctx>): Checkpoint<Ctx> | null;
|
|
37
|
-
}
|
|
38
|
-
export {};
|
|
1
|
+
import type { StringValueToken } from '../../lexer/types';
|
|
2
|
+
import type { TemplateTree } from '../../parser/types';
|
|
3
|
+
import type { Checkpoint, Matcher, NodeHandler, StrTplOptionsBase, StrTreeHandler, StrTreeOptionsBase } from '../types';
|
|
4
|
+
import { AbstractMatcher } from './abstract-matcher';
|
|
5
|
+
export type StrContentMatcherValue = string | RegExp | null;
|
|
6
|
+
export type StrContentMatcherHandler<Ctx> = (ctx: Ctx, token: StringValueToken) => Ctx;
|
|
7
|
+
export interface StrContentMatcherOptions<Ctx> {
|
|
8
|
+
value: StrContentMatcherValue;
|
|
9
|
+
handler: StrContentMatcherHandler<Ctx> | null;
|
|
10
|
+
}
|
|
11
|
+
export declare class StrContentMatcher<Ctx> extends AbstractMatcher<Ctx> {
|
|
12
|
+
readonly content: StrContentMatcherValue;
|
|
13
|
+
readonly handler: StrContentMatcherHandler<Ctx>;
|
|
14
|
+
constructor({ value, handler }: StrContentMatcherOptions<Ctx>);
|
|
15
|
+
match(checkpoint: Checkpoint<Ctx>): Checkpoint<Ctx> | null;
|
|
16
|
+
}
|
|
17
|
+
interface StrTplMatcherOptions<Ctx> extends StrTplOptionsBase<Ctx> {
|
|
18
|
+
matcher: Matcher<Ctx>;
|
|
19
|
+
}
|
|
20
|
+
export declare class StrTplMatcher<Ctx> extends AbstractMatcher<Ctx> {
|
|
21
|
+
readonly matcher: Matcher<Ctx>;
|
|
22
|
+
readonly preHandler: NodeHandler<Ctx, TemplateTree>;
|
|
23
|
+
readonly postHandler: NodeHandler<Ctx, TemplateTree>;
|
|
24
|
+
constructor(config: StrTplMatcherOptions<Ctx>);
|
|
25
|
+
match(checkpoint: Checkpoint<Ctx>): Checkpoint<Ctx> | null;
|
|
26
|
+
}
|
|
27
|
+
export type StrNodeChildMatcher<Ctx> = StrContentMatcher<Ctx> | StrTplMatcher<Ctx>;
|
|
28
|
+
export interface StrMatcherOptions<Ctx> extends StrTreeOptionsBase<Ctx> {
|
|
29
|
+
matchers: StrNodeChildMatcher<Ctx>[] | null;
|
|
30
|
+
}
|
|
31
|
+
export declare class StrNodeMatcher<Ctx> extends AbstractMatcher<Ctx> {
|
|
32
|
+
matchers: StrNodeChildMatcher<Ctx>[] | null;
|
|
33
|
+
readonly preHandler: StrTreeHandler<Ctx>;
|
|
34
|
+
readonly postHandler: StrTreeHandler<Ctx>;
|
|
35
|
+
constructor(opts: StrMatcherOptions<Ctx>);
|
|
36
|
+
match(checkpoint: Checkpoint<Ctx>): Checkpoint<Ctx> | null;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
39
39
|
//# sourceMappingURL=str-matcher.d.ts.map
|