@bcts/envelope-pattern 1.0.0-alpha.15 → 1.0.0-alpha.17
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 +1 -1
- package/dist/index.cjs +485 -485
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +93 -29
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +93 -29
- package/dist/index.d.mts.map +1 -1
- package/dist/index.iife.js +485 -485
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +504 -504
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
- package/src/format.ts +9 -9
- package/src/parse/token.ts +55 -55
- package/src/pattern/leaf/array-pattern.ts +25 -25
- package/src/pattern/leaf/bool-pattern.ts +11 -11
- package/src/pattern/leaf/byte-string-pattern.ts +14 -14
- package/src/pattern/leaf/cbor-pattern.ts +29 -29
- package/src/pattern/leaf/date-pattern.ts +8 -8
- package/src/pattern/leaf/known-value-pattern.ts +17 -17
- package/src/pattern/leaf/map-pattern.ts +13 -13
- package/src/pattern/leaf/null-pattern.ts +7 -7
- package/src/pattern/leaf/number-pattern.ts +19 -19
- package/src/pattern/leaf/tagged-pattern.ts +20 -20
- package/src/pattern/leaf/text-pattern.ts +13 -13
- package/src/pattern/meta/and-pattern.ts +11 -11
- package/src/pattern/meta/capture-pattern.ts +14 -14
- package/src/pattern/meta/group-pattern.ts +13 -13
- package/src/pattern/meta/not-pattern.ts +7 -7
- package/src/pattern/meta/or-pattern.ts +15 -15
- package/src/pattern/meta/search-pattern.ts +15 -15
- package/src/pattern/meta/traverse-pattern.ts +15 -15
- package/src/pattern/structure/assertions-pattern.ts +28 -28
- package/src/pattern/structure/digest-pattern.ts +23 -23
- package/src/pattern/structure/node-pattern.ts +17 -17
- package/src/pattern/structure/object-pattern.ts +13 -13
- package/src/pattern/structure/obscured-pattern.ts +7 -7
- package/src/pattern/structure/predicate-pattern.ts +13 -13
- package/src/pattern/structure/subject-pattern.ts +15 -15
- package/src/pattern/structure/wrapped-pattern.ts +15 -15
package/dist/index.iife.js
CHANGED
|
@@ -260,28 +260,28 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
260
260
|
* Builder for FormatPathsOpts.
|
|
261
261
|
*/
|
|
262
262
|
var FormatPathsOptsBuilder = class {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
263
|
+
_indent = true;
|
|
264
|
+
_elementFormat = defaultPathElementFormat();
|
|
265
|
+
_lastElementOnly = false;
|
|
266
266
|
/**
|
|
267
267
|
* Sets whether to indent each path element.
|
|
268
268
|
*/
|
|
269
269
|
indent(indent) {
|
|
270
|
-
this
|
|
270
|
+
this._indent = indent;
|
|
271
271
|
return this;
|
|
272
272
|
}
|
|
273
273
|
/**
|
|
274
274
|
* Sets the format for each path element.
|
|
275
275
|
*/
|
|
276
276
|
elementFormat(format) {
|
|
277
|
-
this
|
|
277
|
+
this._elementFormat = format;
|
|
278
278
|
return this;
|
|
279
279
|
}
|
|
280
280
|
/**
|
|
281
281
|
* Sets whether to format only the last element of each path.
|
|
282
282
|
*/
|
|
283
283
|
lastElementOnly(lastElementOnly) {
|
|
284
|
-
this
|
|
284
|
+
this._lastElementOnly = lastElementOnly;
|
|
285
285
|
return this;
|
|
286
286
|
}
|
|
287
287
|
/**
|
|
@@ -289,9 +289,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
289
289
|
*/
|
|
290
290
|
build() {
|
|
291
291
|
return {
|
|
292
|
-
indent: this
|
|
293
|
-
elementFormat: this
|
|
294
|
-
lastElementOnly: this
|
|
292
|
+
indent: this._indent,
|
|
293
|
+
elementFormat: this._elementFormat,
|
|
294
|
+
lastElementOnly: this._lastElementOnly
|
|
295
295
|
};
|
|
296
296
|
}
|
|
297
297
|
};
|
|
@@ -531,9 +531,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
531
531
|
* Corresponds to the Rust `BoolPattern` struct in bool_pattern.rs
|
|
532
532
|
*/
|
|
533
533
|
var BoolPattern = class BoolPattern {
|
|
534
|
-
|
|
534
|
+
_inner;
|
|
535
535
|
constructor(inner) {
|
|
536
|
-
this
|
|
536
|
+
this._inner = inner;
|
|
537
537
|
}
|
|
538
538
|
/**
|
|
539
539
|
* Creates a new BoolPattern that matches any boolean value.
|
|
@@ -557,12 +557,12 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
557
557
|
* Gets the underlying dcbor-pattern BoolPattern.
|
|
558
558
|
*/
|
|
559
559
|
get inner() {
|
|
560
|
-
return this
|
|
560
|
+
return this._inner;
|
|
561
561
|
}
|
|
562
562
|
pathsWithCaptures(haystack) {
|
|
563
563
|
const cbor = haystack.asLeaf();
|
|
564
564
|
if (cbor !== void 0) {
|
|
565
|
-
if ((0, _bcts_dcbor_pattern.boolPatternPaths)(this
|
|
565
|
+
if ((0, _bcts_dcbor_pattern.boolPatternPaths)(this._inner, cbor).length > 0) return [[[haystack]], /* @__PURE__ */ new Map()];
|
|
566
566
|
}
|
|
567
567
|
return [[], /* @__PURE__ */ new Map()];
|
|
568
568
|
}
|
|
@@ -580,22 +580,22 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
580
580
|
return false;
|
|
581
581
|
}
|
|
582
582
|
toString() {
|
|
583
|
-
return (0, _bcts_dcbor_pattern.boolPatternDisplay)(this
|
|
583
|
+
return (0, _bcts_dcbor_pattern.boolPatternDisplay)(this._inner);
|
|
584
584
|
}
|
|
585
585
|
/**
|
|
586
586
|
* Equality comparison.
|
|
587
587
|
*/
|
|
588
588
|
equals(other) {
|
|
589
|
-
if (this
|
|
590
|
-
if (this
|
|
589
|
+
if (this._inner.variant !== other._inner.variant) return false;
|
|
590
|
+
if (this._inner.variant === "Value" && other._inner.variant === "Value") return this._inner.value === other._inner.value;
|
|
591
591
|
return true;
|
|
592
592
|
}
|
|
593
593
|
/**
|
|
594
594
|
* Hash code for use in Maps/Sets.
|
|
595
595
|
*/
|
|
596
596
|
hashCode() {
|
|
597
|
-
let hash = this
|
|
598
|
-
if (this
|
|
597
|
+
let hash = this._inner.variant === "Any" ? 0 : 1;
|
|
598
|
+
if (this._inner.variant === "Value") hash = hash * 31 + (this._inner.value ? 1 : 0);
|
|
599
599
|
return hash;
|
|
600
600
|
}
|
|
601
601
|
};
|
|
@@ -615,27 +615,27 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
615
615
|
* Corresponds to the Rust `NullPattern` struct in null_pattern.rs
|
|
616
616
|
*/
|
|
617
617
|
var NullPattern = class NullPattern {
|
|
618
|
-
|
|
619
|
-
static
|
|
618
|
+
_inner;
|
|
619
|
+
static _instance = new NullPattern();
|
|
620
620
|
constructor() {
|
|
621
|
-
this
|
|
621
|
+
this._inner = { variant: "Null" };
|
|
622
622
|
}
|
|
623
623
|
/**
|
|
624
624
|
* Creates a new NullPattern (returns singleton).
|
|
625
625
|
*/
|
|
626
626
|
static new() {
|
|
627
|
-
return NullPattern
|
|
627
|
+
return NullPattern._instance;
|
|
628
628
|
}
|
|
629
629
|
/**
|
|
630
630
|
* Gets the underlying dcbor-pattern NullPattern.
|
|
631
631
|
*/
|
|
632
632
|
get inner() {
|
|
633
|
-
return this
|
|
633
|
+
return this._inner;
|
|
634
634
|
}
|
|
635
635
|
pathsWithCaptures(haystack) {
|
|
636
636
|
const cbor = haystack.asLeaf();
|
|
637
637
|
if (cbor !== void 0) {
|
|
638
|
-
if ((0, _bcts_dcbor_pattern.nullPatternPaths)(this
|
|
638
|
+
if ((0, _bcts_dcbor_pattern.nullPatternPaths)(this._inner, cbor).length > 0) return [[[haystack]], /* @__PURE__ */ new Map()];
|
|
639
639
|
}
|
|
640
640
|
return [[], /* @__PURE__ */ new Map()];
|
|
641
641
|
}
|
|
@@ -653,7 +653,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
653
653
|
return false;
|
|
654
654
|
}
|
|
655
655
|
toString() {
|
|
656
|
-
return (0, _bcts_dcbor_pattern.nullPatternDisplay)(this
|
|
656
|
+
return (0, _bcts_dcbor_pattern.nullPatternDisplay)(this._inner);
|
|
657
657
|
}
|
|
658
658
|
/**
|
|
659
659
|
* Equality comparison.
|
|
@@ -684,9 +684,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
684
684
|
* Corresponds to the Rust `NumberPattern` struct in number_pattern.rs
|
|
685
685
|
*/
|
|
686
686
|
var NumberPattern = class NumberPattern {
|
|
687
|
-
|
|
687
|
+
_inner;
|
|
688
688
|
constructor(inner) {
|
|
689
|
-
this
|
|
689
|
+
this._inner = inner;
|
|
690
690
|
}
|
|
691
691
|
/**
|
|
692
692
|
* Creates a new NumberPattern that matches any number.
|
|
@@ -758,12 +758,12 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
758
758
|
* Gets the underlying dcbor-pattern NumberPattern.
|
|
759
759
|
*/
|
|
760
760
|
get inner() {
|
|
761
|
-
return this
|
|
761
|
+
return this._inner;
|
|
762
762
|
}
|
|
763
763
|
pathsWithCaptures(haystack) {
|
|
764
764
|
const cbor = haystack.asLeaf();
|
|
765
765
|
if (cbor !== void 0) {
|
|
766
|
-
if ((0, _bcts_dcbor_pattern.numberPatternPaths)(this
|
|
766
|
+
if ((0, _bcts_dcbor_pattern.numberPatternPaths)(this._inner, cbor).length > 0) return [[[haystack]], /* @__PURE__ */ new Map()];
|
|
767
767
|
}
|
|
768
768
|
return [[], /* @__PURE__ */ new Map()];
|
|
769
769
|
}
|
|
@@ -781,14 +781,14 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
781
781
|
return false;
|
|
782
782
|
}
|
|
783
783
|
toString() {
|
|
784
|
-
return (0, _bcts_dcbor_pattern.numberPatternDisplay)(this
|
|
784
|
+
return (0, _bcts_dcbor_pattern.numberPatternDisplay)(this._inner);
|
|
785
785
|
}
|
|
786
786
|
/**
|
|
787
787
|
* Equality comparison.
|
|
788
788
|
*/
|
|
789
789
|
equals(other) {
|
|
790
|
-
if (this
|
|
791
|
-
switch (this
|
|
790
|
+
if (this._inner.variant !== other._inner.variant) return false;
|
|
791
|
+
switch (this._inner.variant) {
|
|
792
792
|
case "Any":
|
|
793
793
|
case "NaN":
|
|
794
794
|
case "Infinity":
|
|
@@ -797,8 +797,8 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
797
797
|
case "GreaterThan":
|
|
798
798
|
case "GreaterThanOrEqual":
|
|
799
799
|
case "LessThan":
|
|
800
|
-
case "LessThanOrEqual": return this
|
|
801
|
-
case "Range": return this
|
|
800
|
+
case "LessThanOrEqual": return this._inner.value === other._inner.value;
|
|
801
|
+
case "Range": return this._inner.min === other._inner.min && this._inner.max === other._inner.max;
|
|
802
802
|
}
|
|
803
803
|
}
|
|
804
804
|
/**
|
|
@@ -806,27 +806,27 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
806
806
|
*/
|
|
807
807
|
hashCode() {
|
|
808
808
|
let hash = 0;
|
|
809
|
-
switch (this
|
|
809
|
+
switch (this._inner.variant) {
|
|
810
810
|
case "Any":
|
|
811
811
|
hash = 1;
|
|
812
812
|
break;
|
|
813
813
|
case "Value":
|
|
814
|
-
hash = 62 + this
|
|
814
|
+
hash = 62 + this._inner.value;
|
|
815
815
|
break;
|
|
816
816
|
case "Range":
|
|
817
|
-
hash = 93 + this
|
|
817
|
+
hash = 93 + this._inner.min + this._inner.max;
|
|
818
818
|
break;
|
|
819
819
|
case "GreaterThan":
|
|
820
|
-
hash = 124 + this
|
|
820
|
+
hash = 124 + this._inner.value;
|
|
821
821
|
break;
|
|
822
822
|
case "GreaterThanOrEqual":
|
|
823
|
-
hash = 155 + this
|
|
823
|
+
hash = 155 + this._inner.value;
|
|
824
824
|
break;
|
|
825
825
|
case "LessThan":
|
|
826
|
-
hash = 186 + this
|
|
826
|
+
hash = 186 + this._inner.value;
|
|
827
827
|
break;
|
|
828
828
|
case "LessThanOrEqual":
|
|
829
|
-
hash = 217 + this
|
|
829
|
+
hash = 217 + this._inner.value;
|
|
830
830
|
break;
|
|
831
831
|
case "NaN":
|
|
832
832
|
hash = 8;
|
|
@@ -857,9 +857,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
857
857
|
* Corresponds to the Rust `TextPattern` struct in text_pattern.rs
|
|
858
858
|
*/
|
|
859
859
|
var TextPattern = class TextPattern {
|
|
860
|
-
|
|
860
|
+
_inner;
|
|
861
861
|
constructor(inner) {
|
|
862
|
-
this
|
|
862
|
+
this._inner = inner;
|
|
863
863
|
}
|
|
864
864
|
/**
|
|
865
865
|
* Creates a new TextPattern that matches any text.
|
|
@@ -889,12 +889,12 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
889
889
|
* Gets the underlying dcbor-pattern TextPattern.
|
|
890
890
|
*/
|
|
891
891
|
get inner() {
|
|
892
|
-
return this
|
|
892
|
+
return this._inner;
|
|
893
893
|
}
|
|
894
894
|
pathsWithCaptures(haystack) {
|
|
895
895
|
const cbor = haystack.asLeaf();
|
|
896
896
|
if (cbor !== void 0) {
|
|
897
|
-
if ((0, _bcts_dcbor_pattern.textPatternPaths)(this
|
|
897
|
+
if ((0, _bcts_dcbor_pattern.textPatternPaths)(this._inner, cbor).length > 0) return [[[haystack]], /* @__PURE__ */ new Map()];
|
|
898
898
|
}
|
|
899
899
|
return [[], /* @__PURE__ */ new Map()];
|
|
900
900
|
}
|
|
@@ -912,17 +912,17 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
912
912
|
return false;
|
|
913
913
|
}
|
|
914
914
|
toString() {
|
|
915
|
-
return (0, _bcts_dcbor_pattern.textPatternDisplay)(this
|
|
915
|
+
return (0, _bcts_dcbor_pattern.textPatternDisplay)(this._inner);
|
|
916
916
|
}
|
|
917
917
|
/**
|
|
918
918
|
* Equality comparison.
|
|
919
919
|
*/
|
|
920
920
|
equals(other) {
|
|
921
|
-
if (this
|
|
922
|
-
switch (this
|
|
921
|
+
if (this._inner.variant !== other._inner.variant) return false;
|
|
922
|
+
switch (this._inner.variant) {
|
|
923
923
|
case "Any": return true;
|
|
924
|
-
case "Value": return this
|
|
925
|
-
case "Regex": return this
|
|
924
|
+
case "Value": return this._inner.value === other._inner.value;
|
|
925
|
+
case "Regex": return this._inner.pattern.source === other._inner.pattern.source;
|
|
926
926
|
}
|
|
927
927
|
}
|
|
928
928
|
/**
|
|
@@ -930,17 +930,17 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
930
930
|
*/
|
|
931
931
|
hashCode() {
|
|
932
932
|
let hash = 0;
|
|
933
|
-
switch (this
|
|
933
|
+
switch (this._inner.variant) {
|
|
934
934
|
case "Any":
|
|
935
935
|
hash = 1;
|
|
936
936
|
break;
|
|
937
937
|
case "Value": {
|
|
938
|
-
const val = this
|
|
938
|
+
const val = this._inner.value;
|
|
939
939
|
for (let i = 0; i < val.length; i++) hash = hash * 31 + val.charCodeAt(i);
|
|
940
940
|
break;
|
|
941
941
|
}
|
|
942
942
|
case "Regex":
|
|
943
|
-
hash = 93 + this
|
|
943
|
+
hash = 93 + this._inner.pattern.source.length;
|
|
944
944
|
break;
|
|
945
945
|
}
|
|
946
946
|
return hash;
|
|
@@ -962,9 +962,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
962
962
|
* Corresponds to the Rust `ByteStringPattern` struct in byte_string_pattern.rs
|
|
963
963
|
*/
|
|
964
964
|
var ByteStringPattern = class ByteStringPattern {
|
|
965
|
-
|
|
965
|
+
_inner;
|
|
966
966
|
constructor(inner) {
|
|
967
|
-
this
|
|
967
|
+
this._inner = inner;
|
|
968
968
|
}
|
|
969
969
|
/**
|
|
970
970
|
* Creates a new ByteStringPattern that matches any byte string.
|
|
@@ -994,12 +994,12 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
994
994
|
* Gets the underlying dcbor-pattern ByteStringPattern.
|
|
995
995
|
*/
|
|
996
996
|
get inner() {
|
|
997
|
-
return this
|
|
997
|
+
return this._inner;
|
|
998
998
|
}
|
|
999
999
|
pathsWithCaptures(haystack) {
|
|
1000
1000
|
const cbor = haystack.asLeaf();
|
|
1001
1001
|
if (cbor !== void 0) {
|
|
1002
|
-
if ((0, _bcts_dcbor_pattern.byteStringPatternPaths)(this
|
|
1002
|
+
if ((0, _bcts_dcbor_pattern.byteStringPatternPaths)(this._inner, cbor).length > 0) return [[[haystack]], /* @__PURE__ */ new Map()];
|
|
1003
1003
|
}
|
|
1004
1004
|
return [[], /* @__PURE__ */ new Map()];
|
|
1005
1005
|
}
|
|
@@ -1017,23 +1017,23 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1017
1017
|
return false;
|
|
1018
1018
|
}
|
|
1019
1019
|
toString() {
|
|
1020
|
-
return (0, _bcts_dcbor_pattern.byteStringPatternDisplay)(this
|
|
1020
|
+
return (0, _bcts_dcbor_pattern.byteStringPatternDisplay)(this._inner);
|
|
1021
1021
|
}
|
|
1022
1022
|
/**
|
|
1023
1023
|
* Equality comparison.
|
|
1024
1024
|
*/
|
|
1025
1025
|
equals(other) {
|
|
1026
|
-
if (this
|
|
1027
|
-
switch (this
|
|
1026
|
+
if (this._inner.variant !== other._inner.variant) return false;
|
|
1027
|
+
switch (this._inner.variant) {
|
|
1028
1028
|
case "Any": return true;
|
|
1029
1029
|
case "Value": {
|
|
1030
|
-
const a = this
|
|
1031
|
-
const b = other
|
|
1030
|
+
const a = this._inner.value;
|
|
1031
|
+
const b = other._inner.value;
|
|
1032
1032
|
if (a.length !== b.length) return false;
|
|
1033
1033
|
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
|
|
1034
1034
|
return true;
|
|
1035
1035
|
}
|
|
1036
|
-
case "BinaryRegex": return this
|
|
1036
|
+
case "BinaryRegex": return this._inner.pattern.source === other._inner.pattern.source;
|
|
1037
1037
|
}
|
|
1038
1038
|
}
|
|
1039
1039
|
/**
|
|
@@ -1041,17 +1041,17 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1041
1041
|
*/
|
|
1042
1042
|
hashCode() {
|
|
1043
1043
|
let hash = 0;
|
|
1044
|
-
switch (this
|
|
1044
|
+
switch (this._inner.variant) {
|
|
1045
1045
|
case "Any":
|
|
1046
1046
|
hash = 1;
|
|
1047
1047
|
break;
|
|
1048
1048
|
case "Value": {
|
|
1049
|
-
const val = this
|
|
1049
|
+
const val = this._inner.value;
|
|
1050
1050
|
for (const byte of val) hash = hash * 31 + byte;
|
|
1051
1051
|
break;
|
|
1052
1052
|
}
|
|
1053
1053
|
case "BinaryRegex":
|
|
1054
|
-
hash = 93 + this
|
|
1054
|
+
hash = 93 + this._inner.pattern.source.length;
|
|
1055
1055
|
break;
|
|
1056
1056
|
}
|
|
1057
1057
|
return hash;
|
|
@@ -1073,9 +1073,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1073
1073
|
* Corresponds to the Rust `DatePattern` struct in date_pattern.rs
|
|
1074
1074
|
*/
|
|
1075
1075
|
var DatePattern = class DatePattern {
|
|
1076
|
-
|
|
1076
|
+
_inner;
|
|
1077
1077
|
constructor(inner) {
|
|
1078
|
-
this
|
|
1078
|
+
this._inner = inner;
|
|
1079
1079
|
}
|
|
1080
1080
|
/**
|
|
1081
1081
|
* Creates a new DatePattern that matches any date.
|
|
@@ -1086,8 +1086,8 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1086
1086
|
/**
|
|
1087
1087
|
* Creates a new DatePattern that matches the specific date.
|
|
1088
1088
|
*/
|
|
1089
|
-
static value(date
|
|
1090
|
-
return new DatePattern((0, _bcts_dcbor_pattern.datePatternValue)(date
|
|
1089
|
+
static value(date) {
|
|
1090
|
+
return new DatePattern((0, _bcts_dcbor_pattern.datePatternValue)(date));
|
|
1091
1091
|
}
|
|
1092
1092
|
/**
|
|
1093
1093
|
* Creates a new DatePattern that matches dates within a range (inclusive).
|
|
@@ -1098,14 +1098,14 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1098
1098
|
/**
|
|
1099
1099
|
* Creates a new DatePattern that matches dates on or after the specified date.
|
|
1100
1100
|
*/
|
|
1101
|
-
static earliest(date
|
|
1102
|
-
return new DatePattern((0, _bcts_dcbor_pattern.datePatternEarliest)(date
|
|
1101
|
+
static earliest(date) {
|
|
1102
|
+
return new DatePattern((0, _bcts_dcbor_pattern.datePatternEarliest)(date));
|
|
1103
1103
|
}
|
|
1104
1104
|
/**
|
|
1105
1105
|
* Creates a new DatePattern that matches dates on or before the specified date.
|
|
1106
1106
|
*/
|
|
1107
|
-
static latest(date
|
|
1108
|
-
return new DatePattern((0, _bcts_dcbor_pattern.datePatternLatest)(date
|
|
1107
|
+
static latest(date) {
|
|
1108
|
+
return new DatePattern((0, _bcts_dcbor_pattern.datePatternLatest)(date));
|
|
1109
1109
|
}
|
|
1110
1110
|
/**
|
|
1111
1111
|
* Creates a new DatePattern that matches dates by their ISO-8601 string representation.
|
|
@@ -1130,12 +1130,12 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1130
1130
|
* Gets the underlying dcbor-pattern DatePattern.
|
|
1131
1131
|
*/
|
|
1132
1132
|
get inner() {
|
|
1133
|
-
return this
|
|
1133
|
+
return this._inner;
|
|
1134
1134
|
}
|
|
1135
1135
|
pathsWithCaptures(haystack) {
|
|
1136
1136
|
const cbor = haystack.asLeaf();
|
|
1137
1137
|
if (cbor !== void 0) {
|
|
1138
|
-
if ((0, _bcts_dcbor_pattern.datePatternPaths)(this
|
|
1138
|
+
if ((0, _bcts_dcbor_pattern.datePatternPaths)(this._inner, cbor).length > 0) return [[[haystack]], /* @__PURE__ */ new Map()];
|
|
1139
1139
|
}
|
|
1140
1140
|
return [[], /* @__PURE__ */ new Map()];
|
|
1141
1141
|
}
|
|
@@ -1153,21 +1153,21 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1153
1153
|
return false;
|
|
1154
1154
|
}
|
|
1155
1155
|
toString() {
|
|
1156
|
-
return (0, _bcts_dcbor_pattern.datePatternDisplay)(this
|
|
1156
|
+
return (0, _bcts_dcbor_pattern.datePatternDisplay)(this._inner);
|
|
1157
1157
|
}
|
|
1158
1158
|
/**
|
|
1159
1159
|
* Equality comparison.
|
|
1160
1160
|
*/
|
|
1161
1161
|
equals(other) {
|
|
1162
|
-
if (this
|
|
1163
|
-
return JSON.stringify(this
|
|
1162
|
+
if (this._inner.variant !== other._inner.variant) return false;
|
|
1163
|
+
return JSON.stringify(this._inner) === JSON.stringify(other._inner);
|
|
1164
1164
|
}
|
|
1165
1165
|
/**
|
|
1166
1166
|
* Hash code for use in Maps/Sets.
|
|
1167
1167
|
*/
|
|
1168
1168
|
hashCode() {
|
|
1169
1169
|
let hash = 0;
|
|
1170
|
-
const str = this
|
|
1170
|
+
const str = this._inner.variant;
|
|
1171
1171
|
for (let i = 0; i < str.length; i++) hash = hash * 31 + str.charCodeAt(i);
|
|
1172
1172
|
return hash;
|
|
1173
1173
|
}
|
|
@@ -1192,9 +1192,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1192
1192
|
* Corresponds to the Rust `ArrayPattern` struct in array_pattern.rs
|
|
1193
1193
|
*/
|
|
1194
1194
|
var ArrayPattern = class ArrayPattern {
|
|
1195
|
-
|
|
1195
|
+
_pattern;
|
|
1196
1196
|
constructor(pattern) {
|
|
1197
|
-
this
|
|
1197
|
+
this._pattern = pattern;
|
|
1198
1198
|
}
|
|
1199
1199
|
/**
|
|
1200
1200
|
* Creates a new ArrayPattern that matches any array.
|
|
@@ -1242,22 +1242,22 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1242
1242
|
* Gets the pattern type.
|
|
1243
1243
|
*/
|
|
1244
1244
|
get pattern() {
|
|
1245
|
-
return this
|
|
1245
|
+
return this._pattern;
|
|
1246
1246
|
}
|
|
1247
1247
|
pathsWithCaptures(haystack) {
|
|
1248
1248
|
const cbor = haystack.asLeaf();
|
|
1249
1249
|
if (cbor === void 0) return [[], /* @__PURE__ */ new Map()];
|
|
1250
1250
|
const array = (0, _bcts_dcbor.asCborArray)(cbor);
|
|
1251
1251
|
if (array === void 0) return [[], /* @__PURE__ */ new Map()];
|
|
1252
|
-
switch (this
|
|
1252
|
+
switch (this._pattern.type) {
|
|
1253
1253
|
case "Any": return [[[haystack]], /* @__PURE__ */ new Map()];
|
|
1254
1254
|
case "Interval": {
|
|
1255
1255
|
const length = array.length;
|
|
1256
|
-
if (this
|
|
1256
|
+
if (this._pattern.interval.contains(length)) return [[[haystack]], /* @__PURE__ */ new Map()];
|
|
1257
1257
|
return [[], /* @__PURE__ */ new Map()];
|
|
1258
1258
|
}
|
|
1259
1259
|
case "DCBORPattern": {
|
|
1260
|
-
const { paths: dcborPaths, captures: dcborCaptures } = (0, _bcts_dcbor_pattern.patternPathsWithCaptures)(this
|
|
1260
|
+
const { paths: dcborPaths, captures: dcborCaptures } = (0, _bcts_dcbor_pattern.patternPathsWithCaptures)(this._pattern.pattern, cbor);
|
|
1261
1261
|
if (dcborPaths.length > 0) {
|
|
1262
1262
|
const envelopePaths = dcborPaths.map((dcborPath) => {
|
|
1263
1263
|
const envPath = [haystack];
|
|
@@ -1284,7 +1284,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1284
1284
|
return [[], /* @__PURE__ */ new Map()];
|
|
1285
1285
|
}
|
|
1286
1286
|
case "WithPatterns":
|
|
1287
|
-
if (array.length === this
|
|
1287
|
+
if (array.length === this._pattern.patterns.length) return [[[haystack]], /* @__PURE__ */ new Map()];
|
|
1288
1288
|
return [[], /* @__PURE__ */ new Map()];
|
|
1289
1289
|
}
|
|
1290
1290
|
}
|
|
@@ -1302,26 +1302,26 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1302
1302
|
return false;
|
|
1303
1303
|
}
|
|
1304
1304
|
toString() {
|
|
1305
|
-
switch (this
|
|
1305
|
+
switch (this._pattern.type) {
|
|
1306
1306
|
case "Any": return "[*]";
|
|
1307
|
-
case "Interval": return `[{${this
|
|
1308
|
-
case "DCBORPattern": return (0, _bcts_dcbor_pattern.patternDisplay)(this
|
|
1309
|
-
case "WithPatterns": return `[${this
|
|
1307
|
+
case "Interval": return `[{${this._pattern.interval.toString()}}]`;
|
|
1308
|
+
case "DCBORPattern": return (0, _bcts_dcbor_pattern.patternDisplay)(this._pattern.pattern);
|
|
1309
|
+
case "WithPatterns": return `[${this._pattern.patterns.map(String).join(", ")}]`;
|
|
1310
1310
|
}
|
|
1311
1311
|
}
|
|
1312
1312
|
/**
|
|
1313
1313
|
* Equality comparison.
|
|
1314
1314
|
*/
|
|
1315
1315
|
equals(other) {
|
|
1316
|
-
if (this
|
|
1317
|
-
switch (this
|
|
1316
|
+
if (this._pattern.type !== other._pattern.type) return false;
|
|
1317
|
+
switch (this._pattern.type) {
|
|
1318
1318
|
case "Any": return true;
|
|
1319
|
-
case "Interval": return this
|
|
1320
|
-
case "DCBORPattern": return (0, _bcts_dcbor_pattern.patternDisplay)(this
|
|
1319
|
+
case "Interval": return this._pattern.interval.equals(other._pattern.interval);
|
|
1320
|
+
case "DCBORPattern": return (0, _bcts_dcbor_pattern.patternDisplay)(this._pattern.pattern) === (0, _bcts_dcbor_pattern.patternDisplay)(other._pattern.pattern);
|
|
1321
1321
|
case "WithPatterns": {
|
|
1322
|
-
const otherPatterns = other
|
|
1323
|
-
if (this
|
|
1324
|
-
for (let i = 0; i < this
|
|
1322
|
+
const otherPatterns = other._pattern.patterns;
|
|
1323
|
+
if (this._pattern.patterns.length !== otherPatterns.length) return false;
|
|
1324
|
+
for (let i = 0; i < this._pattern.patterns.length; i++) if (this._pattern.patterns[i] !== otherPatterns[i]) return false;
|
|
1325
1325
|
return true;
|
|
1326
1326
|
}
|
|
1327
1327
|
}
|
|
@@ -1330,11 +1330,11 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1330
1330
|
* Hash code for use in Maps/Sets.
|
|
1331
1331
|
*/
|
|
1332
1332
|
hashCode() {
|
|
1333
|
-
switch (this
|
|
1333
|
+
switch (this._pattern.type) {
|
|
1334
1334
|
case "Any": return 0;
|
|
1335
|
-
case "Interval": return this
|
|
1336
|
-
case "DCBORPattern": return simpleStringHash$3((0, _bcts_dcbor_pattern.patternDisplay)(this
|
|
1337
|
-
case "WithPatterns": return this
|
|
1335
|
+
case "Interval": return this._pattern.interval.min() * 31 + (this._pattern.interval.max() ?? 0);
|
|
1336
|
+
case "DCBORPattern": return simpleStringHash$3((0, _bcts_dcbor_pattern.patternDisplay)(this._pattern.pattern));
|
|
1337
|
+
case "WithPatterns": return this._pattern.patterns.length;
|
|
1338
1338
|
}
|
|
1339
1339
|
}
|
|
1340
1340
|
};
|
|
@@ -1363,9 +1363,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1363
1363
|
* Corresponds to the Rust `MapPattern` struct in map_pattern.rs
|
|
1364
1364
|
*/
|
|
1365
1365
|
var MapPattern = class MapPattern {
|
|
1366
|
-
|
|
1366
|
+
_pattern;
|
|
1367
1367
|
constructor(pattern) {
|
|
1368
|
-
this
|
|
1368
|
+
this._pattern = pattern;
|
|
1369
1369
|
}
|
|
1370
1370
|
/**
|
|
1371
1371
|
* Creates a new MapPattern that matches any map.
|
|
@@ -1386,18 +1386,18 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1386
1386
|
* Gets the pattern type.
|
|
1387
1387
|
*/
|
|
1388
1388
|
get pattern() {
|
|
1389
|
-
return this
|
|
1389
|
+
return this._pattern;
|
|
1390
1390
|
}
|
|
1391
1391
|
pathsWithCaptures(haystack) {
|
|
1392
1392
|
const cbor = haystack.asLeaf();
|
|
1393
1393
|
if (cbor === void 0) return [[], /* @__PURE__ */ new Map()];
|
|
1394
|
-
const map
|
|
1395
|
-
if (map
|
|
1396
|
-
switch (this
|
|
1394
|
+
const map = (0, _bcts_dcbor.asCborMap)(cbor);
|
|
1395
|
+
if (map === void 0) return [[], /* @__PURE__ */ new Map()];
|
|
1396
|
+
switch (this._pattern.type) {
|
|
1397
1397
|
case "Any": return [[[haystack]], /* @__PURE__ */ new Map()];
|
|
1398
1398
|
case "Interval": {
|
|
1399
|
-
const size = map
|
|
1400
|
-
if (this
|
|
1399
|
+
const size = map.size;
|
|
1400
|
+
if (this._pattern.interval.contains(size)) return [[[haystack]], /* @__PURE__ */ new Map()];
|
|
1401
1401
|
return [[], /* @__PURE__ */ new Map()];
|
|
1402
1402
|
}
|
|
1403
1403
|
}
|
|
@@ -1416,28 +1416,28 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1416
1416
|
return false;
|
|
1417
1417
|
}
|
|
1418
1418
|
toString() {
|
|
1419
|
-
switch (this
|
|
1419
|
+
switch (this._pattern.type) {
|
|
1420
1420
|
case "Any": return "{*}";
|
|
1421
|
-
case "Interval": return `{{${this
|
|
1421
|
+
case "Interval": return `{{${this._pattern.interval.toString()}}}`;
|
|
1422
1422
|
}
|
|
1423
1423
|
}
|
|
1424
1424
|
/**
|
|
1425
1425
|
* Equality comparison.
|
|
1426
1426
|
*/
|
|
1427
1427
|
equals(other) {
|
|
1428
|
-
if (this
|
|
1429
|
-
switch (this
|
|
1428
|
+
if (this._pattern.type !== other._pattern.type) return false;
|
|
1429
|
+
switch (this._pattern.type) {
|
|
1430
1430
|
case "Any": return true;
|
|
1431
|
-
case "Interval": return this
|
|
1431
|
+
case "Interval": return this._pattern.interval.equals(other._pattern.interval);
|
|
1432
1432
|
}
|
|
1433
1433
|
}
|
|
1434
1434
|
/**
|
|
1435
1435
|
* Hash code for use in Maps/Sets.
|
|
1436
1436
|
*/
|
|
1437
1437
|
hashCode() {
|
|
1438
|
-
switch (this
|
|
1438
|
+
switch (this._pattern.type) {
|
|
1439
1439
|
case "Any": return 0;
|
|
1440
|
-
case "Interval": return this
|
|
1440
|
+
case "Interval": return this._pattern.interval.min() * 31 + (this._pattern.interval.max() ?? 0);
|
|
1441
1441
|
}
|
|
1442
1442
|
}
|
|
1443
1443
|
};
|
|
@@ -1457,9 +1457,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1457
1457
|
* Corresponds to the Rust `KnownValuePattern` struct in known_value_pattern.rs
|
|
1458
1458
|
*/
|
|
1459
1459
|
var KnownValuePattern = class KnownValuePattern {
|
|
1460
|
-
|
|
1460
|
+
_inner;
|
|
1461
1461
|
constructor(inner) {
|
|
1462
|
-
this
|
|
1462
|
+
this._inner = inner;
|
|
1463
1463
|
}
|
|
1464
1464
|
/**
|
|
1465
1465
|
* Creates a new KnownValuePattern that matches any known value.
|
|
@@ -1495,17 +1495,17 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1495
1495
|
* Gets the underlying dcbor-pattern KnownValuePattern.
|
|
1496
1496
|
*/
|
|
1497
1497
|
get inner() {
|
|
1498
|
-
return this
|
|
1498
|
+
return this._inner;
|
|
1499
1499
|
}
|
|
1500
1500
|
pathsWithCaptures(haystack) {
|
|
1501
1501
|
const envCase = haystack.case();
|
|
1502
1502
|
if (envCase.type === "knownValue") {
|
|
1503
1503
|
const knownValueCbor = envCase.value.taggedCbor();
|
|
1504
|
-
if ((0, _bcts_dcbor_pattern.knownValuePatternMatches)(this
|
|
1504
|
+
if ((0, _bcts_dcbor_pattern.knownValuePatternMatches)(this._inner, knownValueCbor)) return [[[haystack]], /* @__PURE__ */ new Map()];
|
|
1505
1505
|
}
|
|
1506
|
-
const leafCbor
|
|
1507
|
-
if (leafCbor
|
|
1508
|
-
if ((0, _bcts_dcbor_pattern.knownValuePatternMatches)(this
|
|
1506
|
+
const leafCbor = haystack.asLeaf();
|
|
1507
|
+
if (leafCbor !== void 0) {
|
|
1508
|
+
if ((0, _bcts_dcbor_pattern.knownValuePatternMatches)(this._inner, leafCbor)) return [[[haystack]], /* @__PURE__ */ new Map()];
|
|
1509
1509
|
}
|
|
1510
1510
|
return [[], /* @__PURE__ */ new Map()];
|
|
1511
1511
|
}
|
|
@@ -1523,29 +1523,29 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1523
1523
|
return false;
|
|
1524
1524
|
}
|
|
1525
1525
|
toString() {
|
|
1526
|
-
return (0, _bcts_dcbor_pattern.knownValuePatternDisplay)(this
|
|
1526
|
+
return (0, _bcts_dcbor_pattern.knownValuePatternDisplay)(this._inner);
|
|
1527
1527
|
}
|
|
1528
1528
|
/**
|
|
1529
1529
|
* Equality comparison.
|
|
1530
1530
|
*/
|
|
1531
1531
|
equals(other) {
|
|
1532
|
-
if (this
|
|
1533
|
-
switch (this
|
|
1532
|
+
if (this._inner.variant !== other._inner.variant) return false;
|
|
1533
|
+
switch (this._inner.variant) {
|
|
1534
1534
|
case "Any": return true;
|
|
1535
|
-
case "Value": return this
|
|
1536
|
-
case "Named": return this
|
|
1537
|
-
case "Regex": return this
|
|
1535
|
+
case "Value": return this._inner.value.valueBigInt() === other._inner.value.valueBigInt();
|
|
1536
|
+
case "Named": return this._inner.name === other._inner.name;
|
|
1537
|
+
case "Regex": return this._inner.pattern.source === other._inner.pattern.source;
|
|
1538
1538
|
}
|
|
1539
1539
|
}
|
|
1540
1540
|
/**
|
|
1541
1541
|
* Hash code for use in Maps/Sets.
|
|
1542
1542
|
*/
|
|
1543
1543
|
hashCode() {
|
|
1544
|
-
switch (this
|
|
1544
|
+
switch (this._inner.variant) {
|
|
1545
1545
|
case "Any": return 0;
|
|
1546
|
-
case "Value": return Number(this
|
|
1547
|
-
case "Named": return simpleStringHash$2(this
|
|
1548
|
-
case "Regex": return simpleStringHash$2(this
|
|
1546
|
+
case "Value": return Number(this._inner.value.valueBigInt() & BigInt(4294967295));
|
|
1547
|
+
case "Named": return simpleStringHash$2(this._inner.name);
|
|
1548
|
+
case "Regex": return simpleStringHash$2(this._inner.pattern.source);
|
|
1549
1549
|
}
|
|
1550
1550
|
}
|
|
1551
1551
|
};
|
|
@@ -1584,9 +1584,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1584
1584
|
* Corresponds to the Rust `TaggedPattern` struct in tagged_pattern.rs
|
|
1585
1585
|
*/
|
|
1586
1586
|
var TaggedPattern = class TaggedPattern {
|
|
1587
|
-
|
|
1587
|
+
_inner;
|
|
1588
1588
|
constructor(inner) {
|
|
1589
|
-
this
|
|
1589
|
+
this._inner = inner;
|
|
1590
1590
|
}
|
|
1591
1591
|
/**
|
|
1592
1592
|
* Creates a new TaggedPattern that matches any tagged value.
|
|
@@ -1622,12 +1622,12 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1622
1622
|
* Gets the underlying dcbor-pattern TaggedPattern.
|
|
1623
1623
|
*/
|
|
1624
1624
|
get inner() {
|
|
1625
|
-
return this
|
|
1625
|
+
return this._inner;
|
|
1626
1626
|
}
|
|
1627
1627
|
pathsWithCaptures(haystack) {
|
|
1628
1628
|
const cbor = haystack.subject().asLeaf();
|
|
1629
1629
|
if (cbor !== void 0) {
|
|
1630
|
-
const [dcborPaths, dcborCaptures] = (0, _bcts_dcbor_pattern.taggedPatternPathsWithCaptures)(this
|
|
1630
|
+
const [dcborPaths, dcborCaptures] = (0, _bcts_dcbor_pattern.taggedPatternPathsWithCaptures)(this._inner, cbor);
|
|
1631
1631
|
if (dcborPaths.length > 0) {
|
|
1632
1632
|
const envelopePaths = dcborPaths.map((dcborPath) => {
|
|
1633
1633
|
const envPath = [haystack];
|
|
@@ -1668,26 +1668,26 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1668
1668
|
return false;
|
|
1669
1669
|
}
|
|
1670
1670
|
toString() {
|
|
1671
|
-
return (0, _bcts_dcbor_pattern.taggedPatternDisplay)(this
|
|
1671
|
+
return (0, _bcts_dcbor_pattern.taggedPatternDisplay)(this._inner, _bcts_dcbor_pattern.patternDisplay);
|
|
1672
1672
|
}
|
|
1673
1673
|
/**
|
|
1674
1674
|
* Equality comparison.
|
|
1675
1675
|
*/
|
|
1676
1676
|
equals(other) {
|
|
1677
|
-
if (this
|
|
1678
|
-
switch (this
|
|
1677
|
+
if (this._inner.variant !== other._inner.variant) return false;
|
|
1678
|
+
switch (this._inner.variant) {
|
|
1679
1679
|
case "Any": return true;
|
|
1680
1680
|
case "Tag": {
|
|
1681
|
-
const otherTag = other
|
|
1682
|
-
return this
|
|
1681
|
+
const otherTag = other._inner;
|
|
1682
|
+
return this._inner.tag.value === otherTag.tag.value && (0, _bcts_dcbor_pattern.patternDisplay)(this._inner.pattern) === (0, _bcts_dcbor_pattern.patternDisplay)(otherTag.pattern);
|
|
1683
1683
|
}
|
|
1684
1684
|
case "Name": {
|
|
1685
|
-
const otherName = other
|
|
1686
|
-
return this
|
|
1685
|
+
const otherName = other._inner;
|
|
1686
|
+
return this._inner.name === otherName.name && (0, _bcts_dcbor_pattern.patternDisplay)(this._inner.pattern) === (0, _bcts_dcbor_pattern.patternDisplay)(otherName.pattern);
|
|
1687
1687
|
}
|
|
1688
1688
|
case "Regex": {
|
|
1689
|
-
const otherRegex = other
|
|
1690
|
-
return this
|
|
1689
|
+
const otherRegex = other._inner;
|
|
1690
|
+
return this._inner.regex.source === otherRegex.regex.source && (0, _bcts_dcbor_pattern.patternDisplay)(this._inner.pattern) === (0, _bcts_dcbor_pattern.patternDisplay)(otherRegex.pattern);
|
|
1691
1691
|
}
|
|
1692
1692
|
}
|
|
1693
1693
|
}
|
|
@@ -1695,11 +1695,11 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1695
1695
|
* Hash code for use in Maps/Sets.
|
|
1696
1696
|
*/
|
|
1697
1697
|
hashCode() {
|
|
1698
|
-
switch (this
|
|
1698
|
+
switch (this._inner.variant) {
|
|
1699
1699
|
case "Any": return 0;
|
|
1700
|
-
case "Tag": return Number(BigInt(this
|
|
1701
|
-
case "Name": return simpleStringHash$1(this
|
|
1702
|
-
case "Regex": return simpleStringHash$1(this
|
|
1700
|
+
case "Tag": return Number(BigInt(this._inner.tag.value) & BigInt(4294967295));
|
|
1701
|
+
case "Name": return simpleStringHash$1(this._inner.name);
|
|
1702
|
+
case "Regex": return simpleStringHash$1(this._inner.regex.source);
|
|
1703
1703
|
}
|
|
1704
1704
|
}
|
|
1705
1705
|
};
|
|
@@ -1735,9 +1735,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1735
1735
|
* Corresponds to the Rust `CBORPattern` enum in cbor_pattern.rs
|
|
1736
1736
|
*/
|
|
1737
1737
|
var CBORPattern = class CBORPattern {
|
|
1738
|
-
|
|
1738
|
+
_pattern;
|
|
1739
1739
|
constructor(pattern) {
|
|
1740
|
-
this
|
|
1740
|
+
this._pattern = pattern;
|
|
1741
1741
|
}
|
|
1742
1742
|
/**
|
|
1743
1743
|
* Creates a new CBORPattern that matches any CBOR value.
|
|
@@ -1776,15 +1776,15 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1776
1776
|
* Gets the pattern type.
|
|
1777
1777
|
*/
|
|
1778
1778
|
get pattern() {
|
|
1779
|
-
return this
|
|
1779
|
+
return this._pattern;
|
|
1780
1780
|
}
|
|
1781
1781
|
/**
|
|
1782
1782
|
* Convert dcbor captures to envelope captures.
|
|
1783
1783
|
*/
|
|
1784
|
-
|
|
1784
|
+
_convertDcborCapturesToEnvelopeCaptures(dcborCaptures, baseEnvelope, baseCbor) {
|
|
1785
1785
|
const envelopeCaptures = /* @__PURE__ */ new Map();
|
|
1786
1786
|
for (const [captureName, dcborCapturePaths] of dcborCaptures) {
|
|
1787
|
-
const envelopeCapturePaths = dcborCapturePaths.map((dcborPath) => this
|
|
1787
|
+
const envelopeCapturePaths = dcborCapturePaths.map((dcborPath) => this._convertDcborPathToEnvelopePath(dcborPath, baseEnvelope, baseCbor));
|
|
1788
1788
|
envelopeCaptures.set(captureName, envelopeCapturePaths);
|
|
1789
1789
|
}
|
|
1790
1790
|
return envelopeCaptures;
|
|
@@ -1792,7 +1792,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1792
1792
|
/**
|
|
1793
1793
|
* Convert a single dcbor path to an envelope path.
|
|
1794
1794
|
*/
|
|
1795
|
-
|
|
1795
|
+
_convertDcborPathToEnvelopePath(dcborPath, baseEnvelope, baseCbor) {
|
|
1796
1796
|
const envelopePath = [baseEnvelope];
|
|
1797
1797
|
const elementsToAdd = dcborPath.length > 0 && dcborPath[0]?.toDiagnostic() === baseCbor.toDiagnostic() ? dcborPath.slice(1) : dcborPath;
|
|
1798
1798
|
for (const cborElement of elementsToAdd) envelopePath.push(_bcts_envelope.Envelope.newLeaf(cborElement));
|
|
@@ -1801,7 +1801,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1801
1801
|
/**
|
|
1802
1802
|
* Collect capture names from a dcbor pattern.
|
|
1803
1803
|
*/
|
|
1804
|
-
|
|
1804
|
+
_collectDcborCaptureNames(dcborPattern, names) {
|
|
1805
1805
|
const patternStr = (0, _bcts_dcbor_pattern.patternDisplay)(dcborPattern);
|
|
1806
1806
|
let i = 0;
|
|
1807
1807
|
while (i < patternStr.length) if (patternStr[i] === "@") {
|
|
@@ -1818,13 +1818,13 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1818
1818
|
const envCase = haystack.case();
|
|
1819
1819
|
if (envCase.type === "knownValue") {
|
|
1820
1820
|
const knownValueCbor = envCase.value.taggedCbor();
|
|
1821
|
-
switch (this
|
|
1821
|
+
switch (this._pattern.type) {
|
|
1822
1822
|
case "Any": return [[[haystack]], /* @__PURE__ */ new Map()];
|
|
1823
1823
|
case "Value":
|
|
1824
|
-
if (knownValueCbor.toDiagnostic() === this
|
|
1824
|
+
if (knownValueCbor.toDiagnostic() === this._pattern.cbor.toDiagnostic()) return [[[haystack]], /* @__PURE__ */ new Map()];
|
|
1825
1825
|
return [[], /* @__PURE__ */ new Map()];
|
|
1826
1826
|
case "Pattern": {
|
|
1827
|
-
const { paths: dcborPaths, captures: dcborCaptures } = (0, _bcts_dcbor_pattern.patternPathsWithCaptures)(this
|
|
1827
|
+
const { paths: dcborPaths, captures: dcborCaptures } = (0, _bcts_dcbor_pattern.patternPathsWithCaptures)(this._pattern.pattern, knownValueCbor);
|
|
1828
1828
|
if (dcborPaths.length > 0) {
|
|
1829
1829
|
const basePath = [haystack];
|
|
1830
1830
|
return [dcborPaths.map((dcborPath) => {
|
|
@@ -1834,29 +1834,29 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1834
1834
|
if (elem !== void 0) extendedPath.push(_bcts_envelope.Envelope.newLeaf(elem));
|
|
1835
1835
|
}
|
|
1836
1836
|
return extendedPath;
|
|
1837
|
-
}), this
|
|
1837
|
+
}), this._convertDcborCapturesToEnvelopeCaptures(dcborCaptures, haystack, knownValueCbor)];
|
|
1838
1838
|
}
|
|
1839
1839
|
return [[], /* @__PURE__ */ new Map()];
|
|
1840
1840
|
}
|
|
1841
1841
|
}
|
|
1842
1842
|
}
|
|
1843
|
-
const leafCbor
|
|
1844
|
-
if (leafCbor
|
|
1845
|
-
switch (this
|
|
1843
|
+
const leafCbor = haystack.asLeaf();
|
|
1844
|
+
if (leafCbor === void 0) return [[], /* @__PURE__ */ new Map()];
|
|
1845
|
+
switch (this._pattern.type) {
|
|
1846
1846
|
case "Any": return [[[haystack]], /* @__PURE__ */ new Map()];
|
|
1847
1847
|
case "Value":
|
|
1848
|
-
if (leafCbor
|
|
1848
|
+
if (leafCbor.toDiagnostic() === this._pattern.cbor.toDiagnostic()) return [[[haystack]], /* @__PURE__ */ new Map()];
|
|
1849
1849
|
return [[], /* @__PURE__ */ new Map()];
|
|
1850
1850
|
case "Pattern": {
|
|
1851
|
-
const { paths: dcborPaths, captures: dcborCaptures } = (0, _bcts_dcbor_pattern.patternPathsWithCaptures)(this
|
|
1851
|
+
const { paths: dcborPaths, captures: dcborCaptures } = (0, _bcts_dcbor_pattern.patternPathsWithCaptures)(this._pattern.pattern, leafCbor);
|
|
1852
1852
|
if (dcborPaths.length > 0) {
|
|
1853
1853
|
const basePath = [haystack];
|
|
1854
1854
|
return [dcborPaths.map((dcborPath) => {
|
|
1855
1855
|
const extendedPath = [...basePath];
|
|
1856
|
-
const elementsToAdd = dcborPath.length > 0 && dcborPath[0]?.toDiagnostic() === leafCbor
|
|
1856
|
+
const elementsToAdd = dcborPath.length > 0 && dcborPath[0]?.toDiagnostic() === leafCbor.toDiagnostic() ? dcborPath.slice(1) : dcborPath;
|
|
1857
1857
|
for (const cborElement of elementsToAdd) extendedPath.push(_bcts_envelope.Envelope.newLeaf(cborElement));
|
|
1858
1858
|
return extendedPath;
|
|
1859
|
-
}), this
|
|
1859
|
+
}), this._convertDcborCapturesToEnvelopeCaptures(dcborCaptures, haystack, leafCbor)];
|
|
1860
1860
|
}
|
|
1861
1861
|
return [[], /* @__PURE__ */ new Map()];
|
|
1862
1862
|
}
|
|
@@ -1869,9 +1869,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1869
1869
|
return this.paths(haystack).length > 0;
|
|
1870
1870
|
}
|
|
1871
1871
|
compile(code, literals, captures) {
|
|
1872
|
-
if (this
|
|
1872
|
+
if (this._pattern.type === "Pattern") {
|
|
1873
1873
|
const captureNames = [];
|
|
1874
|
-
this
|
|
1874
|
+
this._collectDcborCaptureNames(this._pattern.pattern, captureNames);
|
|
1875
1875
|
for (const name of captureNames) if (!captures.includes(name)) captures.push(name);
|
|
1876
1876
|
}
|
|
1877
1877
|
if (createLeafCBORPattern === void 0) throw new Error("CBORPattern factory not registered");
|
|
@@ -1881,31 +1881,31 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
1881
1881
|
return false;
|
|
1882
1882
|
}
|
|
1883
1883
|
toString() {
|
|
1884
|
-
switch (this
|
|
1884
|
+
switch (this._pattern.type) {
|
|
1885
1885
|
case "Any": return "cbor";
|
|
1886
|
-
case "Value": return `cbor(${this
|
|
1887
|
-
case "Pattern": return `cbor(/${(0, _bcts_dcbor_pattern.patternDisplay)(this
|
|
1886
|
+
case "Value": return `cbor(${this._pattern.cbor.toDiagnostic()})`;
|
|
1887
|
+
case "Pattern": return `cbor(/${(0, _bcts_dcbor_pattern.patternDisplay)(this._pattern.pattern)}/)`;
|
|
1888
1888
|
}
|
|
1889
1889
|
}
|
|
1890
1890
|
/**
|
|
1891
1891
|
* Equality comparison.
|
|
1892
1892
|
*/
|
|
1893
1893
|
equals(other) {
|
|
1894
|
-
if (this
|
|
1895
|
-
switch (this
|
|
1894
|
+
if (this._pattern.type !== other._pattern.type) return false;
|
|
1895
|
+
switch (this._pattern.type) {
|
|
1896
1896
|
case "Any": return true;
|
|
1897
|
-
case "Value": return this
|
|
1898
|
-
case "Pattern": return (0, _bcts_dcbor_pattern.patternDisplay)(this
|
|
1897
|
+
case "Value": return this._pattern.cbor.toDiagnostic() === other._pattern.cbor.toDiagnostic();
|
|
1898
|
+
case "Pattern": return (0, _bcts_dcbor_pattern.patternDisplay)(this._pattern.pattern) === (0, _bcts_dcbor_pattern.patternDisplay)(other._pattern.pattern);
|
|
1899
1899
|
}
|
|
1900
1900
|
}
|
|
1901
1901
|
/**
|
|
1902
1902
|
* Hash code for use in Maps/Sets.
|
|
1903
1903
|
*/
|
|
1904
1904
|
hashCode() {
|
|
1905
|
-
switch (this
|
|
1905
|
+
switch (this._pattern.type) {
|
|
1906
1906
|
case "Any": return 0;
|
|
1907
|
-
case "Value": return simpleStringHash(this
|
|
1908
|
-
case "Pattern": return simpleStringHash((0, _bcts_dcbor_pattern.patternDisplay)(this
|
|
1907
|
+
case "Value": return simpleStringHash(this._pattern.cbor.toDiagnostic());
|
|
1908
|
+
case "Pattern": return simpleStringHash((0, _bcts_dcbor_pattern.patternDisplay)(this._pattern.pattern));
|
|
1909
1909
|
}
|
|
1910
1910
|
}
|
|
1911
1911
|
};
|
|
@@ -2188,9 +2188,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2188
2188
|
* Corresponds to the Rust `SubjectPattern` enum in subject_pattern.rs
|
|
2189
2189
|
*/
|
|
2190
2190
|
var SubjectPattern = class SubjectPattern {
|
|
2191
|
-
|
|
2191
|
+
_pattern;
|
|
2192
2192
|
constructor(pattern) {
|
|
2193
|
-
this
|
|
2193
|
+
this._pattern = pattern;
|
|
2194
2194
|
}
|
|
2195
2195
|
/**
|
|
2196
2196
|
* Creates a new SubjectPattern that matches any subject.
|
|
@@ -2211,23 +2211,23 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2211
2211
|
* Gets the pattern type.
|
|
2212
2212
|
*/
|
|
2213
2213
|
get patternType() {
|
|
2214
|
-
return this
|
|
2214
|
+
return this._pattern;
|
|
2215
2215
|
}
|
|
2216
2216
|
/**
|
|
2217
2217
|
* Gets the inner pattern if this is a Pattern type, undefined otherwise.
|
|
2218
2218
|
*/
|
|
2219
2219
|
innerPattern() {
|
|
2220
|
-
return this
|
|
2220
|
+
return this._pattern.type === "Pattern" ? this._pattern.pattern : void 0;
|
|
2221
2221
|
}
|
|
2222
2222
|
pathsWithCaptures(haystack) {
|
|
2223
|
-
const subject
|
|
2223
|
+
const subject = haystack.subject();
|
|
2224
2224
|
let paths;
|
|
2225
|
-
switch (this
|
|
2225
|
+
switch (this._pattern.type) {
|
|
2226
2226
|
case "Any":
|
|
2227
|
-
paths = [[subject
|
|
2227
|
+
paths = [[subject]];
|
|
2228
2228
|
break;
|
|
2229
2229
|
case "Pattern":
|
|
2230
|
-
if (this
|
|
2230
|
+
if (this._pattern.pattern.matches(subject)) paths = [[subject]];
|
|
2231
2231
|
else paths = [];
|
|
2232
2232
|
break;
|
|
2233
2233
|
}
|
|
@@ -2240,14 +2240,14 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2240
2240
|
return this.paths(haystack).length > 0;
|
|
2241
2241
|
}
|
|
2242
2242
|
compile(code, literals, captures) {
|
|
2243
|
-
switch (this
|
|
2243
|
+
switch (this._pattern.type) {
|
|
2244
2244
|
case "Any":
|
|
2245
2245
|
code.push({ type: "NavigateSubject" });
|
|
2246
2246
|
break;
|
|
2247
2247
|
case "Pattern":
|
|
2248
2248
|
code.push({ type: "NavigateSubject" });
|
|
2249
2249
|
code.push({ type: "ExtendTraversal" });
|
|
2250
|
-
this
|
|
2250
|
+
this._pattern.pattern.compile(code, literals, captures);
|
|
2251
2251
|
code.push({ type: "CombineTraversal" });
|
|
2252
2252
|
break;
|
|
2253
2253
|
}
|
|
@@ -2256,24 +2256,24 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2256
2256
|
return false;
|
|
2257
2257
|
}
|
|
2258
2258
|
toString() {
|
|
2259
|
-
switch (this
|
|
2259
|
+
switch (this._pattern.type) {
|
|
2260
2260
|
case "Any": return "subj";
|
|
2261
|
-
case "Pattern": return `subj(${this
|
|
2261
|
+
case "Pattern": return `subj(${this._pattern.pattern.toString()})`;
|
|
2262
2262
|
}
|
|
2263
2263
|
}
|
|
2264
2264
|
/**
|
|
2265
2265
|
* Equality comparison.
|
|
2266
2266
|
*/
|
|
2267
2267
|
equals(other) {
|
|
2268
|
-
if (this
|
|
2269
|
-
if (this
|
|
2270
|
-
return this
|
|
2268
|
+
if (this._pattern.type !== other._pattern.type) return false;
|
|
2269
|
+
if (this._pattern.type === "Any") return true;
|
|
2270
|
+
return this._pattern.pattern === other._pattern.pattern;
|
|
2271
2271
|
}
|
|
2272
2272
|
/**
|
|
2273
2273
|
* Hash code for use in Maps/Sets.
|
|
2274
2274
|
*/
|
|
2275
2275
|
hashCode() {
|
|
2276
|
-
return this
|
|
2276
|
+
return this._pattern.type === "Any" ? 0 : 1;
|
|
2277
2277
|
}
|
|
2278
2278
|
};
|
|
2279
2279
|
|
|
@@ -2289,9 +2289,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2289
2289
|
* Corresponds to the Rust `PredicatePattern` enum in predicate_pattern.rs
|
|
2290
2290
|
*/
|
|
2291
2291
|
var PredicatePattern = class PredicatePattern {
|
|
2292
|
-
|
|
2292
|
+
_pattern;
|
|
2293
2293
|
constructor(pattern) {
|
|
2294
|
-
this
|
|
2294
|
+
this._pattern = pattern;
|
|
2295
2295
|
}
|
|
2296
2296
|
/**
|
|
2297
2297
|
* Creates a new PredicatePattern that matches any predicate.
|
|
@@ -2312,24 +2312,24 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2312
2312
|
* Gets the pattern type.
|
|
2313
2313
|
*/
|
|
2314
2314
|
get patternType() {
|
|
2315
|
-
return this
|
|
2315
|
+
return this._pattern;
|
|
2316
2316
|
}
|
|
2317
2317
|
/**
|
|
2318
2318
|
* Gets the inner pattern if this is a Pattern type, undefined otherwise.
|
|
2319
2319
|
*/
|
|
2320
2320
|
innerPattern() {
|
|
2321
|
-
return this
|
|
2321
|
+
return this._pattern.type === "Pattern" ? this._pattern.pattern : void 0;
|
|
2322
2322
|
}
|
|
2323
2323
|
pathsWithCaptures(haystack) {
|
|
2324
|
-
const predicate
|
|
2325
|
-
if (predicate
|
|
2324
|
+
const predicate = haystack.asPredicate?.();
|
|
2325
|
+
if (predicate === void 0) return [[], /* @__PURE__ */ new Map()];
|
|
2326
2326
|
let paths;
|
|
2327
|
-
switch (this
|
|
2327
|
+
switch (this._pattern.type) {
|
|
2328
2328
|
case "Any":
|
|
2329
|
-
paths = [[predicate
|
|
2329
|
+
paths = [[predicate]];
|
|
2330
2330
|
break;
|
|
2331
2331
|
case "Pattern":
|
|
2332
|
-
if (this
|
|
2332
|
+
if (this._pattern.pattern.matches(predicate)) paths = [[predicate]];
|
|
2333
2333
|
else paths = [];
|
|
2334
2334
|
break;
|
|
2335
2335
|
}
|
|
@@ -2354,24 +2354,24 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2354
2354
|
return false;
|
|
2355
2355
|
}
|
|
2356
2356
|
toString() {
|
|
2357
|
-
switch (this
|
|
2357
|
+
switch (this._pattern.type) {
|
|
2358
2358
|
case "Any": return "pred";
|
|
2359
|
-
case "Pattern": return `pred(${this
|
|
2359
|
+
case "Pattern": return `pred(${this._pattern.pattern.toString()})`;
|
|
2360
2360
|
}
|
|
2361
2361
|
}
|
|
2362
2362
|
/**
|
|
2363
2363
|
* Equality comparison.
|
|
2364
2364
|
*/
|
|
2365
2365
|
equals(other) {
|
|
2366
|
-
if (this
|
|
2367
|
-
if (this
|
|
2368
|
-
return this
|
|
2366
|
+
if (this._pattern.type !== other._pattern.type) return false;
|
|
2367
|
+
if (this._pattern.type === "Any") return true;
|
|
2368
|
+
return this._pattern.pattern === other._pattern.pattern;
|
|
2369
2369
|
}
|
|
2370
2370
|
/**
|
|
2371
2371
|
* Hash code for use in Maps/Sets.
|
|
2372
2372
|
*/
|
|
2373
2373
|
hashCode() {
|
|
2374
|
-
return this
|
|
2374
|
+
return this._pattern.type === "Any" ? 0 : 1;
|
|
2375
2375
|
}
|
|
2376
2376
|
};
|
|
2377
2377
|
|
|
@@ -2387,9 +2387,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2387
2387
|
* Corresponds to the Rust `ObjectPattern` enum in object_pattern.rs
|
|
2388
2388
|
*/
|
|
2389
2389
|
var ObjectPattern = class ObjectPattern {
|
|
2390
|
-
|
|
2390
|
+
_pattern;
|
|
2391
2391
|
constructor(pattern) {
|
|
2392
|
-
this
|
|
2392
|
+
this._pattern = pattern;
|
|
2393
2393
|
}
|
|
2394
2394
|
/**
|
|
2395
2395
|
* Creates a new ObjectPattern that matches any object.
|
|
@@ -2410,24 +2410,24 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2410
2410
|
* Gets the pattern type.
|
|
2411
2411
|
*/
|
|
2412
2412
|
get patternType() {
|
|
2413
|
-
return this
|
|
2413
|
+
return this._pattern;
|
|
2414
2414
|
}
|
|
2415
2415
|
/**
|
|
2416
2416
|
* Gets the inner pattern if this is a Pattern type, undefined otherwise.
|
|
2417
2417
|
*/
|
|
2418
2418
|
innerPattern() {
|
|
2419
|
-
return this
|
|
2419
|
+
return this._pattern.type === "Pattern" ? this._pattern.pattern : void 0;
|
|
2420
2420
|
}
|
|
2421
2421
|
pathsWithCaptures(haystack) {
|
|
2422
|
-
const object
|
|
2423
|
-
if (object
|
|
2422
|
+
const object = haystack.asObject?.();
|
|
2423
|
+
if (object === void 0) return [[], /* @__PURE__ */ new Map()];
|
|
2424
2424
|
let paths;
|
|
2425
|
-
switch (this
|
|
2425
|
+
switch (this._pattern.type) {
|
|
2426
2426
|
case "Any":
|
|
2427
|
-
paths = [[object
|
|
2427
|
+
paths = [[object]];
|
|
2428
2428
|
break;
|
|
2429
2429
|
case "Pattern":
|
|
2430
|
-
if (this
|
|
2430
|
+
if (this._pattern.pattern.matches(object)) paths = [[object]];
|
|
2431
2431
|
else paths = [];
|
|
2432
2432
|
break;
|
|
2433
2433
|
}
|
|
@@ -2452,24 +2452,24 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2452
2452
|
return false;
|
|
2453
2453
|
}
|
|
2454
2454
|
toString() {
|
|
2455
|
-
switch (this
|
|
2455
|
+
switch (this._pattern.type) {
|
|
2456
2456
|
case "Any": return "obj";
|
|
2457
|
-
case "Pattern": return `obj(${this
|
|
2457
|
+
case "Pattern": return `obj(${this._pattern.pattern.toString()})`;
|
|
2458
2458
|
}
|
|
2459
2459
|
}
|
|
2460
2460
|
/**
|
|
2461
2461
|
* Equality comparison.
|
|
2462
2462
|
*/
|
|
2463
2463
|
equals(other) {
|
|
2464
|
-
if (this
|
|
2465
|
-
if (this
|
|
2466
|
-
return this
|
|
2464
|
+
if (this._pattern.type !== other._pattern.type) return false;
|
|
2465
|
+
if (this._pattern.type === "Any") return true;
|
|
2466
|
+
return this._pattern.pattern === other._pattern.pattern;
|
|
2467
2467
|
}
|
|
2468
2468
|
/**
|
|
2469
2469
|
* Hash code for use in Maps/Sets.
|
|
2470
2470
|
*/
|
|
2471
2471
|
hashCode() {
|
|
2472
|
-
return this
|
|
2472
|
+
return this._pattern.type === "Any" ? 0 : 1;
|
|
2473
2473
|
}
|
|
2474
2474
|
};
|
|
2475
2475
|
|
|
@@ -2485,9 +2485,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2485
2485
|
* Corresponds to the Rust `AssertionsPattern` enum in assertions_pattern.rs
|
|
2486
2486
|
*/
|
|
2487
2487
|
var AssertionsPattern = class AssertionsPattern {
|
|
2488
|
-
|
|
2488
|
+
_pattern;
|
|
2489
2489
|
constructor(pattern) {
|
|
2490
|
-
this
|
|
2490
|
+
this._pattern = pattern;
|
|
2491
2491
|
}
|
|
2492
2492
|
/**
|
|
2493
2493
|
* Creates a new AssertionsPattern that matches any assertion.
|
|
@@ -2530,49 +2530,49 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2530
2530
|
* Gets the pattern type.
|
|
2531
2531
|
*/
|
|
2532
2532
|
get patternType() {
|
|
2533
|
-
return this
|
|
2533
|
+
return this._pattern;
|
|
2534
2534
|
}
|
|
2535
2535
|
/**
|
|
2536
2536
|
* Gets the predicate pattern if this has one, undefined otherwise.
|
|
2537
2537
|
*/
|
|
2538
2538
|
predicatePattern() {
|
|
2539
|
-
if (this
|
|
2540
|
-
if (this
|
|
2539
|
+
if (this._pattern.type === "WithPredicate") return this._pattern.pattern;
|
|
2540
|
+
if (this._pattern.type === "WithBoth") return this._pattern.predicatePattern;
|
|
2541
2541
|
}
|
|
2542
2542
|
/**
|
|
2543
2543
|
* Gets the object pattern if this has one, undefined otherwise.
|
|
2544
2544
|
*/
|
|
2545
2545
|
objectPattern() {
|
|
2546
|
-
if (this
|
|
2547
|
-
if (this
|
|
2546
|
+
if (this._pattern.type === "WithObject") return this._pattern.pattern;
|
|
2547
|
+
if (this._pattern.type === "WithBoth") return this._pattern.objectPattern;
|
|
2548
2548
|
}
|
|
2549
2549
|
pathsWithCaptures(haystack) {
|
|
2550
2550
|
const paths = [];
|
|
2551
|
-
for (const assertion of haystack.assertions()) switch (this
|
|
2551
|
+
for (const assertion of haystack.assertions()) switch (this._pattern.type) {
|
|
2552
2552
|
case "Any":
|
|
2553
2553
|
paths.push([assertion]);
|
|
2554
2554
|
break;
|
|
2555
2555
|
case "WithPredicate": {
|
|
2556
|
-
const predicate
|
|
2557
|
-
if (predicate
|
|
2558
|
-
if (this
|
|
2556
|
+
const predicate = assertion.asPredicate?.();
|
|
2557
|
+
if (predicate !== void 0) {
|
|
2558
|
+
if (this._pattern.pattern.matches(predicate)) paths.push([assertion]);
|
|
2559
2559
|
}
|
|
2560
2560
|
break;
|
|
2561
2561
|
}
|
|
2562
2562
|
case "WithObject": {
|
|
2563
|
-
const object
|
|
2564
|
-
if (object
|
|
2565
|
-
if (this
|
|
2563
|
+
const object = assertion.asObject?.();
|
|
2564
|
+
if (object !== void 0) {
|
|
2565
|
+
if (this._pattern.pattern.matches(object)) paths.push([assertion]);
|
|
2566
2566
|
}
|
|
2567
2567
|
break;
|
|
2568
2568
|
}
|
|
2569
2569
|
case "WithBoth": {
|
|
2570
|
-
const predicate
|
|
2571
|
-
const object
|
|
2572
|
-
if (predicate
|
|
2573
|
-
const predMatcher = this
|
|
2574
|
-
const objMatcher = this
|
|
2575
|
-
if (predMatcher.matches(predicate
|
|
2570
|
+
const predicate = assertion.asPredicate?.();
|
|
2571
|
+
const object = assertion.asObject?.();
|
|
2572
|
+
if (predicate !== void 0 && object !== void 0) {
|
|
2573
|
+
const predMatcher = this._pattern.predicatePattern;
|
|
2574
|
+
const objMatcher = this._pattern.objectPattern;
|
|
2575
|
+
if (predMatcher.matches(predicate) && objMatcher.matches(object)) paths.push([assertion]);
|
|
2576
2576
|
}
|
|
2577
2577
|
break;
|
|
2578
2578
|
}
|
|
@@ -2598,25 +2598,25 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2598
2598
|
return false;
|
|
2599
2599
|
}
|
|
2600
2600
|
toString() {
|
|
2601
|
-
switch (this
|
|
2601
|
+
switch (this._pattern.type) {
|
|
2602
2602
|
case "Any": return "assert";
|
|
2603
|
-
case "WithPredicate": return `assertpred(${this
|
|
2604
|
-
case "WithObject": return `assertobj(${this
|
|
2605
|
-
case "WithBoth": return `assert(${this
|
|
2603
|
+
case "WithPredicate": return `assertpred(${this._pattern.pattern.toString()})`;
|
|
2604
|
+
case "WithObject": return `assertobj(${this._pattern.pattern.toString()})`;
|
|
2605
|
+
case "WithBoth": return `assert(${this._pattern.predicatePattern.toString()}, ${this._pattern.objectPattern.toString()})`;
|
|
2606
2606
|
}
|
|
2607
2607
|
}
|
|
2608
2608
|
/**
|
|
2609
2609
|
* Equality comparison.
|
|
2610
2610
|
*/
|
|
2611
2611
|
equals(other) {
|
|
2612
|
-
if (this
|
|
2613
|
-
switch (this
|
|
2612
|
+
if (this._pattern.type !== other._pattern.type) return false;
|
|
2613
|
+
switch (this._pattern.type) {
|
|
2614
2614
|
case "Any": return true;
|
|
2615
2615
|
case "WithPredicate":
|
|
2616
|
-
case "WithObject": return this
|
|
2616
|
+
case "WithObject": return this._pattern.pattern === other._pattern.pattern;
|
|
2617
2617
|
case "WithBoth": {
|
|
2618
|
-
const otherBoth = other
|
|
2619
|
-
return this
|
|
2618
|
+
const otherBoth = other._pattern;
|
|
2619
|
+
return this._pattern.predicatePattern === otherBoth.predicatePattern && this._pattern.objectPattern === otherBoth.objectPattern;
|
|
2620
2620
|
}
|
|
2621
2621
|
}
|
|
2622
2622
|
}
|
|
@@ -2624,7 +2624,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2624
2624
|
* Hash code for use in Maps/Sets.
|
|
2625
2625
|
*/
|
|
2626
2626
|
hashCode() {
|
|
2627
|
-
switch (this
|
|
2627
|
+
switch (this._pattern.type) {
|
|
2628
2628
|
case "Any": return 0;
|
|
2629
2629
|
case "WithPredicate": return 1;
|
|
2630
2630
|
case "WithObject": return 2;
|
|
@@ -2653,9 +2653,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2653
2653
|
* Corresponds to the Rust `DigestPattern` enum in digest_pattern.rs
|
|
2654
2654
|
*/
|
|
2655
2655
|
var DigestPattern = class DigestPattern {
|
|
2656
|
-
|
|
2656
|
+
_pattern;
|
|
2657
2657
|
constructor(pattern) {
|
|
2658
|
-
this
|
|
2658
|
+
this._pattern = pattern;
|
|
2659
2659
|
}
|
|
2660
2660
|
/**
|
|
2661
2661
|
* Creates a new DigestPattern that matches any digest.
|
|
@@ -2666,10 +2666,10 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2666
2666
|
/**
|
|
2667
2667
|
* Creates a new DigestPattern that matches the exact digest.
|
|
2668
2668
|
*/
|
|
2669
|
-
static digest(digest
|
|
2669
|
+
static digest(digest) {
|
|
2670
2670
|
return new DigestPattern({
|
|
2671
2671
|
type: "Digest",
|
|
2672
|
-
digest
|
|
2672
|
+
digest
|
|
2673
2673
|
});
|
|
2674
2674
|
}
|
|
2675
2675
|
/**
|
|
@@ -2694,21 +2694,21 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2694
2694
|
* Gets the pattern type.
|
|
2695
2695
|
*/
|
|
2696
2696
|
get patternType() {
|
|
2697
|
-
return this
|
|
2697
|
+
return this._pattern;
|
|
2698
2698
|
}
|
|
2699
2699
|
pathsWithCaptures(haystack) {
|
|
2700
|
-
const digest
|
|
2701
|
-
const digestData = digest
|
|
2700
|
+
const digest = haystack.digest();
|
|
2701
|
+
const digestData = digest.data();
|
|
2702
2702
|
let isHit = false;
|
|
2703
|
-
switch (this
|
|
2703
|
+
switch (this._pattern.type) {
|
|
2704
2704
|
case "Any":
|
|
2705
2705
|
isHit = true;
|
|
2706
2706
|
break;
|
|
2707
2707
|
case "Digest":
|
|
2708
|
-
isHit = digest
|
|
2708
|
+
isHit = digest.equals(this._pattern.digest);
|
|
2709
2709
|
break;
|
|
2710
2710
|
case "Prefix": {
|
|
2711
|
-
const prefix = this
|
|
2711
|
+
const prefix = this._pattern.prefix;
|
|
2712
2712
|
if (digestData.length >= prefix.length) {
|
|
2713
2713
|
isHit = true;
|
|
2714
2714
|
for (let i = 0; i < prefix.length; i++) if (digestData[i] !== prefix[i]) {
|
|
@@ -2720,7 +2720,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2720
2720
|
}
|
|
2721
2721
|
case "BinaryRegex": {
|
|
2722
2722
|
const latin1 = bytesToLatin1(digestData);
|
|
2723
|
-
isHit = this
|
|
2723
|
+
isHit = this._pattern.regex.test(latin1);
|
|
2724
2724
|
break;
|
|
2725
2725
|
}
|
|
2726
2726
|
}
|
|
@@ -2740,51 +2740,51 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2740
2740
|
return false;
|
|
2741
2741
|
}
|
|
2742
2742
|
toString() {
|
|
2743
|
-
switch (this
|
|
2743
|
+
switch (this._pattern.type) {
|
|
2744
2744
|
case "Any": return "digest";
|
|
2745
|
-
case "Digest": return `digest(${this
|
|
2746
|
-
case "Prefix": return `digest(${(0, _bcts_dcbor.bytesToHex)(this
|
|
2747
|
-
case "BinaryRegex": return `digest(/${this
|
|
2745
|
+
case "Digest": return `digest(${this._pattern.digest.hex()})`;
|
|
2746
|
+
case "Prefix": return `digest(${(0, _bcts_dcbor.bytesToHex)(this._pattern.prefix)})`;
|
|
2747
|
+
case "BinaryRegex": return `digest(/${this._pattern.regex.source}/)`;
|
|
2748
2748
|
}
|
|
2749
2749
|
}
|
|
2750
2750
|
/**
|
|
2751
2751
|
* Equality comparison.
|
|
2752
2752
|
*/
|
|
2753
2753
|
equals(other) {
|
|
2754
|
-
if (this
|
|
2755
|
-
switch (this
|
|
2754
|
+
if (this._pattern.type !== other._pattern.type) return false;
|
|
2755
|
+
switch (this._pattern.type) {
|
|
2756
2756
|
case "Any": return true;
|
|
2757
|
-
case "Digest": return this
|
|
2757
|
+
case "Digest": return this._pattern.digest.equals(other._pattern.digest);
|
|
2758
2758
|
case "Prefix": {
|
|
2759
|
-
const thisPrefix = this
|
|
2760
|
-
const otherPrefix = other
|
|
2759
|
+
const thisPrefix = this._pattern.prefix;
|
|
2760
|
+
const otherPrefix = other._pattern.prefix;
|
|
2761
2761
|
if (thisPrefix.length !== otherPrefix.length) return false;
|
|
2762
2762
|
for (let i = 0; i < thisPrefix.length; i++) if (thisPrefix[i] !== otherPrefix[i]) return false;
|
|
2763
2763
|
return true;
|
|
2764
2764
|
}
|
|
2765
|
-
case "BinaryRegex": return this
|
|
2765
|
+
case "BinaryRegex": return this._pattern.regex.source === other._pattern.regex.source;
|
|
2766
2766
|
}
|
|
2767
2767
|
}
|
|
2768
2768
|
/**
|
|
2769
2769
|
* Hash code for use in Maps/Sets.
|
|
2770
2770
|
*/
|
|
2771
2771
|
hashCode() {
|
|
2772
|
-
switch (this
|
|
2772
|
+
switch (this._pattern.type) {
|
|
2773
2773
|
case "Any": return 0;
|
|
2774
2774
|
case "Digest": {
|
|
2775
|
-
const data = this
|
|
2775
|
+
const data = this._pattern.digest.data().slice(0, 8);
|
|
2776
2776
|
let hash = 0;
|
|
2777
2777
|
for (const byte of data) hash = hash * 31 + byte | 0;
|
|
2778
2778
|
return hash;
|
|
2779
2779
|
}
|
|
2780
2780
|
case "Prefix": {
|
|
2781
2781
|
let hash = 0;
|
|
2782
|
-
for (const byte of this
|
|
2782
|
+
for (const byte of this._pattern.prefix) hash = hash * 31 + byte | 0;
|
|
2783
2783
|
return hash;
|
|
2784
2784
|
}
|
|
2785
2785
|
case "BinaryRegex": {
|
|
2786
2786
|
let hash = 0;
|
|
2787
|
-
for (const char of this
|
|
2787
|
+
for (const char of this._pattern.regex.source) hash = hash * 31 + char.charCodeAt(0) | 0;
|
|
2788
2788
|
return hash;
|
|
2789
2789
|
}
|
|
2790
2790
|
}
|
|
@@ -2803,9 +2803,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2803
2803
|
* Corresponds to the Rust `NodePattern` enum in node_pattern.rs
|
|
2804
2804
|
*/
|
|
2805
2805
|
var NodePattern = class NodePattern {
|
|
2806
|
-
|
|
2806
|
+
_pattern;
|
|
2807
2807
|
constructor(pattern) {
|
|
2808
|
-
this
|
|
2808
|
+
this._pattern = pattern;
|
|
2809
2809
|
}
|
|
2810
2810
|
/**
|
|
2811
2811
|
* Creates a new NodePattern that matches any node.
|
|
@@ -2844,13 +2844,13 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2844
2844
|
* Gets the pattern type.
|
|
2845
2845
|
*/
|
|
2846
2846
|
get patternType() {
|
|
2847
|
-
return this
|
|
2847
|
+
return this._pattern;
|
|
2848
2848
|
}
|
|
2849
2849
|
/**
|
|
2850
2850
|
* Gets the subject pattern if this is a WithSubject type, undefined otherwise.
|
|
2851
2851
|
*/
|
|
2852
2852
|
subjectPattern() {
|
|
2853
|
-
return this
|
|
2853
|
+
return this._pattern.type === "WithSubject" ? this._pattern.subjectPattern : void 0;
|
|
2854
2854
|
}
|
|
2855
2855
|
/**
|
|
2856
2856
|
* Gets the assertion patterns (empty array if none).
|
|
@@ -2861,12 +2861,12 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2861
2861
|
pathsWithCaptures(haystack) {
|
|
2862
2862
|
if (!haystack.isNode()) return [[], /* @__PURE__ */ new Map()];
|
|
2863
2863
|
let isHit = false;
|
|
2864
|
-
switch (this
|
|
2864
|
+
switch (this._pattern.type) {
|
|
2865
2865
|
case "Any":
|
|
2866
2866
|
isHit = true;
|
|
2867
2867
|
break;
|
|
2868
2868
|
case "AssertionsInterval":
|
|
2869
|
-
isHit = this
|
|
2869
|
+
isHit = this._pattern.interval.contains(haystack.assertions().length);
|
|
2870
2870
|
break;
|
|
2871
2871
|
case "WithSubject":
|
|
2872
2872
|
isHit = true;
|
|
@@ -2888,30 +2888,30 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2888
2888
|
return false;
|
|
2889
2889
|
}
|
|
2890
2890
|
toString() {
|
|
2891
|
-
switch (this
|
|
2891
|
+
switch (this._pattern.type) {
|
|
2892
2892
|
case "Any": return "node";
|
|
2893
|
-
case "AssertionsInterval": return `node(${this
|
|
2894
|
-
case "WithSubject": return `node(${this
|
|
2893
|
+
case "AssertionsInterval": return `node(${this._pattern.interval.toString()})`;
|
|
2894
|
+
case "WithSubject": return `node(${this._pattern.subjectPattern.toString()})`;
|
|
2895
2895
|
}
|
|
2896
2896
|
}
|
|
2897
2897
|
/**
|
|
2898
2898
|
* Equality comparison.
|
|
2899
2899
|
*/
|
|
2900
2900
|
equals(other) {
|
|
2901
|
-
if (this
|
|
2902
|
-
switch (this
|
|
2901
|
+
if (this._pattern.type !== other._pattern.type) return false;
|
|
2902
|
+
switch (this._pattern.type) {
|
|
2903
2903
|
case "Any": return true;
|
|
2904
|
-
case "AssertionsInterval": return this
|
|
2905
|
-
case "WithSubject": return this
|
|
2904
|
+
case "AssertionsInterval": return this._pattern.interval.equals(other._pattern.interval);
|
|
2905
|
+
case "WithSubject": return this._pattern.subjectPattern === other._pattern.subjectPattern;
|
|
2906
2906
|
}
|
|
2907
2907
|
}
|
|
2908
2908
|
/**
|
|
2909
2909
|
* Hash code for use in Maps/Sets.
|
|
2910
2910
|
*/
|
|
2911
2911
|
hashCode() {
|
|
2912
|
-
switch (this
|
|
2912
|
+
switch (this._pattern.type) {
|
|
2913
2913
|
case "Any": return 0;
|
|
2914
|
-
case "AssertionsInterval": return this
|
|
2914
|
+
case "AssertionsInterval": return this._pattern.interval.min() * 31 + (this._pattern.interval.max() ?? 0);
|
|
2915
2915
|
case "WithSubject": return 1;
|
|
2916
2916
|
}
|
|
2917
2917
|
}
|
|
@@ -2929,9 +2929,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2929
2929
|
* Corresponds to the Rust `ObscuredPattern` enum in obscured_pattern.rs
|
|
2930
2930
|
*/
|
|
2931
2931
|
var ObscuredPattern = class ObscuredPattern {
|
|
2932
|
-
|
|
2932
|
+
_pattern;
|
|
2933
2933
|
constructor(pattern) {
|
|
2934
|
-
this
|
|
2934
|
+
this._pattern = pattern;
|
|
2935
2935
|
}
|
|
2936
2936
|
/**
|
|
2937
2937
|
* Creates a new ObscuredPattern that matches any obscured element.
|
|
@@ -2961,11 +2961,11 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2961
2961
|
* Gets the pattern type.
|
|
2962
2962
|
*/
|
|
2963
2963
|
get patternType() {
|
|
2964
|
-
return this
|
|
2964
|
+
return this._pattern;
|
|
2965
2965
|
}
|
|
2966
2966
|
pathsWithCaptures(haystack) {
|
|
2967
2967
|
let isHit = false;
|
|
2968
|
-
switch (this
|
|
2968
|
+
switch (this._pattern.type) {
|
|
2969
2969
|
case "Any":
|
|
2970
2970
|
isHit = haystack.isObscured();
|
|
2971
2971
|
break;
|
|
@@ -2995,7 +2995,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
2995
2995
|
return false;
|
|
2996
2996
|
}
|
|
2997
2997
|
toString() {
|
|
2998
|
-
switch (this
|
|
2998
|
+
switch (this._pattern.type) {
|
|
2999
2999
|
case "Any": return "obscured";
|
|
3000
3000
|
case "Elided": return "elided";
|
|
3001
3001
|
case "Encrypted": return "encrypted";
|
|
@@ -3006,13 +3006,13 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3006
3006
|
* Equality comparison.
|
|
3007
3007
|
*/
|
|
3008
3008
|
equals(other) {
|
|
3009
|
-
return this
|
|
3009
|
+
return this._pattern.type === other._pattern.type;
|
|
3010
3010
|
}
|
|
3011
3011
|
/**
|
|
3012
3012
|
* Hash code for use in Maps/Sets.
|
|
3013
3013
|
*/
|
|
3014
3014
|
hashCode() {
|
|
3015
|
-
switch (this
|
|
3015
|
+
switch (this._pattern.type) {
|
|
3016
3016
|
case "Any": return 0;
|
|
3017
3017
|
case "Elided": return 1;
|
|
3018
3018
|
case "Encrypted": return 2;
|
|
@@ -3033,9 +3033,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3033
3033
|
* Corresponds to the Rust `WrappedPattern` enum in wrapped_pattern.rs
|
|
3034
3034
|
*/
|
|
3035
3035
|
var WrappedPattern = class WrappedPattern {
|
|
3036
|
-
|
|
3036
|
+
_pattern;
|
|
3037
3037
|
constructor(pattern) {
|
|
3038
|
-
this
|
|
3038
|
+
this._pattern = pattern;
|
|
3039
3039
|
}
|
|
3040
3040
|
/**
|
|
3041
3041
|
* Creates a new WrappedPattern that matches any wrapped envelope without descending.
|
|
@@ -3064,25 +3064,25 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3064
3064
|
* Gets the pattern type.
|
|
3065
3065
|
*/
|
|
3066
3066
|
get patternType() {
|
|
3067
|
-
return this
|
|
3067
|
+
return this._pattern;
|
|
3068
3068
|
}
|
|
3069
3069
|
/**
|
|
3070
3070
|
* Gets the inner pattern if this is an Unwrap type, undefined otherwise.
|
|
3071
3071
|
*/
|
|
3072
3072
|
innerPattern() {
|
|
3073
|
-
return this
|
|
3073
|
+
return this._pattern.type === "Unwrap" ? this._pattern.pattern : void 0;
|
|
3074
3074
|
}
|
|
3075
3075
|
pathsWithCaptures(haystack) {
|
|
3076
|
-
const subject
|
|
3077
|
-
if (!subject
|
|
3076
|
+
const subject = haystack.subject();
|
|
3077
|
+
if (!subject.isWrapped()) return [[], /* @__PURE__ */ new Map()];
|
|
3078
3078
|
let paths;
|
|
3079
|
-
switch (this
|
|
3079
|
+
switch (this._pattern.type) {
|
|
3080
3080
|
case "Any":
|
|
3081
3081
|
paths = [[haystack]];
|
|
3082
3082
|
break;
|
|
3083
3083
|
case "Unwrap": {
|
|
3084
|
-
const unwrapped = subject
|
|
3085
|
-
if (unwrapped !== void 0) paths = this
|
|
3084
|
+
const unwrapped = subject.tryUnwrap?.();
|
|
3085
|
+
if (unwrapped !== void 0) paths = this._pattern.pattern.paths(unwrapped).map((path) => {
|
|
3086
3086
|
return [haystack, ...path];
|
|
3087
3087
|
});
|
|
3088
3088
|
else paths = [];
|
|
@@ -3099,7 +3099,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3099
3099
|
}
|
|
3100
3100
|
compile(code, literals, captures) {
|
|
3101
3101
|
if (createStructureWrappedPattern === void 0) throw new Error("WrappedPattern factory not registered");
|
|
3102
|
-
switch (this
|
|
3102
|
+
switch (this._pattern.type) {
|
|
3103
3103
|
case "Any": {
|
|
3104
3104
|
const idx = literals.length;
|
|
3105
3105
|
literals.push(createStructureWrappedPattern(this));
|
|
@@ -3120,7 +3120,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3120
3120
|
type: "PushAxis",
|
|
3121
3121
|
axis: "Wrapped"
|
|
3122
3122
|
});
|
|
3123
|
-
this
|
|
3123
|
+
this._pattern.pattern.compile(code, literals, captures);
|
|
3124
3124
|
break;
|
|
3125
3125
|
}
|
|
3126
3126
|
}
|
|
@@ -3129,10 +3129,10 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3129
3129
|
return false;
|
|
3130
3130
|
}
|
|
3131
3131
|
toString() {
|
|
3132
|
-
switch (this
|
|
3132
|
+
switch (this._pattern.type) {
|
|
3133
3133
|
case "Any": return "wrapped";
|
|
3134
3134
|
case "Unwrap": {
|
|
3135
|
-
const patternStr = this
|
|
3135
|
+
const patternStr = this._pattern.pattern.toString();
|
|
3136
3136
|
if (patternStr === "*") return "unwrap";
|
|
3137
3137
|
return `unwrap(${patternStr})`;
|
|
3138
3138
|
}
|
|
@@ -3142,15 +3142,15 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3142
3142
|
* Equality comparison.
|
|
3143
3143
|
*/
|
|
3144
3144
|
equals(other) {
|
|
3145
|
-
if (this
|
|
3146
|
-
if (this
|
|
3147
|
-
return this
|
|
3145
|
+
if (this._pattern.type !== other._pattern.type) return false;
|
|
3146
|
+
if (this._pattern.type === "Any") return true;
|
|
3147
|
+
return this._pattern.pattern === other._pattern.pattern;
|
|
3148
3148
|
}
|
|
3149
3149
|
/**
|
|
3150
3150
|
* Hash code for use in Maps/Sets.
|
|
3151
3151
|
*/
|
|
3152
3152
|
hashCode() {
|
|
3153
|
-
return this
|
|
3153
|
+
return this._pattern.type === "Any" ? 0 : 1;
|
|
3154
3154
|
}
|
|
3155
3155
|
};
|
|
3156
3156
|
|
|
@@ -3390,9 +3390,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3390
3390
|
* Corresponds to the Rust `AndPattern` struct in and_pattern.rs
|
|
3391
3391
|
*/
|
|
3392
3392
|
var AndPattern = class AndPattern {
|
|
3393
|
-
|
|
3393
|
+
_patterns;
|
|
3394
3394
|
constructor(patterns) {
|
|
3395
|
-
this
|
|
3395
|
+
this._patterns = patterns;
|
|
3396
3396
|
}
|
|
3397
3397
|
/**
|
|
3398
3398
|
* Creates a new AndPattern with the given patterns.
|
|
@@ -3404,10 +3404,10 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3404
3404
|
* Gets the patterns.
|
|
3405
3405
|
*/
|
|
3406
3406
|
patterns() {
|
|
3407
|
-
return this
|
|
3407
|
+
return this._patterns;
|
|
3408
3408
|
}
|
|
3409
3409
|
pathsWithCaptures(haystack) {
|
|
3410
|
-
return [this
|
|
3410
|
+
return [this._patterns.every((pattern) => matchPattern(pattern, haystack)) ? [[haystack]] : [], /* @__PURE__ */ new Map()];
|
|
3411
3411
|
}
|
|
3412
3412
|
paths(haystack) {
|
|
3413
3413
|
return this.pathsWithCaptures(haystack)[0];
|
|
@@ -3416,27 +3416,27 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3416
3416
|
return this.paths(haystack).length > 0;
|
|
3417
3417
|
}
|
|
3418
3418
|
compile(code, literals, captures) {
|
|
3419
|
-
for (const pattern of this
|
|
3419
|
+
for (const pattern of this._patterns) pattern.compile(code, literals, captures);
|
|
3420
3420
|
}
|
|
3421
3421
|
isComplex() {
|
|
3422
|
-
return this
|
|
3422
|
+
return this._patterns.length > 1 || this._patterns.some((p) => p.isComplex());
|
|
3423
3423
|
}
|
|
3424
3424
|
toString() {
|
|
3425
|
-
return this
|
|
3425
|
+
return this._patterns.map((p) => p.toString()).join(" & ");
|
|
3426
3426
|
}
|
|
3427
3427
|
/**
|
|
3428
3428
|
* Equality comparison.
|
|
3429
3429
|
*/
|
|
3430
3430
|
equals(other) {
|
|
3431
|
-
if (this
|
|
3432
|
-
for (let i = 0; i < this
|
|
3431
|
+
if (this._patterns.length !== other._patterns.length) return false;
|
|
3432
|
+
for (let i = 0; i < this._patterns.length; i++) if (this._patterns[i] !== other._patterns[i]) return false;
|
|
3433
3433
|
return true;
|
|
3434
3434
|
}
|
|
3435
3435
|
/**
|
|
3436
3436
|
* Hash code for use in Maps/Sets.
|
|
3437
3437
|
*/
|
|
3438
3438
|
hashCode() {
|
|
3439
|
-
return this
|
|
3439
|
+
return this._patterns.length;
|
|
3440
3440
|
}
|
|
3441
3441
|
};
|
|
3442
3442
|
|
|
@@ -3452,9 +3452,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3452
3452
|
* Corresponds to the Rust `OrPattern` struct in or_pattern.rs
|
|
3453
3453
|
*/
|
|
3454
3454
|
var OrPattern = class OrPattern {
|
|
3455
|
-
|
|
3455
|
+
_patterns;
|
|
3456
3456
|
constructor(patterns) {
|
|
3457
|
-
this
|
|
3457
|
+
this._patterns = patterns;
|
|
3458
3458
|
}
|
|
3459
3459
|
/**
|
|
3460
3460
|
* Creates a new OrPattern with the given patterns.
|
|
@@ -3466,10 +3466,10 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3466
3466
|
* Gets the patterns.
|
|
3467
3467
|
*/
|
|
3468
3468
|
patterns() {
|
|
3469
|
-
return this
|
|
3469
|
+
return this._patterns;
|
|
3470
3470
|
}
|
|
3471
3471
|
pathsWithCaptures(haystack) {
|
|
3472
|
-
return [this
|
|
3472
|
+
return [this._patterns.some((pattern) => matchPattern(pattern, haystack)) ? [[haystack]] : [], /* @__PURE__ */ new Map()];
|
|
3473
3473
|
}
|
|
3474
3474
|
paths(haystack) {
|
|
3475
3475
|
return this.pathsWithCaptures(haystack)[0];
|
|
@@ -3478,9 +3478,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3478
3478
|
return this.paths(haystack).length > 0;
|
|
3479
3479
|
}
|
|
3480
3480
|
compile(code, literals, captures) {
|
|
3481
|
-
if (this
|
|
3481
|
+
if (this._patterns.length === 0) return;
|
|
3482
3482
|
const splits = [];
|
|
3483
|
-
for (let i = 0; i < this
|
|
3483
|
+
for (let i = 0; i < this._patterns.length - 1; i++) {
|
|
3484
3484
|
splits.push(code.length);
|
|
3485
3485
|
code.push({
|
|
3486
3486
|
type: "Split",
|
|
@@ -3489,16 +3489,16 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3489
3489
|
});
|
|
3490
3490
|
}
|
|
3491
3491
|
const jumps = [];
|
|
3492
|
-
for (let i = 0; i < this
|
|
3492
|
+
for (let i = 0; i < this._patterns.length; i++) {
|
|
3493
3493
|
const patternStart = code.length;
|
|
3494
|
-
this
|
|
3494
|
+
this._patterns[i].compile(code, literals, captures);
|
|
3495
3495
|
const jumpPastAll = code.length;
|
|
3496
3496
|
code.push({
|
|
3497
3497
|
type: "Jump",
|
|
3498
3498
|
address: 0
|
|
3499
3499
|
});
|
|
3500
3500
|
jumps.push(jumpPastAll);
|
|
3501
|
-
if (i < this
|
|
3501
|
+
if (i < this._patterns.length - 1) {
|
|
3502
3502
|
const nextPattern = code.length;
|
|
3503
3503
|
code[splits[i]] = {
|
|
3504
3504
|
type: "Split",
|
|
@@ -3514,24 +3514,24 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3514
3514
|
};
|
|
3515
3515
|
}
|
|
3516
3516
|
isComplex() {
|
|
3517
|
-
return this
|
|
3517
|
+
return this._patterns.length > 1 || this._patterns.some((p) => p.isComplex());
|
|
3518
3518
|
}
|
|
3519
3519
|
toString() {
|
|
3520
|
-
return this
|
|
3520
|
+
return this._patterns.map((p) => p.toString()).join(" | ");
|
|
3521
3521
|
}
|
|
3522
3522
|
/**
|
|
3523
3523
|
* Equality comparison.
|
|
3524
3524
|
*/
|
|
3525
3525
|
equals(other) {
|
|
3526
|
-
if (this
|
|
3527
|
-
for (let i = 0; i < this
|
|
3526
|
+
if (this._patterns.length !== other._patterns.length) return false;
|
|
3527
|
+
for (let i = 0; i < this._patterns.length; i++) if (this._patterns[i] !== other._patterns[i]) return false;
|
|
3528
3528
|
return true;
|
|
3529
3529
|
}
|
|
3530
3530
|
/**
|
|
3531
3531
|
* Hash code for use in Maps/Sets.
|
|
3532
3532
|
*/
|
|
3533
3533
|
hashCode() {
|
|
3534
|
-
return this
|
|
3534
|
+
return this._patterns.length;
|
|
3535
3535
|
}
|
|
3536
3536
|
};
|
|
3537
3537
|
|
|
@@ -3547,9 +3547,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3547
3547
|
* Corresponds to the Rust `NotPattern` struct in not_pattern.rs
|
|
3548
3548
|
*/
|
|
3549
3549
|
var NotPattern = class NotPattern {
|
|
3550
|
-
|
|
3550
|
+
_pattern;
|
|
3551
3551
|
constructor(pattern) {
|
|
3552
|
-
this
|
|
3552
|
+
this._pattern = pattern;
|
|
3553
3553
|
}
|
|
3554
3554
|
/**
|
|
3555
3555
|
* Creates a new NotPattern with the given pattern.
|
|
@@ -3561,10 +3561,10 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3561
3561
|
* Gets the inner pattern.
|
|
3562
3562
|
*/
|
|
3563
3563
|
pattern() {
|
|
3564
|
-
return this
|
|
3564
|
+
return this._pattern;
|
|
3565
3565
|
}
|
|
3566
3566
|
pathsWithCaptures(haystack) {
|
|
3567
|
-
return [!matchPattern(this
|
|
3567
|
+
return [!matchPattern(this._pattern, haystack) ? [[haystack]] : [], /* @__PURE__ */ new Map()];
|
|
3568
3568
|
}
|
|
3569
3569
|
paths(haystack) {
|
|
3570
3570
|
return this.pathsWithCaptures(haystack)[0];
|
|
@@ -3574,7 +3574,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3574
3574
|
}
|
|
3575
3575
|
compile(code, literals, _captures) {
|
|
3576
3576
|
const idx = literals.length;
|
|
3577
|
-
literals.push(this
|
|
3577
|
+
literals.push(this._pattern);
|
|
3578
3578
|
code.push({
|
|
3579
3579
|
type: "NotMatch",
|
|
3580
3580
|
patternIndex: idx
|
|
@@ -3584,13 +3584,13 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3584
3584
|
return false;
|
|
3585
3585
|
}
|
|
3586
3586
|
toString() {
|
|
3587
|
-
return `!${this
|
|
3587
|
+
return `!${this._pattern.toString()}`;
|
|
3588
3588
|
}
|
|
3589
3589
|
/**
|
|
3590
3590
|
* Equality comparison.
|
|
3591
3591
|
*/
|
|
3592
3592
|
equals(other) {
|
|
3593
|
-
return this
|
|
3593
|
+
return this._pattern === other._pattern;
|
|
3594
3594
|
}
|
|
3595
3595
|
/**
|
|
3596
3596
|
* Hash code for use in Maps/Sets.
|
|
@@ -3612,11 +3612,11 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3612
3612
|
* Corresponds to the Rust `CapturePattern` struct in capture_pattern.rs
|
|
3613
3613
|
*/
|
|
3614
3614
|
var CapturePattern = class CapturePattern {
|
|
3615
|
-
|
|
3616
|
-
|
|
3615
|
+
_name;
|
|
3616
|
+
_pattern;
|
|
3617
3617
|
constructor(name, pattern) {
|
|
3618
|
-
this
|
|
3619
|
-
this
|
|
3618
|
+
this._name = name;
|
|
3619
|
+
this._pattern = pattern;
|
|
3620
3620
|
}
|
|
3621
3621
|
/**
|
|
3622
3622
|
* Creates a new CapturePattern with the given name and pattern.
|
|
@@ -3628,19 +3628,19 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3628
3628
|
* Gets the name of the capture.
|
|
3629
3629
|
*/
|
|
3630
3630
|
name() {
|
|
3631
|
-
return this
|
|
3631
|
+
return this._name;
|
|
3632
3632
|
}
|
|
3633
3633
|
/**
|
|
3634
3634
|
* Gets the inner pattern.
|
|
3635
3635
|
*/
|
|
3636
3636
|
pattern() {
|
|
3637
|
-
return this
|
|
3637
|
+
return this._pattern;
|
|
3638
3638
|
}
|
|
3639
3639
|
pathsWithCaptures(haystack) {
|
|
3640
|
-
const [paths, caps] = this
|
|
3640
|
+
const [paths, caps] = this._pattern.pathsWithCaptures(haystack);
|
|
3641
3641
|
if (paths.length > 0) {
|
|
3642
|
-
const existing = caps.get(this
|
|
3643
|
-
caps.set(this
|
|
3642
|
+
const existing = caps.get(this._name) ?? [];
|
|
3643
|
+
caps.set(this._name, [...existing, ...paths]);
|
|
3644
3644
|
}
|
|
3645
3645
|
return [paths, caps];
|
|
3646
3646
|
}
|
|
@@ -3652,12 +3652,12 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3652
3652
|
}
|
|
3653
3653
|
compile(code, literals, captures) {
|
|
3654
3654
|
const id = captures.length;
|
|
3655
|
-
captures.push(this
|
|
3655
|
+
captures.push(this._name);
|
|
3656
3656
|
code.push({
|
|
3657
3657
|
type: "CaptureStart",
|
|
3658
3658
|
captureIndex: id
|
|
3659
3659
|
});
|
|
3660
|
-
this
|
|
3660
|
+
this._pattern.compile(code, literals, captures);
|
|
3661
3661
|
code.push({
|
|
3662
3662
|
type: "CaptureEnd",
|
|
3663
3663
|
captureIndex: id
|
|
@@ -3667,20 +3667,20 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3667
3667
|
return false;
|
|
3668
3668
|
}
|
|
3669
3669
|
toString() {
|
|
3670
|
-
return `@${this
|
|
3670
|
+
return `@${this._name}(${this._pattern.toString()})`;
|
|
3671
3671
|
}
|
|
3672
3672
|
/**
|
|
3673
3673
|
* Equality comparison.
|
|
3674
3674
|
*/
|
|
3675
3675
|
equals(other) {
|
|
3676
|
-
return this
|
|
3676
|
+
return this._name === other._name && this._pattern === other._pattern;
|
|
3677
3677
|
}
|
|
3678
3678
|
/**
|
|
3679
3679
|
* Hash code for use in Maps/Sets.
|
|
3680
3680
|
*/
|
|
3681
3681
|
hashCode() {
|
|
3682
3682
|
let hash = 0;
|
|
3683
|
-
for (const char of this
|
|
3683
|
+
for (const char of this._name) hash = hash * 31 + char.charCodeAt(0) | 0;
|
|
3684
3684
|
return hash;
|
|
3685
3685
|
}
|
|
3686
3686
|
};
|
|
@@ -3697,9 +3697,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3697
3697
|
* Corresponds to the Rust `SearchPattern` struct in search_pattern.rs
|
|
3698
3698
|
*/
|
|
3699
3699
|
var SearchPattern = class SearchPattern {
|
|
3700
|
-
|
|
3700
|
+
_pattern;
|
|
3701
3701
|
constructor(pattern) {
|
|
3702
|
-
this
|
|
3702
|
+
this._pattern = pattern;
|
|
3703
3703
|
}
|
|
3704
3704
|
/**
|
|
3705
3705
|
* Creates a new SearchPattern with the given pattern.
|
|
@@ -3711,15 +3711,15 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3711
3711
|
* Gets the inner pattern.
|
|
3712
3712
|
*/
|
|
3713
3713
|
pattern() {
|
|
3714
|
-
return this
|
|
3714
|
+
return this._pattern;
|
|
3715
3715
|
}
|
|
3716
3716
|
pathsWithCaptures(haystack) {
|
|
3717
3717
|
const resultPaths = [];
|
|
3718
|
-
const matcher = this
|
|
3719
|
-
this
|
|
3718
|
+
const matcher = this._pattern;
|
|
3719
|
+
this._walkEnvelope(haystack, [], (currentEnvelope, pathToCurrent) => {
|
|
3720
3720
|
const newPath = [...pathToCurrent, currentEnvelope];
|
|
3721
|
-
const patternPaths
|
|
3722
|
-
for (const patternPath of patternPaths
|
|
3721
|
+
const patternPaths = matcher.paths(currentEnvelope);
|
|
3722
|
+
for (const patternPath of patternPaths) {
|
|
3723
3723
|
const fullPath = [...newPath];
|
|
3724
3724
|
if (patternPath.length > 1) fullPath.push(...patternPath.slice(1));
|
|
3725
3725
|
else if (patternPath.length === 1) {
|
|
@@ -3743,27 +3743,27 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3743
3743
|
/**
|
|
3744
3744
|
* Walk the envelope tree recursively.
|
|
3745
3745
|
*/
|
|
3746
|
-
|
|
3746
|
+
_walkEnvelope(envelope, pathToCurrent, visitor) {
|
|
3747
3747
|
visitor(envelope, pathToCurrent);
|
|
3748
|
-
const subject
|
|
3748
|
+
const subject = envelope.subject();
|
|
3749
3749
|
const newPath = [...pathToCurrent, envelope];
|
|
3750
|
-
if (!subject
|
|
3750
|
+
if (!subject.digest().equals(envelope.digest())) this._walkEnvelope(subject, newPath, visitor);
|
|
3751
3751
|
for (const assertion of envelope.assertions()) {
|
|
3752
|
-
this
|
|
3753
|
-
const predicate
|
|
3754
|
-
if (predicate
|
|
3752
|
+
this._walkEnvelope(assertion, newPath, visitor);
|
|
3753
|
+
const predicate = assertion.asPredicate?.();
|
|
3754
|
+
if (predicate !== void 0) {
|
|
3755
3755
|
const assertionPath = [...newPath, assertion];
|
|
3756
|
-
this
|
|
3756
|
+
this._walkEnvelope(predicate, assertionPath, visitor);
|
|
3757
3757
|
}
|
|
3758
|
-
const object
|
|
3759
|
-
if (object
|
|
3758
|
+
const object = assertion.asObject?.();
|
|
3759
|
+
if (object !== void 0) {
|
|
3760
3760
|
const assertionPath = [...newPath, assertion];
|
|
3761
|
-
this
|
|
3761
|
+
this._walkEnvelope(object, assertionPath, visitor);
|
|
3762
3762
|
}
|
|
3763
3763
|
}
|
|
3764
|
-
if (subject
|
|
3765
|
-
const unwrapped = subject
|
|
3766
|
-
if (unwrapped !== void 0) this
|
|
3764
|
+
if (subject.isWrapped()) {
|
|
3765
|
+
const unwrapped = subject.tryUnwrap?.();
|
|
3766
|
+
if (unwrapped !== void 0) this._walkEnvelope(unwrapped, newPath, visitor);
|
|
3767
3767
|
}
|
|
3768
3768
|
}
|
|
3769
3769
|
paths(haystack) {
|
|
@@ -3774,9 +3774,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3774
3774
|
}
|
|
3775
3775
|
compile(code, literals, captures) {
|
|
3776
3776
|
const idx = literals.length;
|
|
3777
|
-
literals.push(this
|
|
3777
|
+
literals.push(this._pattern);
|
|
3778
3778
|
const innerNames = [];
|
|
3779
|
-
collectCaptureNames$1(this
|
|
3779
|
+
collectCaptureNames$1(this._pattern, innerNames);
|
|
3780
3780
|
const captureMap = [];
|
|
3781
3781
|
for (const name of innerNames) {
|
|
3782
3782
|
let pos = captures.indexOf(name);
|
|
@@ -3796,13 +3796,13 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3796
3796
|
return true;
|
|
3797
3797
|
}
|
|
3798
3798
|
toString() {
|
|
3799
|
-
return `search(${this
|
|
3799
|
+
return `search(${this._pattern.toString()})`;
|
|
3800
3800
|
}
|
|
3801
3801
|
/**
|
|
3802
3802
|
* Equality comparison.
|
|
3803
3803
|
*/
|
|
3804
3804
|
equals(other) {
|
|
3805
|
-
return this
|
|
3805
|
+
return this._pattern === other._pattern;
|
|
3806
3806
|
}
|
|
3807
3807
|
/**
|
|
3808
3808
|
* Hash code for use in Maps/Sets.
|
|
@@ -3831,11 +3831,11 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3831
3831
|
* Corresponds to the Rust `TraversePattern` struct in traverse_pattern.rs
|
|
3832
3832
|
*/
|
|
3833
3833
|
var TraversePattern = class TraversePattern {
|
|
3834
|
-
|
|
3835
|
-
|
|
3834
|
+
_first;
|
|
3835
|
+
_rest;
|
|
3836
3836
|
constructor(first, rest) {
|
|
3837
|
-
this
|
|
3838
|
-
this
|
|
3837
|
+
this._first = first;
|
|
3838
|
+
this._rest = rest;
|
|
3839
3839
|
}
|
|
3840
3840
|
/**
|
|
3841
3841
|
* Creates a new TraversePattern with the given patterns.
|
|
@@ -3850,18 +3850,18 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3850
3850
|
* Gets all patterns in this traversal.
|
|
3851
3851
|
*/
|
|
3852
3852
|
patterns() {
|
|
3853
|
-
const result = [this
|
|
3854
|
-
if (this
|
|
3853
|
+
const result = [this._first];
|
|
3854
|
+
if (this._rest !== void 0) result.push(...this._rest.patterns());
|
|
3855
3855
|
return result;
|
|
3856
3856
|
}
|
|
3857
3857
|
pathsWithCaptures(haystack) {
|
|
3858
|
-
const headPaths = this
|
|
3859
|
-
if (this
|
|
3858
|
+
const headPaths = this._first.paths(haystack);
|
|
3859
|
+
if (this._rest === void 0) return [headPaths, /* @__PURE__ */ new Map()];
|
|
3860
3860
|
const result = [];
|
|
3861
3861
|
for (const path of headPaths) {
|
|
3862
3862
|
const lastEnv = path[path.length - 1];
|
|
3863
3863
|
if (lastEnv !== void 0) {
|
|
3864
|
-
const tailPaths = this
|
|
3864
|
+
const tailPaths = this._rest.paths(lastEnv);
|
|
3865
3865
|
for (const tailPath of tailPaths) {
|
|
3866
3866
|
const combined = [...path, ...tailPath];
|
|
3867
3867
|
result.push(combined);
|
|
@@ -3877,15 +3877,15 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3877
3877
|
return this.paths(haystack).length > 0;
|
|
3878
3878
|
}
|
|
3879
3879
|
compile(code, literals, captures) {
|
|
3880
|
-
this
|
|
3881
|
-
if (this
|
|
3880
|
+
this._first.compile(code, literals, captures);
|
|
3881
|
+
if (this._rest !== void 0) {
|
|
3882
3882
|
code.push({ type: "ExtendTraversal" });
|
|
3883
|
-
this
|
|
3883
|
+
this._rest.compile(code, literals, captures);
|
|
3884
3884
|
code.push({ type: "CombineTraversal" });
|
|
3885
3885
|
}
|
|
3886
3886
|
}
|
|
3887
3887
|
isComplex() {
|
|
3888
|
-
return this
|
|
3888
|
+
return this._first.isComplex() || this._rest !== void 0;
|
|
3889
3889
|
}
|
|
3890
3890
|
toString() {
|
|
3891
3891
|
return this.patterns().map((p) => p.toString()).join(" -> ");
|
|
@@ -3920,11 +3920,11 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3920
3920
|
* Corresponds to the Rust `GroupPattern` struct in repeat_pattern.rs
|
|
3921
3921
|
*/
|
|
3922
3922
|
var GroupPattern = class GroupPattern {
|
|
3923
|
-
|
|
3924
|
-
|
|
3923
|
+
_pattern;
|
|
3924
|
+
_quantifier;
|
|
3925
3925
|
constructor(pattern, quantifier) {
|
|
3926
|
-
this
|
|
3927
|
-
this
|
|
3926
|
+
this._pattern = pattern;
|
|
3927
|
+
this._quantifier = quantifier;
|
|
3928
3928
|
}
|
|
3929
3929
|
/**
|
|
3930
3930
|
* Creates a new GroupPattern with the specified sub-pattern and quantifier.
|
|
@@ -3942,13 +3942,13 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3942
3942
|
* Gets the sub-pattern of this group pattern.
|
|
3943
3943
|
*/
|
|
3944
3944
|
pattern() {
|
|
3945
|
-
return this
|
|
3945
|
+
return this._pattern;
|
|
3946
3946
|
}
|
|
3947
3947
|
/**
|
|
3948
3948
|
* Gets the quantifier of this group pattern.
|
|
3949
3949
|
*/
|
|
3950
3950
|
quantifier() {
|
|
3951
|
-
return this
|
|
3951
|
+
return this._quantifier;
|
|
3952
3952
|
}
|
|
3953
3953
|
pathsWithCaptures(_haystack) {
|
|
3954
3954
|
throw new Error("GroupPattern does not support pathsWithCaptures directly; use compile instead");
|
|
@@ -3957,35 +3957,35 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
3957
3957
|
return this.pathsWithCaptures(haystack)[0];
|
|
3958
3958
|
}
|
|
3959
3959
|
matches(haystack) {
|
|
3960
|
-
return this
|
|
3960
|
+
return this._pattern.matches(haystack);
|
|
3961
3961
|
}
|
|
3962
3962
|
compile(code, literals, _captures) {
|
|
3963
3963
|
const idx = literals.length;
|
|
3964
|
-
literals.push(this
|
|
3964
|
+
literals.push(this._pattern);
|
|
3965
3965
|
code.push({
|
|
3966
3966
|
type: "Repeat",
|
|
3967
3967
|
patternIndex: idx,
|
|
3968
|
-
quantifier: this
|
|
3968
|
+
quantifier: this._quantifier
|
|
3969
3969
|
});
|
|
3970
3970
|
}
|
|
3971
3971
|
isComplex() {
|
|
3972
3972
|
return true;
|
|
3973
3973
|
}
|
|
3974
3974
|
toString() {
|
|
3975
|
-
const formattedRange = this
|
|
3976
|
-
return `(${this
|
|
3975
|
+
const formattedRange = this._quantifier.toString();
|
|
3976
|
+
return `(${this._pattern.toString()})${formattedRange}`;
|
|
3977
3977
|
}
|
|
3978
3978
|
/**
|
|
3979
3979
|
* Equality comparison.
|
|
3980
3980
|
*/
|
|
3981
3981
|
equals(other) {
|
|
3982
|
-
return this
|
|
3982
|
+
return this._pattern === other._pattern && this._quantifier.equals(other._quantifier);
|
|
3983
3983
|
}
|
|
3984
3984
|
/**
|
|
3985
3985
|
* Hash code for use in Maps/Sets.
|
|
3986
3986
|
*/
|
|
3987
3987
|
hashCode() {
|
|
3988
|
-
return this
|
|
3988
|
+
return this._quantifier.min() * 31 + (this._quantifier.max() ?? 0);
|
|
3989
3989
|
}
|
|
3990
3990
|
};
|
|
3991
3991
|
|
|
@@ -4212,9 +4212,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
4212
4212
|
return [];
|
|
4213
4213
|
case "Wrapped":
|
|
4214
4214
|
if (envCase.type === "node") {
|
|
4215
|
-
const subject
|
|
4216
|
-
if (subject
|
|
4217
|
-
const unwrapped = subject
|
|
4215
|
+
const subject = envCase.subject;
|
|
4216
|
+
if (subject.isWrapped()) {
|
|
4217
|
+
const unwrapped = subject.unwrap();
|
|
4218
4218
|
if (unwrapped !== void 0) return [[unwrapped, "Content"]];
|
|
4219
4219
|
}
|
|
4220
4220
|
} else if (envCase.type === "wrapped") return [[envCase.envelope, "Content"]];
|
|
@@ -4510,9 +4510,9 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
4510
4510
|
}
|
|
4511
4511
|
case "NavigateSubject":
|
|
4512
4512
|
if (th.env.isNode()) {
|
|
4513
|
-
const subject
|
|
4514
|
-
th.env = subject
|
|
4515
|
-
th.path.push(subject
|
|
4513
|
+
const subject = th.env.subject();
|
|
4514
|
+
th.env = subject;
|
|
4515
|
+
th.path.push(subject);
|
|
4516
4516
|
}
|
|
4517
4517
|
th.pc += 1;
|
|
4518
4518
|
continue;
|
|
@@ -4586,12 +4586,12 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
4586
4586
|
seen: /* @__PURE__ */ new Set()
|
|
4587
4587
|
}, out);
|
|
4588
4588
|
return out.map(([path, caps]) => {
|
|
4589
|
-
const map
|
|
4589
|
+
const map = /* @__PURE__ */ new Map();
|
|
4590
4590
|
for (let i = 0; i < caps.length; i++) {
|
|
4591
4591
|
const paths = caps[i];
|
|
4592
|
-
if (paths.length > 0) map
|
|
4592
|
+
if (paths.length > 0) map.set(prog.captureNames[i], paths);
|
|
4593
4593
|
}
|
|
4594
|
-
return [path, map
|
|
4594
|
+
return [path, map];
|
|
4595
4595
|
});
|
|
4596
4596
|
}
|
|
4597
4597
|
/**
|
|
@@ -4963,10 +4963,10 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
4963
4963
|
/**
|
|
4964
4964
|
* Creates a Leaf pattern.
|
|
4965
4965
|
*/
|
|
4966
|
-
function patternLeaf(leaf
|
|
4966
|
+
function patternLeaf(leaf) {
|
|
4967
4967
|
return {
|
|
4968
4968
|
type: "Leaf",
|
|
4969
|
-
pattern: leaf
|
|
4969
|
+
pattern: leaf
|
|
4970
4970
|
};
|
|
4971
4971
|
}
|
|
4972
4972
|
/**
|
|
@@ -5499,26 +5499,26 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
5499
5499
|
* Lexer for Gordian Envelope pattern syntax.
|
|
5500
5500
|
*/
|
|
5501
5501
|
var Lexer = class {
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5502
|
+
_source;
|
|
5503
|
+
_position = 0;
|
|
5504
|
+
_tokenStart = 0;
|
|
5505
|
+
_peekedToken = void 0;
|
|
5506
5506
|
constructor(source) {
|
|
5507
|
-
this
|
|
5507
|
+
this._source = source;
|
|
5508
5508
|
}
|
|
5509
5509
|
/**
|
|
5510
5510
|
* Gets the current position in the source.
|
|
5511
5511
|
*/
|
|
5512
5512
|
get position() {
|
|
5513
|
-
return this
|
|
5513
|
+
return this._position;
|
|
5514
5514
|
}
|
|
5515
5515
|
/**
|
|
5516
5516
|
* Peeks at the next token without consuming it.
|
|
5517
5517
|
*/
|
|
5518
5518
|
peekToken() {
|
|
5519
|
-
if (this
|
|
5519
|
+
if (this._peekedToken !== void 0) return this._peekedToken;
|
|
5520
5520
|
const result = this.next();
|
|
5521
|
-
this
|
|
5521
|
+
this._peekedToken = result;
|
|
5522
5522
|
return result;
|
|
5523
5523
|
}
|
|
5524
5524
|
/**
|
|
@@ -5526,50 +5526,50 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
5526
5526
|
*/
|
|
5527
5527
|
span() {
|
|
5528
5528
|
return {
|
|
5529
|
-
start: this
|
|
5530
|
-
end: this
|
|
5529
|
+
start: this._tokenStart,
|
|
5530
|
+
end: this._position
|
|
5531
5531
|
};
|
|
5532
5532
|
}
|
|
5533
5533
|
/**
|
|
5534
5534
|
* Gets the remaining source string.
|
|
5535
5535
|
*/
|
|
5536
5536
|
remainder() {
|
|
5537
|
-
return this
|
|
5537
|
+
return this._source.slice(this._position);
|
|
5538
5538
|
}
|
|
5539
5539
|
/**
|
|
5540
5540
|
* Peeks at the current character without consuming it.
|
|
5541
5541
|
*/
|
|
5542
5542
|
peek() {
|
|
5543
|
-
if (this
|
|
5544
|
-
return this
|
|
5543
|
+
if (this._position >= this._source.length) return;
|
|
5544
|
+
return this._source[this._position];
|
|
5545
5545
|
}
|
|
5546
5546
|
/**
|
|
5547
5547
|
* Peeks at the next character without consuming current.
|
|
5548
5548
|
*/
|
|
5549
5549
|
peekNext() {
|
|
5550
|
-
if (this
|
|
5551
|
-
return this
|
|
5550
|
+
if (this._position + 1 >= this._source.length) return;
|
|
5551
|
+
return this._source[this._position + 1];
|
|
5552
5552
|
}
|
|
5553
5553
|
/**
|
|
5554
5554
|
* Advances the position by n characters.
|
|
5555
5555
|
*/
|
|
5556
5556
|
bump(n = 1) {
|
|
5557
|
-
this
|
|
5557
|
+
this._position = Math.min(this._position + n, this._source.length);
|
|
5558
5558
|
}
|
|
5559
5559
|
/**
|
|
5560
5560
|
* Skips whitespace.
|
|
5561
5561
|
*/
|
|
5562
|
-
|
|
5563
|
-
while (this
|
|
5564
|
-
const ch = this
|
|
5565
|
-
if (ch !== void 0 && isWhitespace(ch)) this
|
|
5562
|
+
_skipWhitespace() {
|
|
5563
|
+
while (this._position < this._source.length) {
|
|
5564
|
+
const ch = this._source[this._position];
|
|
5565
|
+
if (ch !== void 0 && isWhitespace(ch)) this._position++;
|
|
5566
5566
|
else break;
|
|
5567
5567
|
}
|
|
5568
5568
|
}
|
|
5569
5569
|
/**
|
|
5570
5570
|
* Parses a string literal (after the opening quote).
|
|
5571
5571
|
*/
|
|
5572
|
-
|
|
5572
|
+
_parseStringLiteral() {
|
|
5573
5573
|
const src = this.remainder();
|
|
5574
5574
|
let escape = false;
|
|
5575
5575
|
let content = "";
|
|
@@ -5613,7 +5613,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
5613
5613
|
/**
|
|
5614
5614
|
* Parses a regex pattern (after the opening slash).
|
|
5615
5615
|
*/
|
|
5616
|
-
|
|
5616
|
+
_parseRegex() {
|
|
5617
5617
|
const src = this.remainder();
|
|
5618
5618
|
let escape = false;
|
|
5619
5619
|
for (let i = 0; i < src.length; i++) {
|
|
@@ -5640,7 +5640,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
5640
5640
|
/**
|
|
5641
5641
|
* Parses a hex pattern (after h').
|
|
5642
5642
|
*/
|
|
5643
|
-
|
|
5643
|
+
_parseHexPattern() {
|
|
5644
5644
|
const src = this.remainder();
|
|
5645
5645
|
for (let i = 0; i < src.length; i++) {
|
|
5646
5646
|
const ch = src[i];
|
|
@@ -5664,7 +5664,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
5664
5664
|
/**
|
|
5665
5665
|
* Parses a hex binary regex (after h'/).
|
|
5666
5666
|
*/
|
|
5667
|
-
|
|
5667
|
+
_parseHexBinaryRegex() {
|
|
5668
5668
|
const src = this.remainder();
|
|
5669
5669
|
let escape = false;
|
|
5670
5670
|
for (let i = 0; i < src.length; i++) {
|
|
@@ -5692,7 +5692,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
5692
5692
|
/**
|
|
5693
5693
|
* Parses a date pattern (after date').
|
|
5694
5694
|
*/
|
|
5695
|
-
|
|
5695
|
+
_parseDatePattern() {
|
|
5696
5696
|
const src = this.remainder();
|
|
5697
5697
|
for (let i = 0; i < src.length; i++) if (src[i] === "'") {
|
|
5698
5698
|
const content = src.slice(0, i);
|
|
@@ -5704,7 +5704,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
5704
5704
|
/**
|
|
5705
5705
|
* Parses a range pattern (after {).
|
|
5706
5706
|
*/
|
|
5707
|
-
|
|
5707
|
+
_parseRange() {
|
|
5708
5708
|
const src = this.remainder();
|
|
5709
5709
|
let pos = 0;
|
|
5710
5710
|
while (pos < src.length && src[pos] !== void 0 && isWhitespace(src[pos])) pos++;
|
|
@@ -5753,7 +5753,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
5753
5753
|
/**
|
|
5754
5754
|
* Parses a single quoted pattern (after ').
|
|
5755
5755
|
*/
|
|
5756
|
-
|
|
5756
|
+
_parseSingleQuotedPattern() {
|
|
5757
5757
|
const src = this.remainder();
|
|
5758
5758
|
for (let i = 0; i < src.length; i++) if (src[i] === "'") {
|
|
5759
5759
|
const content = src.slice(0, i);
|
|
@@ -5765,7 +5765,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
5765
5765
|
/**
|
|
5766
5766
|
* Parses a single quoted regex (after '/).
|
|
5767
5767
|
*/
|
|
5768
|
-
|
|
5768
|
+
_parseSingleQuotedRegex() {
|
|
5769
5769
|
const src = this.remainder();
|
|
5770
5770
|
let escape = false;
|
|
5771
5771
|
for (let i = 0; i < src.length; i++) {
|
|
@@ -5793,8 +5793,8 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
5793
5793
|
/**
|
|
5794
5794
|
* Parses a number (integer or float).
|
|
5795
5795
|
*/
|
|
5796
|
-
|
|
5797
|
-
const startPos = this
|
|
5796
|
+
_parseNumber() {
|
|
5797
|
+
const startPos = this._position;
|
|
5798
5798
|
let isFloat = false;
|
|
5799
5799
|
let isNegative = false;
|
|
5800
5800
|
if (this.peek() === "-") {
|
|
@@ -5826,16 +5826,16 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
5826
5826
|
c = this.peek();
|
|
5827
5827
|
}
|
|
5828
5828
|
}
|
|
5829
|
-
const numStr = this
|
|
5829
|
+
const numStr = this._source.slice(startPos, this._position);
|
|
5830
5830
|
if (isFloat) {
|
|
5831
|
-
const value
|
|
5832
|
-
if (Number.isNaN(value
|
|
5831
|
+
const value = parseFloat(numStr);
|
|
5832
|
+
if (Number.isNaN(value)) return {
|
|
5833
5833
|
type: "Float",
|
|
5834
5834
|
value: err(invalidNumberFormat(this.span()))
|
|
5835
5835
|
};
|
|
5836
5836
|
return {
|
|
5837
5837
|
type: "Float",
|
|
5838
|
-
value: ok(value
|
|
5838
|
+
value: ok(value)
|
|
5839
5839
|
};
|
|
5840
5840
|
}
|
|
5841
5841
|
const value = parseInt(numStr, 10);
|
|
@@ -5856,25 +5856,25 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
5856
5856
|
* Gets the next token from the input.
|
|
5857
5857
|
*/
|
|
5858
5858
|
next() {
|
|
5859
|
-
if (this
|
|
5860
|
-
const peeked = this
|
|
5861
|
-
this
|
|
5859
|
+
if (this._peekedToken !== void 0) {
|
|
5860
|
+
const peeked = this._peekedToken;
|
|
5861
|
+
this._peekedToken = void 0;
|
|
5862
5862
|
return peeked;
|
|
5863
5863
|
}
|
|
5864
|
-
this
|
|
5865
|
-
this
|
|
5866
|
-
if (this
|
|
5867
|
-
const ch = this
|
|
5864
|
+
this._skipWhitespace();
|
|
5865
|
+
this._tokenStart = this._position;
|
|
5866
|
+
if (this._position >= this._source.length) return;
|
|
5867
|
+
const ch = this._source[this._position];
|
|
5868
5868
|
if (ch === void 0) return void 0;
|
|
5869
|
-
const twoChar = this
|
|
5870
|
-
if (this
|
|
5869
|
+
const twoChar = this._source.slice(this._position, this._position + 2);
|
|
5870
|
+
if (this._source.slice(this._position, this._position + 3) === "...") {
|
|
5871
5871
|
this.bump(3);
|
|
5872
5872
|
return {
|
|
5873
5873
|
token: { type: "Ellipsis" },
|
|
5874
5874
|
span: this.span()
|
|
5875
5875
|
};
|
|
5876
5876
|
}
|
|
5877
|
-
if (this
|
|
5877
|
+
if (this._source.slice(this._position, this._position + 9) === "-Infinity") {
|
|
5878
5878
|
this.bump(9);
|
|
5879
5879
|
return {
|
|
5880
5880
|
token: { type: "NegativeInfinity" },
|
|
@@ -5943,7 +5943,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
5943
5943
|
return {
|
|
5944
5944
|
token: {
|
|
5945
5945
|
type: "HexBinaryRegex",
|
|
5946
|
-
value: this
|
|
5946
|
+
value: this._parseHexBinaryRegex()
|
|
5947
5947
|
},
|
|
5948
5948
|
span: this.span()
|
|
5949
5949
|
};
|
|
@@ -5951,7 +5951,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
5951
5951
|
return {
|
|
5952
5952
|
token: {
|
|
5953
5953
|
type: "HexPattern",
|
|
5954
|
-
value: this
|
|
5954
|
+
value: this._parseHexPattern()
|
|
5955
5955
|
},
|
|
5956
5956
|
span: this.span()
|
|
5957
5957
|
};
|
|
@@ -5960,7 +5960,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
5960
5960
|
return {
|
|
5961
5961
|
token: {
|
|
5962
5962
|
type: "SingleQuotedRegex",
|
|
5963
|
-
value: this
|
|
5963
|
+
value: this._parseSingleQuotedRegex()
|
|
5964
5964
|
},
|
|
5965
5965
|
span: this.span()
|
|
5966
5966
|
};
|
|
@@ -6049,7 +6049,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
6049
6049
|
return {
|
|
6050
6050
|
token: {
|
|
6051
6051
|
type: "StringLiteral",
|
|
6052
|
-
value: this
|
|
6052
|
+
value: this._parseStringLiteral()
|
|
6053
6053
|
},
|
|
6054
6054
|
span: this.span()
|
|
6055
6055
|
};
|
|
@@ -6058,7 +6058,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
6058
6058
|
return {
|
|
6059
6059
|
token: {
|
|
6060
6060
|
type: "Regex",
|
|
6061
|
-
value: this
|
|
6061
|
+
value: this._parseRegex()
|
|
6062
6062
|
},
|
|
6063
6063
|
span: this.span()
|
|
6064
6064
|
};
|
|
@@ -6067,7 +6067,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
6067
6067
|
return {
|
|
6068
6068
|
token: {
|
|
6069
6069
|
type: "Range",
|
|
6070
|
-
value: this
|
|
6070
|
+
value: this._parseRange()
|
|
6071
6071
|
},
|
|
6072
6072
|
span: this.span()
|
|
6073
6073
|
};
|
|
@@ -6076,13 +6076,13 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
6076
6076
|
return {
|
|
6077
6077
|
token: {
|
|
6078
6078
|
type: "SingleQuotedPattern",
|
|
6079
|
-
value: this
|
|
6079
|
+
value: this._parseSingleQuotedPattern()
|
|
6080
6080
|
},
|
|
6081
6081
|
span: this.span()
|
|
6082
6082
|
};
|
|
6083
6083
|
case "@": {
|
|
6084
6084
|
this.bump(1);
|
|
6085
|
-
const start = this
|
|
6085
|
+
const start = this._position;
|
|
6086
6086
|
let gc = this.peek();
|
|
6087
6087
|
if (gc !== void 0 && isIdentStart(gc)) {
|
|
6088
6088
|
gc = this.peek();
|
|
@@ -6093,7 +6093,7 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
6093
6093
|
return {
|
|
6094
6094
|
token: {
|
|
6095
6095
|
type: "GroupName",
|
|
6096
|
-
name: this
|
|
6096
|
+
name: this._source.slice(start, this._position)
|
|
6097
6097
|
},
|
|
6098
6098
|
span: this.span()
|
|
6099
6099
|
};
|
|
@@ -6107,29 +6107,29 @@ var bctsEnvelopePattern = (function(exports, _bcts_dcbor_pattern, _bcts_known_va
|
|
|
6107
6107
|
};
|
|
6108
6108
|
}
|
|
6109
6109
|
}
|
|
6110
|
-
if (this
|
|
6110
|
+
if (this._source.slice(this._position, this._position + 5) === "date'") {
|
|
6111
6111
|
this.bump(5);
|
|
6112
6112
|
return {
|
|
6113
6113
|
token: {
|
|
6114
6114
|
type: "DatePattern",
|
|
6115
|
-
value: this
|
|
6115
|
+
value: this._parseDatePattern()
|
|
6116
6116
|
},
|
|
6117
6117
|
span: this.span()
|
|
6118
6118
|
};
|
|
6119
6119
|
}
|
|
6120
6120
|
const nextChar = this.peekNext();
|
|
6121
6121
|
if (isDigit(ch) || ch === "-" && nextChar !== void 0 && isDigit(nextChar)) return {
|
|
6122
|
-
token: this
|
|
6122
|
+
token: this._parseNumber(),
|
|
6123
6123
|
span: this.span()
|
|
6124
6124
|
};
|
|
6125
6125
|
if (isIdentStart(ch)) {
|
|
6126
|
-
const start = this
|
|
6126
|
+
const start = this._position;
|
|
6127
6127
|
let ic = this.peek();
|
|
6128
6128
|
while (ic !== void 0 && isIdentContinue(ic)) {
|
|
6129
6129
|
this.bump(1);
|
|
6130
6130
|
ic = this.peek();
|
|
6131
6131
|
}
|
|
6132
|
-
const ident = this
|
|
6132
|
+
const ident = this._source.slice(start, this._position);
|
|
6133
6133
|
const keyword = KEYWORDS.get(ident);
|
|
6134
6134
|
if (keyword !== void 0) return {
|
|
6135
6135
|
token: keyword,
|