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