@bcts/dcbor-parse 1.0.0-alpha.16 → 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.
@@ -27,120 +27,120 @@ var bctsDcborParse = (function(exports, _bcts_dcbor, _bcts_known_values, _bcts_u
27
27
  unexpectedEndOfInput() {
28
28
  return { type: "UnexpectedEndOfInput" };
29
29
  },
30
- extraData(span$1) {
30
+ extraData(span) {
31
31
  return {
32
32
  type: "ExtraData",
33
- span: span$1
33
+ span
34
34
  };
35
35
  },
36
- unexpectedToken(token$1, span$1) {
36
+ unexpectedToken(token, span) {
37
37
  return {
38
38
  type: "UnexpectedToken",
39
- token: token$1,
40
- span: span$1
39
+ token,
40
+ span
41
41
  };
42
42
  },
43
- unrecognizedToken(span$1) {
43
+ unrecognizedToken(span) {
44
44
  return {
45
45
  type: "UnrecognizedToken",
46
- span: span$1
46
+ span
47
47
  };
48
48
  },
49
- expectedComma(span$1) {
49
+ expectedComma(span) {
50
50
  return {
51
51
  type: "ExpectedComma",
52
- span: span$1
52
+ span
53
53
  };
54
54
  },
55
- expectedColon(span$1) {
55
+ expectedColon(span) {
56
56
  return {
57
57
  type: "ExpectedColon",
58
- span: span$1
58
+ span
59
59
  };
60
60
  },
61
- unmatchedParentheses(span$1) {
61
+ unmatchedParentheses(span) {
62
62
  return {
63
63
  type: "UnmatchedParentheses",
64
- span: span$1
64
+ span
65
65
  };
66
66
  },
67
- unmatchedBraces(span$1) {
67
+ unmatchedBraces(span) {
68
68
  return {
69
69
  type: "UnmatchedBraces",
70
- span: span$1
70
+ span
71
71
  };
72
72
  },
73
- expectedMapKey(span$1) {
73
+ expectedMapKey(span) {
74
74
  return {
75
75
  type: "ExpectedMapKey",
76
- span: span$1
76
+ span
77
77
  };
78
78
  },
79
- invalidTagValue(value, span$1) {
79
+ invalidTagValue(value, span) {
80
80
  return {
81
81
  type: "InvalidTagValue",
82
82
  value,
83
- span: span$1
83
+ span
84
84
  };
85
85
  },
86
- unknownTagName(name, span$1) {
86
+ unknownTagName(name, span) {
87
87
  return {
88
88
  type: "UnknownTagName",
89
89
  name,
90
- span: span$1
90
+ span
91
91
  };
92
92
  },
93
- invalidHexString(span$1) {
93
+ invalidHexString(span) {
94
94
  return {
95
95
  type: "InvalidHexString",
96
- span: span$1
96
+ span
97
97
  };
98
98
  },
99
- invalidBase64String(span$1) {
99
+ invalidBase64String(span) {
100
100
  return {
101
101
  type: "InvalidBase64String",
102
- span: span$1
102
+ span
103
103
  };
104
104
  },
105
- unknownUrType(urType, span$1) {
105
+ unknownUrType(urType, span) {
106
106
  return {
107
107
  type: "UnknownUrType",
108
108
  urType,
109
- span: span$1
109
+ span
110
110
  };
111
111
  },
112
- invalidUr(message, span$1) {
112
+ invalidUr(message, span) {
113
113
  return {
114
114
  type: "InvalidUr",
115
115
  message,
116
- span: span$1
116
+ span
117
117
  };
118
118
  },
119
- invalidKnownValue(value, span$1) {
119
+ invalidKnownValue(value, span) {
120
120
  return {
121
121
  type: "InvalidKnownValue",
122
122
  value,
123
- span: span$1
123
+ span
124
124
  };
125
125
  },
126
- unknownKnownValueName(name, span$1) {
126
+ unknownKnownValueName(name, span) {
127
127
  return {
128
128
  type: "UnknownKnownValueName",
129
129
  name,
130
- span: span$1
130
+ span
131
131
  };
132
132
  },
133
- invalidDateString(dateString, span$1) {
133
+ invalidDateString(dateString, span) {
134
134
  return {
135
135
  type: "InvalidDateString",
136
136
  dateString,
137
- span: span$1
137
+ span
138
138
  };
139
139
  },
140
- duplicateMapKey(span$1) {
140
+ duplicateMapKey(span) {
141
141
  return {
142
142
  type: "DuplicateMapKey",
143
- span: span$1
143
+ span
144
144
  };
145
145
  }
146
146
  };
@@ -310,8 +310,8 @@ var bctsDcborParse = (function(exports, _bcts_dcbor, _bcts_known_values, _bcts_u
310
310
  if (!result.ok) return result.error;
311
311
  throw new Error("Called unwrapErr on an Ok result");
312
312
  }
313
- function tokenDebugString(token$1) {
314
- return JSON.stringify(token$1);
313
+ function tokenDebugString(token) {
314
+ return JSON.stringify(token);
315
315
  }
316
316
 
317
317
  //#endregion
@@ -436,65 +436,65 @@ var bctsDcborParse = (function(exports, _bcts_dcbor, _bcts_known_values, _bcts_u
436
436
  * Corresponds to the Rust `logos::Lexer` used in parse.rs
437
437
  */
438
438
  var Lexer = class {
439
- #source;
440
- #position;
441
- #tokenStart;
442
- #tokenEnd;
439
+ _source;
440
+ _position;
441
+ _tokenStart;
442
+ _tokenEnd;
443
443
  constructor(source) {
444
- this.#source = source;
445
- this.#position = 0;
446
- this.#tokenStart = 0;
447
- this.#tokenEnd = 0;
444
+ this._source = source;
445
+ this._position = 0;
446
+ this._tokenStart = 0;
447
+ this._tokenEnd = 0;
448
448
  }
449
449
  /**
450
450
  * Gets the current span (position range of the last token).
451
451
  */
452
452
  span() {
453
- return span(this.#tokenStart, this.#tokenEnd);
453
+ return span(this._tokenStart, this._tokenEnd);
454
454
  }
455
455
  /**
456
456
  * Gets the slice of source corresponding to the last token.
457
457
  */
458
458
  slice() {
459
- return this.#source.slice(this.#tokenStart, this.#tokenEnd);
459
+ return this._source.slice(this._tokenStart, this._tokenEnd);
460
460
  }
461
461
  /**
462
462
  * Gets the next token, or undefined if at end of input.
463
463
  * Returns a Result to handle lexing errors.
464
464
  */
465
465
  next() {
466
- this.#skipWhitespaceAndComments();
467
- if (this.#position >= this.#source.length) return;
468
- this.#tokenStart = this.#position;
469
- const result = this.#tryMatchKeyword() ?? this.#tryMatchDateLiteral() ?? this.#tryMatchTagValueOrNumber() ?? this.#tryMatchTagName() ?? this.#tryMatchString() ?? this.#tryMatchByteStringHex() ?? this.#tryMatchByteStringBase64() ?? this.#tryMatchKnownValue() ?? this.#tryMatchUR() ?? this.#tryMatchPunctuation();
466
+ this._skipWhitespaceAndComments();
467
+ if (this._position >= this._source.length) return;
468
+ this._tokenStart = this._position;
469
+ const result = this._tryMatchKeyword() ?? this._tryMatchDateLiteral() ?? this._tryMatchTagValueOrNumber() ?? this._tryMatchTagName() ?? this._tryMatchString() ?? this._tryMatchByteStringHex() ?? this._tryMatchByteStringBase64() ?? this._tryMatchKnownValue() ?? this._tryMatchUR() ?? this._tryMatchPunctuation();
470
470
  if (result === void 0) {
471
- this.#position++;
472
- this.#tokenEnd = this.#position;
471
+ this._position++;
472
+ this._tokenEnd = this._position;
473
473
  return err(parseError.unrecognizedToken(this.span()));
474
474
  }
475
475
  return result;
476
476
  }
477
- #skipWhitespaceAndComments() {
478
- while (this.#position < this.#source.length) {
479
- const ch = this.#source[this.#position];
477
+ _skipWhitespaceAndComments() {
478
+ while (this._position < this._source.length) {
479
+ const ch = this._source[this._position];
480
480
  if (ch === " " || ch === " " || ch === "\r" || ch === "\n" || ch === "\f") {
481
- this.#position++;
481
+ this._position++;
482
482
  continue;
483
483
  }
484
- if (ch === "/" && this.#position + 1 < this.#source.length && this.#source[this.#position + 1] !== "/") {
485
- this.#position++;
486
- while (this.#position < this.#source.length && this.#source[this.#position] !== "/") this.#position++;
487
- if (this.#position < this.#source.length) this.#position++;
484
+ if (ch === "/" && this._position + 1 < this._source.length && this._source[this._position + 1] !== "/") {
485
+ this._position++;
486
+ while (this._position < this._source.length && this._source[this._position] !== "/") this._position++;
487
+ if (this._position < this._source.length) this._position++;
488
488
  continue;
489
489
  }
490
490
  if (ch === "#") {
491
- while (this.#position < this.#source.length && this.#source[this.#position] !== "\n") this.#position++;
491
+ while (this._position < this._source.length && this._source[this._position] !== "\n") this._position++;
492
492
  continue;
493
493
  }
494
494
  break;
495
495
  }
496
496
  }
497
- #tryMatchKeyword() {
497
+ _tryMatchKeyword() {
498
498
  const keywords = [
499
499
  ["true", token.bool(true)],
500
500
  ["false", token.bool(false)],
@@ -504,23 +504,23 @@ var bctsDcborParse = (function(exports, _bcts_dcbor, _bcts_known_values, _bcts_u
504
504
  ["-Infinity", token.negInfinity()],
505
505
  ["Unit", token.unit()]
506
506
  ];
507
- for (const [keyword, tok] of keywords) if (this.#matchLiteral(keyword)) {
508
- const nextChar = this.#source[this.#position];
509
- if (nextChar === void 0 || !this.#isIdentifierChar(nextChar)) {
510
- this.#tokenEnd = this.#position;
507
+ for (const [keyword, tok] of keywords) if (this._matchLiteral(keyword)) {
508
+ const nextChar = this._source[this._position];
509
+ if (nextChar === void 0 || !this._isIdentifierChar(nextChar)) {
510
+ this._tokenEnd = this._position;
511
511
  return ok(tok);
512
512
  }
513
- this.#position = this.#tokenStart;
513
+ this._position = this._tokenStart;
514
514
  }
515
515
  }
516
- #tryMatchDateLiteral() {
516
+ _tryMatchDateLiteral() {
517
517
  const dateRegex = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?)?/;
518
- const remaining = this.#source.slice(this.#position);
518
+ const remaining = this._source.slice(this._position);
519
519
  const match = dateRegex.exec(remaining);
520
520
  if (match !== null) {
521
521
  const dateStr = match[0];
522
- this.#position += dateStr.length;
523
- this.#tokenEnd = this.#position;
522
+ this._position += dateStr.length;
523
+ this._tokenEnd = this._position;
524
524
  if (!isValidDateString(dateStr)) return err(parseError.invalidDateString(dateStr, this.span()));
525
525
  try {
526
526
  const date = _bcts_dcbor.CborDate.fromString(dateStr);
@@ -530,91 +530,91 @@ var bctsDcborParse = (function(exports, _bcts_dcbor, _bcts_known_values, _bcts_u
530
530
  }
531
531
  }
532
532
  }
533
- #tryMatchTagValueOrNumber() {
533
+ _tryMatchTagValueOrNumber() {
534
534
  const numberRegex = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/;
535
- const remaining = this.#source.slice(this.#position);
535
+ const remaining = this._source.slice(this._position);
536
536
  const match = numberRegex.exec(remaining);
537
537
  if (match !== null) {
538
538
  const numStr = match[0];
539
- if (this.#source[this.#position + numStr.length] === "(" && !numStr.includes(".") && !numStr.includes("e") && !numStr.includes("E") && !numStr.startsWith("-")) {
540
- this.#position += numStr.length + 1;
541
- this.#tokenEnd = this.#position;
539
+ if (this._source[this._position + numStr.length] === "(" && !numStr.includes(".") && !numStr.includes("e") && !numStr.includes("E") && !numStr.startsWith("-")) {
540
+ this._position += numStr.length + 1;
541
+ this._tokenEnd = this._position;
542
542
  const tagValue = parseInt(numStr, 10);
543
- if (!Number.isSafeInteger(tagValue) || tagValue < 0) return err(parseError.invalidTagValue(numStr, span(this.#tokenStart, this.#tokenStart + numStr.length)));
543
+ if (!Number.isSafeInteger(tagValue) || tagValue < 0) return err(parseError.invalidTagValue(numStr, span(this._tokenStart, this._tokenStart + numStr.length)));
544
544
  return ok(token.tagValue(tagValue));
545
545
  }
546
- this.#position += numStr.length;
547
- this.#tokenEnd = this.#position;
546
+ this._position += numStr.length;
547
+ this._tokenEnd = this._position;
548
548
  const num = parseFloat(numStr);
549
549
  return ok(token.number(num));
550
550
  }
551
551
  }
552
- #tryMatchTagName() {
552
+ _tryMatchTagName() {
553
553
  const tagNameRegex = /^[a-zA-Z_][a-zA-Z0-9_-]*\(/;
554
- const remaining = this.#source.slice(this.#position);
554
+ const remaining = this._source.slice(this._position);
555
555
  const match = tagNameRegex.exec(remaining);
556
556
  if (match !== null) {
557
557
  const fullMatch = match[0];
558
558
  const name = fullMatch.slice(0, -1);
559
- this.#position += fullMatch.length;
560
- this.#tokenEnd = this.#position;
559
+ this._position += fullMatch.length;
560
+ this._tokenEnd = this._position;
561
561
  return ok(token.tagName(name));
562
562
  }
563
563
  }
564
- #tryMatchString() {
565
- if (this.#source[this.#position] !== "\"") return;
564
+ _tryMatchString() {
565
+ if (this._source[this._position] !== "\"") return;
566
566
  const stringRegex = /^"([^"\\\x00-\x1F]|\\(["\\bnfrt/]|u[a-fA-F0-9]{4}))*"/;
567
- const remaining = this.#source.slice(this.#position);
567
+ const remaining = this._source.slice(this._position);
568
568
  const match = stringRegex.exec(remaining);
569
569
  if (match !== null) {
570
570
  const fullMatch = match[0];
571
- this.#position += fullMatch.length;
572
- this.#tokenEnd = this.#position;
571
+ this._position += fullMatch.length;
572
+ this._tokenEnd = this._position;
573
573
  return ok(token.string(fullMatch));
574
574
  }
575
- this.#position++;
576
- while (this.#position < this.#source.length) {
577
- const ch = this.#source[this.#position];
575
+ this._position++;
576
+ while (this._position < this._source.length) {
577
+ const ch = this._source[this._position];
578
578
  if (ch === "\"" || ch === "\n") {
579
- if (ch === "\"") this.#position++;
579
+ if (ch === "\"") this._position++;
580
580
  break;
581
581
  }
582
- if (ch === "\\") this.#position += 2;
583
- else this.#position++;
582
+ if (ch === "\\") this._position += 2;
583
+ else this._position++;
584
584
  }
585
- this.#tokenEnd = this.#position;
585
+ this._tokenEnd = this._position;
586
586
  return err(parseError.unrecognizedToken(this.span()));
587
587
  }
588
- #tryMatchByteStringHex() {
589
- if (!this.#matchLiteral("h'")) return;
588
+ _tryMatchByteStringHex() {
589
+ if (!this._matchLiteral("h'")) return;
590
590
  const hexRegex = /^[0-9a-fA-F]*/;
591
- const remaining = this.#source.slice(this.#position);
591
+ const remaining = this._source.slice(this._position);
592
592
  const match = hexRegex.exec(remaining);
593
593
  const hexPart = match !== null ? match[0] : "";
594
- this.#position += hexPart.length;
595
- if (this.#source[this.#position] !== "'") {
596
- this.#tokenEnd = this.#position;
594
+ this._position += hexPart.length;
595
+ if (this._source[this._position] !== "'") {
596
+ this._tokenEnd = this._position;
597
597
  return err(parseError.invalidHexString(this.span()));
598
598
  }
599
- this.#position++;
600
- this.#tokenEnd = this.#position;
599
+ this._position++;
600
+ this._tokenEnd = this._position;
601
601
  if (hexPart.length % 2 !== 0) return err(parseError.invalidHexString(this.span()));
602
602
  const bytes = hexToBytes(hexPart);
603
603
  return ok(token.byteStringHex(bytes));
604
604
  }
605
- #tryMatchByteStringBase64() {
606
- if (!this.#matchLiteral("b64'")) return;
605
+ _tryMatchByteStringBase64() {
606
+ if (!this._matchLiteral("b64'")) return;
607
607
  const base64Regex = /^[A-Za-z0-9+/=]*/;
608
- const remaining = this.#source.slice(this.#position);
608
+ const remaining = this._source.slice(this._position);
609
609
  const match = base64Regex.exec(remaining);
610
610
  const base64Part = match !== null ? match[0] : "";
611
- this.#position += base64Part.length;
612
- if (this.#source[this.#position] !== "'") {
613
- this.#tokenEnd = this.#position;
611
+ this._position += base64Part.length;
612
+ if (this._source[this._position] !== "'") {
613
+ this._tokenEnd = this._position;
614
614
  return err(parseError.invalidBase64String(this.span()));
615
615
  }
616
- this.#position++;
617
- this.#tokenEnd = this.#position;
616
+ this._position++;
617
+ this._tokenEnd = this._position;
618
618
  if (base64Part.length < 2) return err(parseError.invalidBase64String(this.span()));
619
619
  try {
620
620
  const bytes = base64ToBytes(base64Part);
@@ -623,47 +623,47 @@ var bctsDcborParse = (function(exports, _bcts_dcbor, _bcts_known_values, _bcts_u
623
623
  return err(parseError.invalidBase64String(this.span()));
624
624
  }
625
625
  }
626
- #tryMatchKnownValue() {
627
- if (this.#source[this.#position] !== "'") return;
628
- if (this.#source[this.#position + 1] === "'") {
629
- this.#position += 2;
630
- this.#tokenEnd = this.#position;
626
+ _tryMatchKnownValue() {
627
+ if (this._source[this._position] !== "'") return;
628
+ if (this._source[this._position + 1] === "'") {
629
+ this._position += 2;
630
+ this._tokenEnd = this._position;
631
631
  return ok(token.knownValueName(""));
632
632
  }
633
633
  const numericRegex = /^'(0|[1-9][0-9]*)'/;
634
- const remaining = this.#source.slice(this.#position);
634
+ const remaining = this._source.slice(this._position);
635
635
  let match = numericRegex.exec(remaining);
636
636
  if (match !== null) {
637
637
  const fullMatch = match[0];
638
638
  const numStr = match[1];
639
- this.#position += fullMatch.length;
640
- this.#tokenEnd = this.#position;
639
+ this._position += fullMatch.length;
640
+ this._tokenEnd = this._position;
641
641
  const value = parseInt(numStr, 10);
642
- if (!Number.isSafeInteger(value) || value < 0) return err(parseError.invalidKnownValue(numStr, span(this.#tokenStart + 1, this.#tokenEnd - 1)));
642
+ if (!Number.isSafeInteger(value) || value < 0) return err(parseError.invalidKnownValue(numStr, span(this._tokenStart + 1, this._tokenEnd - 1)));
643
643
  return ok(token.knownValueNumber(value));
644
644
  }
645
645
  match = /^'([a-zA-Z_][a-zA-Z0-9_-]*)'/.exec(remaining);
646
646
  if (match !== null) {
647
647
  const fullMatch = match[0];
648
648
  const name = match[1];
649
- this.#position += fullMatch.length;
650
- this.#tokenEnd = this.#position;
649
+ this._position += fullMatch.length;
650
+ this._tokenEnd = this._position;
651
651
  return ok(token.knownValueName(name));
652
652
  }
653
- this.#position++;
654
- while (this.#position < this.#source.length && this.#source[this.#position] !== "'") this.#position++;
655
- if (this.#position < this.#source.length) this.#position++;
656
- this.#tokenEnd = this.#position;
653
+ this._position++;
654
+ while (this._position < this._source.length && this._source[this._position] !== "'") this._position++;
655
+ if (this._position < this._source.length) this._position++;
656
+ this._tokenEnd = this._position;
657
657
  return err(parseError.unrecognizedToken(this.span()));
658
658
  }
659
- #tryMatchUR() {
659
+ _tryMatchUR() {
660
660
  const urRegex = /^ur:([a-zA-Z0-9][a-zA-Z0-9-]*)\/([a-zA-Z]{8,})/;
661
- const remaining = this.#source.slice(this.#position);
661
+ const remaining = this._source.slice(this._position);
662
662
  const match = urRegex.exec(remaining);
663
663
  if (match !== null) {
664
664
  const fullMatch = match[0];
665
- this.#position += fullMatch.length;
666
- this.#tokenEnd = this.#position;
665
+ this._position += fullMatch.length;
666
+ this._tokenEnd = this._position;
667
667
  try {
668
668
  const ur = _bcts_uniform_resources.UR.fromURString(fullMatch);
669
669
  return ok(token.ur(ur));
@@ -673,8 +673,8 @@ var bctsDcborParse = (function(exports, _bcts_dcbor, _bcts_known_values, _bcts_u
673
673
  }
674
674
  }
675
675
  }
676
- #tryMatchPunctuation() {
677
- const ch = this.#source[this.#position];
676
+ _tryMatchPunctuation() {
677
+ const ch = this._source[this._position];
678
678
  const matched = {
679
679
  "{": token.braceOpen(),
680
680
  "}": token.braceClose(),
@@ -686,19 +686,19 @@ var bctsDcborParse = (function(exports, _bcts_dcbor, _bcts_known_values, _bcts_u
686
686
  ",": token.comma()
687
687
  }[ch];
688
688
  if (matched !== void 0) {
689
- this.#position++;
690
- this.#tokenEnd = this.#position;
689
+ this._position++;
690
+ this._tokenEnd = this._position;
691
691
  return ok(matched);
692
692
  }
693
693
  }
694
- #matchLiteral(literal) {
695
- if (this.#source.slice(this.#position, this.#position + literal.length) === literal) {
696
- this.#position += literal.length;
694
+ _matchLiteral(literal) {
695
+ if (this._source.slice(this._position, this._position + literal.length) === literal) {
696
+ this._position += literal.length;
697
697
  return true;
698
698
  }
699
699
  return false;
700
700
  }
701
- #isIdentifierChar(ch) {
701
+ _isIdentifierChar(ch) {
702
702
  return /[a-zA-Z0-9_-]/.test(ch);
703
703
  }
704
704
  };
@@ -855,28 +855,28 @@ var bctsDcborParse = (function(exports, _bcts_dcbor, _bcts_known_values, _bcts_u
855
855
  }
856
856
  return result;
857
857
  }
858
- function parseItemToken(token$1, lexer) {
859
- switch (token$1.type) {
860
- case "Bool": return ok((0, _bcts_dcbor.cbor)(token$1.value));
858
+ function parseItemToken(token, lexer) {
859
+ switch (token.type) {
860
+ case "Bool": return ok((0, _bcts_dcbor.cbor)(token.value));
861
861
  case "Null": return ok((0, _bcts_dcbor.cbor)(null));
862
- case "ByteStringHex": return ok((0, _bcts_dcbor.cbor)(token$1.value));
863
- case "ByteStringBase64": return ok((0, _bcts_dcbor.cbor)(token$1.value));
864
- case "DateLiteral": return ok((0, _bcts_dcbor.cbor)(token$1.value));
865
- case "Number": return ok((0, _bcts_dcbor.cbor)(token$1.value));
862
+ case "ByteStringHex": return ok((0, _bcts_dcbor.cbor)(token.value));
863
+ case "ByteStringBase64": return ok((0, _bcts_dcbor.cbor)(token.value));
864
+ case "DateLiteral": return ok((0, _bcts_dcbor.cbor)(token.value));
865
+ case "Number": return ok((0, _bcts_dcbor.cbor)(token.value));
866
866
  case "NaN": return ok((0, _bcts_dcbor.cbor)(NaN));
867
867
  case "Infinity": return ok((0, _bcts_dcbor.cbor)(Number.POSITIVE_INFINITY));
868
868
  case "NegInfinity": return ok((0, _bcts_dcbor.cbor)(Number.NEGATIVE_INFINITY));
869
- case "String": return parseString(token$1.value, lexer.span());
870
- case "UR": return parseUr(token$1.value, lexer.span());
871
- case "TagValue": return parseNumberTag(token$1.value, lexer);
872
- case "TagName": return parseNameTag(token$1.value, lexer);
873
- case "KnownValueNumber": return ok(new _bcts_known_values.KnownValue(token$1.value).taggedCbor());
869
+ case "String": return parseString(token.value, lexer.span());
870
+ case "UR": return parseUr(token.value, lexer.span());
871
+ case "TagValue": return parseNumberTag(token.value, lexer);
872
+ case "TagName": return parseNameTag(token.value, lexer);
873
+ case "KnownValueNumber": return ok(new _bcts_known_values.KnownValue(token.value).taggedCbor());
874
874
  case "KnownValueName": {
875
- if (token$1.value === "") return ok(new _bcts_known_values.KnownValue(0).taggedCbor());
876
- const knownValue = knownValueForName(token$1.value);
875
+ if (token.value === "") return ok(new _bcts_known_values.KnownValue(0).taggedCbor());
876
+ const knownValue = knownValueForName(token.value);
877
877
  if (knownValue !== void 0) return ok(knownValue.taggedCbor());
878
878
  const tokenSpan = lexer.span();
879
- return err(parseError.unknownKnownValueName(token$1.value, span(tokenSpan.start + 1, tokenSpan.end - 1)));
879
+ return err(parseError.unknownKnownValueName(token.value, span(tokenSpan.start + 1, tokenSpan.end - 1)));
880
880
  }
881
881
  case "Unit": return ok(new _bcts_known_values.KnownValue(0).taggedCbor());
882
882
  case "BracketOpen": return parseArray(lexer);
@@ -886,7 +886,7 @@ var bctsDcborParse = (function(exports, _bcts_dcbor, _bcts_known_values, _bcts_u
886
886
  case "ParenthesisOpen":
887
887
  case "ParenthesisClose":
888
888
  case "Colon":
889
- case "Comma": return err(parseError.unexpectedToken(token$1, lexer.span()));
889
+ case "Comma": return err(parseError.unexpectedToken(token, lexer.span()));
890
890
  }
891
891
  }
892
892
  function parseString(s, tokenSpan) {
@@ -945,15 +945,15 @@ var bctsDcborParse = (function(exports, _bcts_dcbor, _bcts_known_values, _bcts_u
945
945
  while (true) {
946
946
  const tokenResult = expectToken(lexer);
947
947
  if (!tokenResult.ok) return tokenResult;
948
- const token$1 = tokenResult.value;
949
- if (token$1.type === "BracketClose" && !awaitsItem) return ok((0, _bcts_dcbor.cbor)(items));
950
- if (token$1.type === "Comma" && awaitsComma) {
948
+ const token = tokenResult.value;
949
+ if (token.type === "BracketClose" && !awaitsItem) return ok((0, _bcts_dcbor.cbor)(items));
950
+ if (token.type === "Comma" && awaitsComma) {
951
951
  awaitsItem = true;
952
952
  awaitsComma = false;
953
953
  continue;
954
954
  }
955
955
  if (awaitsComma) return err(parseError.expectedComma(lexer.span()));
956
- const itemResult = parseItemToken(token$1, lexer);
956
+ const itemResult = parseItemToken(token, lexer);
957
957
  if (!itemResult.ok) return itemResult;
958
958
  items.push(itemResult.value);
959
959
  awaitsItem = false;
@@ -970,15 +970,15 @@ var bctsDcborParse = (function(exports, _bcts_dcbor, _bcts_known_values, _bcts_u
970
970
  if (tokenResult.error.type === "UnexpectedEndOfInput") return err(parseError.unmatchedBraces(lexer.span()));
971
971
  return tokenResult;
972
972
  }
973
- const token$1 = tokenResult.value;
974
- if (token$1.type === "BraceClose" && !awaitsKey) return ok((0, _bcts_dcbor.cbor)(map));
975
- if (token$1.type === "Comma" && awaitsComma) {
973
+ const token = tokenResult.value;
974
+ if (token.type === "BraceClose" && !awaitsKey) return ok((0, _bcts_dcbor.cbor)(map));
975
+ if (token.type === "Comma" && awaitsComma) {
976
976
  awaitsKey = true;
977
977
  awaitsComma = false;
978
978
  continue;
979
979
  }
980
980
  if (awaitsComma) return err(parseError.expectedComma(lexer.span()));
981
- const keyResult = parseItemToken(token$1, lexer);
981
+ const keyResult = parseItemToken(token, lexer);
982
982
  if (!keyResult.ok) return keyResult;
983
983
  const key = keyResult.value;
984
984
  const keySpan = lexer.span();