links-notation 0.21.2 → 0.21.3

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.
@@ -182,11 +182,11 @@ function peg$parse(input, options) {
182
182
 
183
183
  const peg$e0 = peg$classExpectation([" ", "\t"], false, false, false);
184
184
  const peg$e1 = peg$classExpectation(["\r", "\n"], false, false, false);
185
- const peg$e2 = peg$literalExpectation("(", false);
186
- const peg$e3 = peg$literalExpectation(")", false);
187
- const peg$e4 = peg$literalExpectation(":", false);
188
- const peg$e5 = peg$literalExpectation("\"", false);
189
- const peg$e6 = peg$anyExpectation();
185
+ const peg$e2 = peg$anyExpectation();
186
+ const peg$e3 = peg$literalExpectation("(", false);
187
+ const peg$e4 = peg$literalExpectation(")", false);
188
+ const peg$e5 = peg$literalExpectation(":", false);
189
+ const peg$e6 = peg$literalExpectation("\"", false);
190
190
  const peg$e7 = peg$literalExpectation("'", false);
191
191
  const peg$e8 = peg$literalExpectation("`", false);
192
192
  const peg$e9 = peg$literalExpectation(" ", false);
@@ -200,31 +200,40 @@ function peg$parse(input, options) {
200
200
  function peg$f4(fl, list) { popIndentation(); return [fl].concat(list || []); }
201
201
  function peg$f5(l) { return l; }
202
202
  function peg$f6(l) { return l; }
203
- function peg$f7(e, l) {
203
+ function peg$f7() { return !unreadableLines.has(lineKey(offset())); }
204
+ function peg$f8(e, saved, l) {
205
+ if (l === null) {
206
+ // No child line followed the indentation. Forget what looking for one
207
+ // pushed, so the next line is compared with this line's indentation.
208
+ indentationStack = saved;
209
+ return e;
210
+ }
204
211
  return Object.assign({}, e, { children: l });
205
212
  }
206
- function peg$f8(e) { return e; }
207
- function peg$f9(l) { return l; }
208
- function peg$f10(i) { return { id: i }; }
209
- function peg$f11(ml) { return ml; }
210
- function peg$f12(il) { return il; }
211
- function peg$f13(sl) { return sl; }
213
+ function peg$f9() { unreadableLines.add(lineKey(offset())); return false; }
214
+ function peg$f10(l) { return l; }
215
+ function peg$f11(i) { return { id: i }; }
216
+ function peg$f12(g, rest) {
217
+ return rest === null ? g : { values: [g].concat(rest) };
218
+ }
219
+ function peg$f13() { return null; }
212
220
  function peg$f14(fl) { return fl; }
213
221
  function peg$f15(vl) { return vl; }
214
222
  function peg$f16(body) {
215
223
  exitNestedContext();
216
224
  return body;
217
225
  }
218
- function peg$f17(l) { return { nested: l }; }
219
- function peg$f18() { return { nested: [] }; }
220
- function peg$f19() { return enterNestedContext(); }
221
- function peg$f20(value) { return value; }
222
- function peg$f21(list) { return list; }
223
- function peg$f22(id, v) { return { id: id, values: v }; }
224
- function peg$f23(v) { return { values: v }; }
225
- function peg$f24(id) { return { id: id, values: [] }; }
226
- function peg$f25(chars) { return chars.join(''); }
227
- function peg$f26() {
226
+ function peg$f17() { exitNestedContext(); return false; }
227
+ function peg$f18(l) { return { nested: l }; }
228
+ function peg$f19() { return { nested: [] }; }
229
+ function peg$f20() { return enterNestedContext(); }
230
+ function peg$f21(value) { return value; }
231
+ function peg$f22(list) { return list; }
232
+ function peg$f23(id, v) { return { id: id, values: v }; }
233
+ function peg$f24(v) { return { values: v }; }
234
+ function peg$f25(id) { return { id: id, values: [] }; }
235
+ function peg$f26(chars) { return chars.join(''); }
236
+ function peg$f27() {
228
237
  const pos = offset();
229
238
  const result = parseQuotedStringAt(input, pos, '"');
230
239
  if (result) {
@@ -234,11 +243,11 @@ function peg$parse(input, options) {
234
243
  }
235
244
  return false;
236
245
  }
237
- function peg$f27(chars) { return parsedValue; }
238
- function peg$f28(c, cs) { return [c].concat(cs).join(''); }
239
- function peg$f29() { return parsedLength > 1 && (parsedLength--, true); }
240
- function peg$f30(c) { return c; }
241
- function peg$f31() {
246
+ function peg$f28(chars) { return parsedValue; }
247
+ function peg$f29(c, cs) { return [c].concat(cs).join(''); }
248
+ function peg$f30() { return parsedLength > 1 && (parsedLength--, true); }
249
+ function peg$f31(c) { return c; }
250
+ function peg$f32() {
242
251
  const pos = offset();
243
252
  const result = parseQuotedStringAt(input, pos, "'");
244
253
  if (result) {
@@ -248,11 +257,11 @@ function peg$parse(input, options) {
248
257
  }
249
258
  return false;
250
259
  }
251
- function peg$f32(chars) { return parsedValue; }
252
- function peg$f33(c, cs) { return [c].concat(cs).join(''); }
253
- function peg$f34() { return parsedLength > 1 && (parsedLength--, true); }
254
- function peg$f35(c) { return c; }
255
- function peg$f36() {
260
+ function peg$f33(chars) { return parsedValue; }
261
+ function peg$f34(c, cs) { return [c].concat(cs).join(''); }
262
+ function peg$f35() { return parsedLength > 1 && (parsedLength--, true); }
263
+ function peg$f36(c) { return c; }
264
+ function peg$f37() {
256
265
  const pos = offset();
257
266
  const result = parseQuotedStringAt(input, pos, '`');
258
267
  if (result) {
@@ -262,15 +271,16 @@ function peg$parse(input, options) {
262
271
  }
263
272
  return false;
264
273
  }
265
- function peg$f37(chars) { return parsedValue; }
266
- function peg$f38(c, cs) { return [c].concat(cs).join(''); }
267
- function peg$f39() { return parsedLength > 1 && (parsedLength--, true); }
268
- function peg$f40(c) { return c; }
269
- function peg$f41(spaces) { setBaseIndentation(spaces); }
270
- function peg$f42(spaces) { return normalizeIndentation(spaces) > getCurrentIndentation(); }
271
- function peg$f43(spaces) { pushIndentation(spaces); }
272
- function peg$f44(spaces) { return checkIndentation(spaces); }
273
- function peg$f45() { return isInsideNestedContext(); }
274
+ function peg$f38(chars) { return parsedValue; }
275
+ function peg$f39(c, cs) { return [c].concat(cs).join(''); }
276
+ function peg$f40() { return parsedLength > 1 && (parsedLength--, true); }
277
+ function peg$f41(c) { return c; }
278
+ function peg$f42() { return indentationStack.slice(); }
279
+ function peg$f43(spaces) { setBaseIndentation(spaces); }
280
+ function peg$f44(spaces) { return normalizeIndentation(spaces) > getCurrentIndentation(); }
281
+ function peg$f45(spaces) { pushIndentation(spaces); }
282
+ function peg$f46(spaces) { return checkIndentation(spaces); }
283
+ function peg$f47() { return isInsideNestedContext(); }
274
284
  let peg$currPos = options.peg$currPos | 0;
275
285
  let peg$savedPos = peg$currPos;
276
286
  const peg$posDetailsCache = [{ line: 1, column: 1 }];
@@ -640,21 +650,39 @@ function peg$parse(input, options) {
640
650
  }
641
651
 
642
652
  function peg$parseelement() {
643
- let s0, s1, s2, s3;
653
+ let s0, s1, s2, s3, s4, s5, s6;
644
654
 
645
655
  s0 = peg$currPos;
646
- s1 = peg$parseanyLink();
656
+ peg$savedPos = peg$currPos;
657
+ s1 = peg$f7();
658
+ if (s1) {
659
+ s1 = undefined;
660
+ } else {
661
+ s1 = peg$FAILED;
662
+ }
647
663
  if (s1 !== peg$FAILED) {
648
- s2 = peg$parsePUSH_INDENTATION();
664
+ s2 = peg$parseanyLink();
649
665
  if (s2 !== peg$FAILED) {
650
- s3 = peg$parselinks();
651
- if (s3 !== peg$FAILED) {
652
- peg$savedPos = s0;
653
- s0 = peg$f7(s1, s3);
666
+ s3 = peg$parseSAVE_INDENTATION();
667
+ s4 = peg$currPos;
668
+ s5 = peg$parsePUSH_INDENTATION();
669
+ if (s5 !== peg$FAILED) {
670
+ s6 = peg$parselinks();
671
+ if (s6 !== peg$FAILED) {
672
+ s4 = s6;
673
+ } else {
674
+ peg$currPos = s4;
675
+ s4 = peg$FAILED;
676
+ }
654
677
  } else {
655
- peg$currPos = s0;
656
- s0 = peg$FAILED;
678
+ peg$currPos = s4;
679
+ s4 = peg$FAILED;
680
+ }
681
+ if (s4 === peg$FAILED) {
682
+ s4 = null;
657
683
  }
684
+ peg$savedPos = s0;
685
+ s0 = peg$f8(s2, s3, s4);
658
686
  } else {
659
687
  peg$currPos = s0;
660
688
  s0 = peg$FAILED;
@@ -665,12 +693,32 @@ function peg$parse(input, options) {
665
693
  }
666
694
  if (s0 === peg$FAILED) {
667
695
  s0 = peg$currPos;
668
- s1 = peg$parseanyLink();
696
+ peg$savedPos = peg$currPos;
697
+ s1 = peg$f9();
698
+ if (s1) {
699
+ s1 = undefined;
700
+ } else {
701
+ s1 = peg$FAILED;
702
+ }
669
703
  if (s1 !== peg$FAILED) {
670
- peg$savedPos = s0;
671
- s1 = peg$f8(s1);
704
+ if (input.length > peg$currPos) {
705
+ s2 = input.charAt(peg$currPos);
706
+ peg$currPos++;
707
+ } else {
708
+ s2 = peg$FAILED;
709
+ if (peg$silentFails === 0) { peg$fail(peg$e2); }
710
+ }
711
+ if (s2 !== peg$FAILED) {
712
+ s1 = [s1, s2];
713
+ s0 = s1;
714
+ } else {
715
+ peg$currPos = s0;
716
+ s0 = peg$FAILED;
717
+ }
718
+ } else {
719
+ peg$currPos = s0;
720
+ s0 = peg$FAILED;
672
721
  }
673
- s0 = s1;
674
722
  }
675
723
 
676
724
  return s0;
@@ -683,7 +731,7 @@ function peg$parse(input, options) {
683
731
  s1 = peg$parsenestedGroup();
684
732
  if (s1 !== peg$FAILED) {
685
733
  peg$savedPos = s0;
686
- s1 = peg$f9(s1);
734
+ s1 = peg$f10(s1);
687
735
  }
688
736
  s0 = s1;
689
737
  if (s0 === peg$FAILED) {
@@ -691,7 +739,7 @@ function peg$parse(input, options) {
691
739
  s1 = peg$parsereference();
692
740
  if (s1 !== peg$FAILED) {
693
741
  peg$savedPos = s0;
694
- s1 = peg$f10(s1);
742
+ s1 = peg$f11(s1);
695
743
  }
696
744
  s0 = s1;
697
745
  }
@@ -703,12 +751,26 @@ function peg$parse(input, options) {
703
751
  let s0, s1, s2;
704
752
 
705
753
  s0 = peg$currPos;
706
- s1 = peg$parsenestedGroup();
754
+ s1 = peg$currPos;
755
+ peg$silentFails++;
756
+ if (input.charCodeAt(peg$currPos) === 40) {
757
+ s2 = peg$c0;
758
+ peg$currPos++;
759
+ } else {
760
+ s2 = peg$FAILED;
761
+ if (peg$silentFails === 0) { peg$fail(peg$e3); }
762
+ }
763
+ peg$silentFails--;
764
+ if (s2 !== peg$FAILED) {
765
+ peg$currPos = s1;
766
+ s1 = undefined;
767
+ } else {
768
+ s1 = peg$FAILED;
769
+ }
707
770
  if (s1 !== peg$FAILED) {
708
- s2 = peg$parseeol();
771
+ s2 = peg$parsegroupLink();
709
772
  if (s2 !== peg$FAILED) {
710
- peg$savedPos = s0;
711
- s0 = peg$f11(s1);
773
+ s0 = s2;
712
774
  } else {
713
775
  peg$currPos = s0;
714
776
  s0 = peg$FAILED;
@@ -719,20 +781,88 @@ function peg$parse(input, options) {
719
781
  }
720
782
  if (s0 === peg$FAILED) {
721
783
  s0 = peg$currPos;
722
- s1 = peg$parseindentedIdLink();
784
+ s1 = peg$currPos;
785
+ peg$silentFails++;
786
+ if (input.charCodeAt(peg$currPos) === 40) {
787
+ s2 = peg$c0;
788
+ peg$currPos++;
789
+ } else {
790
+ s2 = peg$FAILED;
791
+ if (peg$silentFails === 0) { peg$fail(peg$e3); }
792
+ }
793
+ peg$silentFails--;
794
+ if (s2 === peg$FAILED) {
795
+ s1 = undefined;
796
+ } else {
797
+ peg$currPos = s1;
798
+ s1 = peg$FAILED;
799
+ }
723
800
  if (s1 !== peg$FAILED) {
801
+ s2 = peg$parseindentedIdLink();
802
+ if (s2 === peg$FAILED) {
803
+ s2 = peg$parsesingleLineAnyLink();
804
+ }
805
+ if (s2 !== peg$FAILED) {
806
+ s0 = s2;
807
+ } else {
808
+ peg$currPos = s0;
809
+ s0 = peg$FAILED;
810
+ }
811
+ } else {
812
+ peg$currPos = s0;
813
+ s0 = peg$FAILED;
814
+ }
815
+ }
816
+
817
+ return s0;
818
+ }
819
+
820
+ function peg$parsegroupLink() {
821
+ let s0, s1, s2;
822
+
823
+ s0 = peg$currPos;
824
+ s1 = peg$parsenestedGroup();
825
+ if (s1 !== peg$FAILED) {
826
+ s2 = peg$parsegroupLinkRest();
827
+ if (s2 !== peg$FAILED) {
724
828
  peg$savedPos = s0;
725
- s1 = peg$f12(s1);
829
+ s0 = peg$f12(s1, s2);
830
+ } else {
831
+ peg$currPos = s0;
832
+ s0 = peg$FAILED;
726
833
  }
727
- s0 = s1;
728
- if (s0 === peg$FAILED) {
729
- s0 = peg$currPos;
730
- s1 = peg$parsesingleLineAnyLink();
731
- if (s1 !== peg$FAILED) {
732
- peg$savedPos = s0;
733
- s1 = peg$f13(s1);
734
- }
834
+ } else {
835
+ peg$currPos = s0;
836
+ s0 = peg$FAILED;
837
+ }
838
+
839
+ return s0;
840
+ }
841
+
842
+ function peg$parsegroupLinkRest() {
843
+ let s0, s1, s2;
844
+
845
+ s0 = peg$currPos;
846
+ s1 = peg$parseeol();
847
+ if (s1 !== peg$FAILED) {
848
+ peg$savedPos = s0;
849
+ s1 = peg$f13();
850
+ }
851
+ s0 = s1;
852
+ if (s0 === peg$FAILED) {
853
+ s0 = peg$currPos;
854
+ s1 = [];
855
+ s2 = peg$parsesingleLineValueAndWhitespace();
856
+ while (s2 !== peg$FAILED) {
857
+ s1.push(s2);
858
+ s2 = peg$parsesingleLineValueAndWhitespace();
859
+ }
860
+ s2 = peg$parseeol();
861
+ if (s2 !== peg$FAILED) {
735
862
  s0 = s1;
863
+ } else {
864
+ peg$currPos = s0;
865
+ s0 = peg$FAILED;
736
866
  }
737
867
  }
738
868
 
@@ -787,7 +917,7 @@ function peg$parse(input, options) {
787
917
  peg$currPos++;
788
918
  } else {
789
919
  s1 = peg$FAILED;
790
- if (peg$silentFails === 0) { peg$fail(peg$e2); }
920
+ if (peg$silentFails === 0) { peg$fail(peg$e3); }
791
921
  }
792
922
  if (s1 !== peg$FAILED) {
793
923
  s2 = peg$parseENTER_NESTED_CONTEXT();
@@ -808,6 +938,35 @@ function peg$parse(input, options) {
808
938
  peg$currPos = s0;
809
939
  s0 = peg$FAILED;
810
940
  }
941
+ if (s0 === peg$FAILED) {
942
+ s0 = peg$currPos;
943
+ if (input.charCodeAt(peg$currPos) === 40) {
944
+ s1 = peg$c0;
945
+ peg$currPos++;
946
+ } else {
947
+ s1 = peg$FAILED;
948
+ if (peg$silentFails === 0) { peg$fail(peg$e3); }
949
+ }
950
+ if (s1 !== peg$FAILED) {
951
+ peg$savedPos = peg$currPos;
952
+ s2 = peg$f17();
953
+ if (s2) {
954
+ s2 = undefined;
955
+ } else {
956
+ s2 = peg$FAILED;
957
+ }
958
+ if (s2 !== peg$FAILED) {
959
+ s1 = [s1, s2];
960
+ s0 = s1;
961
+ } else {
962
+ peg$currPos = s0;
963
+ s0 = peg$FAILED;
964
+ }
965
+ } else {
966
+ peg$currPos = s0;
967
+ s0 = peg$FAILED;
968
+ }
969
+ }
811
970
 
812
971
  return s0;
813
972
  }
@@ -825,11 +984,11 @@ function peg$parse(input, options) {
825
984
  peg$currPos++;
826
985
  } else {
827
986
  s4 = peg$FAILED;
828
- if (peg$silentFails === 0) { peg$fail(peg$e3); }
987
+ if (peg$silentFails === 0) { peg$fail(peg$e4); }
829
988
  }
830
989
  if (s4 !== peg$FAILED) {
831
990
  peg$savedPos = s0;
832
- s0 = peg$f17(s2);
991
+ s0 = peg$f18(s2);
833
992
  } else {
834
993
  peg$currPos = s0;
835
994
  s0 = peg$FAILED;
@@ -846,11 +1005,11 @@ function peg$parse(input, options) {
846
1005
  peg$currPos++;
847
1006
  } else {
848
1007
  s2 = peg$FAILED;
849
- if (peg$silentFails === 0) { peg$fail(peg$e3); }
1008
+ if (peg$silentFails === 0) { peg$fail(peg$e4); }
850
1009
  }
851
1010
  if (s2 !== peg$FAILED) {
852
1011
  peg$savedPos = s0;
853
- s0 = peg$f18();
1012
+ s0 = peg$f19();
854
1013
  } else {
855
1014
  peg$currPos = s0;
856
1015
  s0 = peg$FAILED;
@@ -864,7 +1023,7 @@ function peg$parse(input, options) {
864
1023
  let s0;
865
1024
 
866
1025
  peg$savedPos = peg$currPos;
867
- s0 = peg$f19();
1026
+ s0 = peg$f20();
868
1027
  if (s0) {
869
1028
  s0 = undefined;
870
1029
  } else {
@@ -882,7 +1041,7 @@ function peg$parse(input, options) {
882
1041
  s2 = peg$parsereferenceOrLink();
883
1042
  if (s2 !== peg$FAILED) {
884
1043
  peg$savedPos = s0;
885
- s0 = peg$f20(s2);
1044
+ s0 = peg$f21(s2);
886
1045
  } else {
887
1046
  peg$currPos = s0;
888
1047
  s0 = peg$FAILED;
@@ -907,7 +1066,7 @@ function peg$parse(input, options) {
907
1066
  }
908
1067
  if (s1 !== peg$FAILED) {
909
1068
  peg$savedPos = s0;
910
- s1 = peg$f21(s1);
1069
+ s1 = peg$f22(s1);
911
1070
  }
912
1071
  s0 = s1;
913
1072
 
@@ -927,13 +1086,13 @@ function peg$parse(input, options) {
927
1086
  peg$currPos++;
928
1087
  } else {
929
1088
  s4 = peg$FAILED;
930
- if (peg$silentFails === 0) { peg$fail(peg$e4); }
1089
+ if (peg$silentFails === 0) { peg$fail(peg$e5); }
931
1090
  }
932
1091
  if (s4 !== peg$FAILED) {
933
1092
  s5 = peg$parsesingleLineValues();
934
1093
  if (s5 !== peg$FAILED) {
935
1094
  peg$savedPos = s0;
936
- s0 = peg$f22(s2, s5);
1095
+ s0 = peg$f23(s2, s5);
937
1096
  } else {
938
1097
  peg$currPos = s0;
939
1098
  s0 = peg$FAILED;
@@ -957,7 +1116,7 @@ function peg$parse(input, options) {
957
1116
  s1 = peg$parsesingleLineValues();
958
1117
  if (s1 !== peg$FAILED) {
959
1118
  peg$savedPos = s0;
960
- s1 = peg$f23(s1);
1119
+ s1 = peg$f24(s1);
961
1120
  }
962
1121
  s0 = s1;
963
1122
 
@@ -976,13 +1135,13 @@ function peg$parse(input, options) {
976
1135
  peg$currPos++;
977
1136
  } else {
978
1137
  s3 = peg$FAILED;
979
- if (peg$silentFails === 0) { peg$fail(peg$e4); }
1138
+ if (peg$silentFails === 0) { peg$fail(peg$e5); }
980
1139
  }
981
1140
  if (s3 !== peg$FAILED) {
982
1141
  s4 = peg$parseeol();
983
1142
  if (s4 !== peg$FAILED) {
984
1143
  peg$savedPos = s0;
985
- s0 = peg$f24(s1);
1144
+ s0 = peg$f25(s1);
986
1145
  } else {
987
1146
  peg$currPos = s0;
988
1147
  s0 = peg$FAILED;
@@ -1026,7 +1185,7 @@ function peg$parse(input, options) {
1026
1185
  }
1027
1186
  if (s1 !== peg$FAILED) {
1028
1187
  peg$savedPos = s0;
1029
- s1 = peg$f25(s1);
1188
+ s1 = peg$f26(s1);
1030
1189
  }
1031
1190
  s0 = s1;
1032
1191
 
@@ -1058,7 +1217,7 @@ function peg$parse(input, options) {
1058
1217
  peg$currPos++;
1059
1218
  } else {
1060
1219
  s2 = peg$FAILED;
1061
- if (peg$silentFails === 0) { peg$fail(peg$e5); }
1220
+ if (peg$silentFails === 0) { peg$fail(peg$e6); }
1062
1221
  }
1063
1222
  peg$silentFails--;
1064
1223
  if (s2 !== peg$FAILED) {
@@ -1069,7 +1228,7 @@ function peg$parse(input, options) {
1069
1228
  }
1070
1229
  if (s1 !== peg$FAILED) {
1071
1230
  peg$savedPos = peg$currPos;
1072
- s2 = peg$f26();
1231
+ s2 = peg$f27();
1073
1232
  if (s2) {
1074
1233
  s2 = undefined;
1075
1234
  } else {
@@ -1079,7 +1238,7 @@ function peg$parse(input, options) {
1079
1238
  s3 = peg$parseconsumeDouble();
1080
1239
  if (s3 !== peg$FAILED) {
1081
1240
  peg$savedPos = s0;
1082
- s0 = peg$f27(s3);
1241
+ s0 = peg$f28(s3);
1083
1242
  } else {
1084
1243
  peg$currPos = s0;
1085
1244
  s0 = peg$FAILED;
@@ -1105,7 +1264,7 @@ function peg$parse(input, options) {
1105
1264
  peg$currPos++;
1106
1265
  } else {
1107
1266
  s1 = peg$FAILED;
1108
- if (peg$silentFails === 0) { peg$fail(peg$e6); }
1267
+ if (peg$silentFails === 0) { peg$fail(peg$e2); }
1109
1268
  }
1110
1269
  if (s1 !== peg$FAILED) {
1111
1270
  s2 = [];
@@ -1115,7 +1274,7 @@ function peg$parse(input, options) {
1115
1274
  s3 = peg$parseconsumeDoubleMore();
1116
1275
  }
1117
1276
  peg$savedPos = s0;
1118
- s0 = peg$f28(s1, s2);
1277
+ s0 = peg$f29(s1, s2);
1119
1278
  } else {
1120
1279
  peg$currPos = s0;
1121
1280
  s0 = peg$FAILED;
@@ -1129,7 +1288,7 @@ function peg$parse(input, options) {
1129
1288
 
1130
1289
  s0 = peg$currPos;
1131
1290
  peg$savedPos = peg$currPos;
1132
- s1 = peg$f29();
1291
+ s1 = peg$f30();
1133
1292
  if (s1) {
1134
1293
  s1 = undefined;
1135
1294
  } else {
@@ -1141,11 +1300,11 @@ function peg$parse(input, options) {
1141
1300
  peg$currPos++;
1142
1301
  } else {
1143
1302
  s2 = peg$FAILED;
1144
- if (peg$silentFails === 0) { peg$fail(peg$e6); }
1303
+ if (peg$silentFails === 0) { peg$fail(peg$e2); }
1145
1304
  }
1146
1305
  if (s2 !== peg$FAILED) {
1147
1306
  peg$savedPos = s0;
1148
- s0 = peg$f30(s2);
1307
+ s0 = peg$f31(s2);
1149
1308
  } else {
1150
1309
  peg$currPos = s0;
1151
1310
  s0 = peg$FAILED;
@@ -1180,7 +1339,7 @@ function peg$parse(input, options) {
1180
1339
  }
1181
1340
  if (s1 !== peg$FAILED) {
1182
1341
  peg$savedPos = peg$currPos;
1183
- s2 = peg$f31();
1342
+ s2 = peg$f32();
1184
1343
  if (s2) {
1185
1344
  s2 = undefined;
1186
1345
  } else {
@@ -1190,7 +1349,7 @@ function peg$parse(input, options) {
1190
1349
  s3 = peg$parseconsumeSingle();
1191
1350
  if (s3 !== peg$FAILED) {
1192
1351
  peg$savedPos = s0;
1193
- s0 = peg$f32(s3);
1352
+ s0 = peg$f33(s3);
1194
1353
  } else {
1195
1354
  peg$currPos = s0;
1196
1355
  s0 = peg$FAILED;
@@ -1216,7 +1375,7 @@ function peg$parse(input, options) {
1216
1375
  peg$currPos++;
1217
1376
  } else {
1218
1377
  s1 = peg$FAILED;
1219
- if (peg$silentFails === 0) { peg$fail(peg$e6); }
1378
+ if (peg$silentFails === 0) { peg$fail(peg$e2); }
1220
1379
  }
1221
1380
  if (s1 !== peg$FAILED) {
1222
1381
  s2 = [];
@@ -1226,7 +1385,7 @@ function peg$parse(input, options) {
1226
1385
  s3 = peg$parseconsumeSingleMore();
1227
1386
  }
1228
1387
  peg$savedPos = s0;
1229
- s0 = peg$f33(s1, s2);
1388
+ s0 = peg$f34(s1, s2);
1230
1389
  } else {
1231
1390
  peg$currPos = s0;
1232
1391
  s0 = peg$FAILED;
@@ -1240,7 +1399,7 @@ function peg$parse(input, options) {
1240
1399
 
1241
1400
  s0 = peg$currPos;
1242
1401
  peg$savedPos = peg$currPos;
1243
- s1 = peg$f34();
1402
+ s1 = peg$f35();
1244
1403
  if (s1) {
1245
1404
  s1 = undefined;
1246
1405
  } else {
@@ -1252,11 +1411,11 @@ function peg$parse(input, options) {
1252
1411
  peg$currPos++;
1253
1412
  } else {
1254
1413
  s2 = peg$FAILED;
1255
- if (peg$silentFails === 0) { peg$fail(peg$e6); }
1414
+ if (peg$silentFails === 0) { peg$fail(peg$e2); }
1256
1415
  }
1257
1416
  if (s2 !== peg$FAILED) {
1258
1417
  peg$savedPos = s0;
1259
- s0 = peg$f35(s2);
1418
+ s0 = peg$f36(s2);
1260
1419
  } else {
1261
1420
  peg$currPos = s0;
1262
1421
  s0 = peg$FAILED;
@@ -1291,7 +1450,7 @@ function peg$parse(input, options) {
1291
1450
  }
1292
1451
  if (s1 !== peg$FAILED) {
1293
1452
  peg$savedPos = peg$currPos;
1294
- s2 = peg$f36();
1453
+ s2 = peg$f37();
1295
1454
  if (s2) {
1296
1455
  s2 = undefined;
1297
1456
  } else {
@@ -1301,7 +1460,7 @@ function peg$parse(input, options) {
1301
1460
  s3 = peg$parseconsumeBacktick();
1302
1461
  if (s3 !== peg$FAILED) {
1303
1462
  peg$savedPos = s0;
1304
- s0 = peg$f37(s3);
1463
+ s0 = peg$f38(s3);
1305
1464
  } else {
1306
1465
  peg$currPos = s0;
1307
1466
  s0 = peg$FAILED;
@@ -1327,7 +1486,7 @@ function peg$parse(input, options) {
1327
1486
  peg$currPos++;
1328
1487
  } else {
1329
1488
  s1 = peg$FAILED;
1330
- if (peg$silentFails === 0) { peg$fail(peg$e6); }
1489
+ if (peg$silentFails === 0) { peg$fail(peg$e2); }
1331
1490
  }
1332
1491
  if (s1 !== peg$FAILED) {
1333
1492
  s2 = [];
@@ -1337,7 +1496,7 @@ function peg$parse(input, options) {
1337
1496
  s3 = peg$parseconsumeBacktickMore();
1338
1497
  }
1339
1498
  peg$savedPos = s0;
1340
- s0 = peg$f38(s1, s2);
1499
+ s0 = peg$f39(s1, s2);
1341
1500
  } else {
1342
1501
  peg$currPos = s0;
1343
1502
  s0 = peg$FAILED;
@@ -1351,7 +1510,7 @@ function peg$parse(input, options) {
1351
1510
 
1352
1511
  s0 = peg$currPos;
1353
1512
  peg$savedPos = peg$currPos;
1354
- s1 = peg$f39();
1513
+ s1 = peg$f40();
1355
1514
  if (s1) {
1356
1515
  s1 = undefined;
1357
1516
  } else {
@@ -1363,11 +1522,11 @@ function peg$parse(input, options) {
1363
1522
  peg$currPos++;
1364
1523
  } else {
1365
1524
  s2 = peg$FAILED;
1366
- if (peg$silentFails === 0) { peg$fail(peg$e6); }
1525
+ if (peg$silentFails === 0) { peg$fail(peg$e2); }
1367
1526
  }
1368
1527
  if (s2 !== peg$FAILED) {
1369
1528
  peg$savedPos = s0;
1370
- s0 = peg$f40(s2);
1529
+ s0 = peg$f41(s2);
1371
1530
  } else {
1372
1531
  peg$currPos = s0;
1373
1532
  s0 = peg$FAILED;
@@ -1380,6 +1539,18 @@ function peg$parse(input, options) {
1380
1539
  return s0;
1381
1540
  }
1382
1541
 
1542
+ function peg$parseSAVE_INDENTATION() {
1543
+ let s0, s1;
1544
+
1545
+ s0 = peg$currPos;
1546
+ s1 = '';
1547
+ peg$savedPos = s0;
1548
+ s1 = peg$f42();
1549
+ s0 = s1;
1550
+
1551
+ return s0;
1552
+ }
1553
+
1383
1554
  function peg$parseSET_BASE_INDENTATION() {
1384
1555
  let s0, s1, s2;
1385
1556
 
@@ -1403,7 +1574,7 @@ function peg$parse(input, options) {
1403
1574
  }
1404
1575
  }
1405
1576
  peg$savedPos = s0;
1406
- s1 = peg$f41(s1);
1577
+ s1 = peg$f43(s1);
1407
1578
  s0 = s1;
1408
1579
 
1409
1580
  return s0;
@@ -1432,7 +1603,7 @@ function peg$parse(input, options) {
1432
1603
  }
1433
1604
  }
1434
1605
  peg$savedPos = peg$currPos;
1435
- s2 = peg$f42(s1);
1606
+ s2 = peg$f44(s1);
1436
1607
  if (s2) {
1437
1608
  s2 = undefined;
1438
1609
  } else {
@@ -1440,7 +1611,7 @@ function peg$parse(input, options) {
1440
1611
  }
1441
1612
  if (s2 !== peg$FAILED) {
1442
1613
  peg$savedPos = s0;
1443
- s0 = peg$f43(s1);
1614
+ s0 = peg$f45(s1);
1444
1615
  } else {
1445
1616
  peg$currPos = s0;
1446
1617
  s0 = peg$FAILED;
@@ -1472,7 +1643,7 @@ function peg$parse(input, options) {
1472
1643
  }
1473
1644
  }
1474
1645
  peg$savedPos = peg$currPos;
1475
- s2 = peg$f44(s1);
1646
+ s2 = peg$f46(s1);
1476
1647
  if (s2) {
1477
1648
  s2 = undefined;
1478
1649
  } else {
@@ -1672,7 +1843,7 @@ function peg$parse(input, options) {
1672
1843
 
1673
1844
  s0 = peg$currPos;
1674
1845
  peg$savedPos = peg$currPos;
1675
- s1 = peg$f45();
1846
+ s1 = peg$f47();
1676
1847
  if (s1) {
1677
1848
  s1 = undefined;
1678
1849
  } else {
@@ -1686,7 +1857,7 @@ function peg$parse(input, options) {
1686
1857
  peg$currPos++;
1687
1858
  } else {
1688
1859
  s3 = peg$FAILED;
1689
- if (peg$silentFails === 0) { peg$fail(peg$e3); }
1860
+ if (peg$silentFails === 0) { peg$fail(peg$e4); }
1690
1861
  }
1691
1862
  peg$silentFails--;
1692
1863
  if (s3 !== peg$FAILED) {
@@ -1720,7 +1891,7 @@ function peg$parse(input, options) {
1720
1891
  peg$currPos++;
1721
1892
  } else {
1722
1893
  s1 = peg$FAILED;
1723
- if (peg$silentFails === 0) { peg$fail(peg$e6); }
1894
+ if (peg$silentFails === 0) { peg$fail(peg$e2); }
1724
1895
  }
1725
1896
  peg$silentFails--;
1726
1897
  if (s1 === peg$FAILED) {
@@ -1806,14 +1977,27 @@ function peg$parse(input, options) {
1806
1977
  // group opens a nested context that starts fresh at indentation level zero,
1807
1978
  // so line breaks and indentation mean the same thing at every depth.
1808
1979
  let contextStack = [];
1980
+ // Lines already found unreadable, keyed by where they start and whether they
1981
+ // are inside a parenthesised group. Reading a line depends on nothing else: a
1982
+ // group starts a fresh indentation context, and indentation only decides
1983
+ // which lines become children, so a line that could not be read once never
1984
+ // can be. A line that does not parse as the first child of the line above it
1985
+ // is tried again as a sibling at every enclosing indentation level, and
1986
+ // without this each of those attempts would read the whole line again.
1987
+ let unreadableLines = new Set();
1809
1988
 
1810
1989
  function resetState() {
1811
1990
  indentationStack = [0];
1812
1991
  baseIndentation = null;
1813
1992
  contextStack = [];
1993
+ unreadableLines = new Set();
1814
1994
  return true;
1815
1995
  }
1816
1996
 
1997
+ function lineKey(position) {
1998
+ return contextStack.length > 0 ? -1 - position : position;
1999
+ }
2000
+
1817
2001
  function enterNestedContext() {
1818
2002
  contextStack.push({ indentationStack, baseIndentation });
1819
2003
  indentationStack = [0];