links-notation 0.12.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- // @generated by Peggy 5.0.6.
1
+ // @generated by Peggy 5.1.0.
2
2
  //
3
3
  // https://peggyjs.org/
4
4
 
@@ -164,43 +164,41 @@ function peg$parse(input, options) {
164
164
  };
165
165
  let peg$startRuleFunction = peg$parsedocument;
166
166
 
167
- const peg$c0 = ":";
168
- const peg$c1 = "(";
169
- const peg$c2 = ")";
167
+ const peg$c0 = "(";
168
+ const peg$c1 = ")";
169
+ const peg$c2 = ":";
170
170
  const peg$c3 = "\"";
171
171
  const peg$c4 = "'";
172
- const peg$c5 = " ";
172
+ const peg$c5 = "`";
173
+ const peg$c6 = " ";
173
174
 
174
175
  const peg$r0 = /^[ \t]/;
175
176
  const peg$r1 = /^[\r\n]/;
176
- const peg$r2 = /^[^"]/;
177
- const peg$r3 = /^[^']/;
178
- const peg$r4 = /^[ \t\n\r]/;
179
- const peg$r5 = /^[^ \t\n\r(:)]/;
177
+ const peg$r2 = /^[ \t\n\r]/;
178
+ const peg$r3 = /^[^ \t\n\r(:)]/;
180
179
 
181
180
  const peg$e0 = peg$classExpectation([" ", "\t"], false, false, false);
182
181
  const peg$e1 = peg$classExpectation(["\r", "\n"], false, false, false);
183
- const peg$e2 = peg$literalExpectation(":", false);
184
- const peg$e3 = peg$literalExpectation("(", false);
185
- const peg$e4 = peg$literalExpectation(")", false);
182
+ const peg$e2 = peg$literalExpectation("(", false);
183
+ const peg$e3 = peg$literalExpectation(")", false);
184
+ const peg$e4 = peg$literalExpectation(":", false);
186
185
  const peg$e5 = peg$literalExpectation("\"", false);
187
- const peg$e6 = peg$classExpectation(["\""], true, false, false);
186
+ const peg$e6 = peg$anyExpectation();
188
187
  const peg$e7 = peg$literalExpectation("'", false);
189
- const peg$e8 = peg$classExpectation(["'"], true, false, false);
188
+ const peg$e8 = peg$literalExpectation("`", false);
190
189
  const peg$e9 = peg$literalExpectation(" ", false);
191
- const peg$e10 = peg$anyExpectation();
192
- const peg$e11 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false, false);
193
- const peg$e12 = peg$classExpectation([" ", "\t", "\n", "\r", "(", ":", ")"], true, false, false);
190
+ const peg$e10 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false, false);
191
+ const peg$e11 = peg$classExpectation([" ", "\t", "\n", "\r", "(", ":", ")"], true, false, false);
194
192
 
195
- function peg$f0() { indentationStack = [0]; baseIndentation = null; return true; }
193
+ function peg$f0() { return resetState(); }
196
194
  function peg$f1(links) { return links; }
197
- function peg$f2() { indentationStack = [0]; baseIndentation = null; return true; }
195
+ function peg$f2() { return resetState(); }
198
196
  function peg$f3() { return []; }
199
197
  function peg$f4(fl, list) { popIndentation(); return [fl].concat(list || []); }
200
198
  function peg$f5(l) { return l; }
201
199
  function peg$f6(l) { return l; }
202
200
  function peg$f7(e, l) {
203
- return { id: e.id, values: e.values, children: l };
201
+ return Object.assign({}, e, { children: l });
204
202
  }
205
203
  function peg$f8(e) { return e; }
206
204
  function peg$f9(l) { return l; }
@@ -210,22 +208,66 @@ function peg$parse(input, options) {
210
208
  function peg$f13(sl) { return sl; }
211
209
  function peg$f14(fl) { return fl; }
212
210
  function peg$f15(vl) { return vl; }
213
- function peg$f16(value) { return value; }
214
- function peg$f17(list) { return list; }
215
- function peg$f18(value) { return value; }
216
- function peg$f19(list) { return list; }
217
- function peg$f20(id, v) { return { id: id, values: v }; }
218
- function peg$f21(id, v) { return { id: id, values: v }; }
219
- function peg$f22(v) { return { values: v }; }
211
+ function peg$f16(body) {
212
+ exitNestedContext();
213
+ return body;
214
+ }
215
+ function peg$f17(l) { return { nested: l }; }
216
+ function peg$f18() { return { nested: [] }; }
217
+ function peg$f19() { return enterNestedContext(); }
218
+ function peg$f20(value) { return value; }
219
+ function peg$f21(list) { return list; }
220
+ function peg$f22(id, v) { return { id: id, values: v }; }
220
221
  function peg$f23(v) { return { values: v }; }
221
222
  function peg$f24(id) { return { id: id, values: [] }; }
222
223
  function peg$f25(chars) { return chars.join(''); }
223
- function peg$f26(r) { return r.join(''); }
224
- function peg$f27(r) { return r.join(''); }
225
- function peg$f28(spaces) { setBaseIndentation(spaces); }
226
- function peg$f29(spaces) { return normalizeIndentation(spaces) > getCurrentIndentation(); }
227
- function peg$f30(spaces) { pushIndentation(spaces); }
228
- function peg$f31(spaces) { return checkIndentation(spaces); }
224
+ function peg$f26() {
225
+ const pos = offset();
226
+ const result = parseQuotedStringAt(input, pos, '"');
227
+ if (result) {
228
+ parsedValue = result.value;
229
+ parsedLength = result.length;
230
+ return true;
231
+ }
232
+ return false;
233
+ }
234
+ function peg$f27(chars) { return parsedValue; }
235
+ function peg$f28(c, cs) { return [c].concat(cs).join(''); }
236
+ function peg$f29() { return parsedLength > 1 && (parsedLength--, true); }
237
+ function peg$f30(c) { return c; }
238
+ function peg$f31() {
239
+ const pos = offset();
240
+ const result = parseQuotedStringAt(input, pos, "'");
241
+ if (result) {
242
+ parsedValue = result.value;
243
+ parsedLength = result.length;
244
+ return true;
245
+ }
246
+ return false;
247
+ }
248
+ function peg$f32(chars) { return parsedValue; }
249
+ function peg$f33(c, cs) { return [c].concat(cs).join(''); }
250
+ function peg$f34() { return parsedLength > 1 && (parsedLength--, true); }
251
+ function peg$f35(c) { return c; }
252
+ function peg$f36() {
253
+ const pos = offset();
254
+ const result = parseQuotedStringAt(input, pos, '`');
255
+ if (result) {
256
+ parsedValue = result.value;
257
+ parsedLength = result.length;
258
+ return true;
259
+ }
260
+ return false;
261
+ }
262
+ function peg$f37(chars) { return parsedValue; }
263
+ function peg$f38(c, cs) { return [c].concat(cs).join(''); }
264
+ function peg$f39() { return parsedLength > 1 && (parsedLength--, true); }
265
+ function peg$f40(c) { return c; }
266
+ function peg$f41(spaces) { setBaseIndentation(spaces); }
267
+ function peg$f42(spaces) { return normalizeIndentation(spaces) > getCurrentIndentation(); }
268
+ function peg$f43(spaces) { pushIndentation(spaces); }
269
+ function peg$f44(spaces) { return checkIndentation(spaces); }
270
+ function peg$f45() { return isInsideNestedContext(); }
229
271
  let peg$currPos = options.peg$currPos | 0;
230
272
  let peg$savedPos = peg$currPos;
231
273
  const peg$posDetailsCache = [{ line: 1, column: 1 }];
@@ -635,7 +677,7 @@ function peg$parse(input, options) {
635
677
  let s0, s1;
636
678
 
637
679
  s0 = peg$currPos;
638
- s1 = peg$parsemultiLineAnyLink();
680
+ s1 = peg$parsenestedGroup();
639
681
  if (s1 !== peg$FAILED) {
640
682
  peg$savedPos = s0;
641
683
  s1 = peg$f9(s1);
@@ -658,7 +700,7 @@ function peg$parse(input, options) {
658
700
  let s0, s1, s2;
659
701
 
660
702
  s0 = peg$currPos;
661
- s1 = peg$parsemultiLineAnyLink();
703
+ s1 = peg$parsenestedGroup();
662
704
  if (s1 !== peg$FAILED) {
663
705
  s2 = peg$parseeol();
664
706
  if (s2 !== peg$FAILED) {
@@ -694,17 +736,6 @@ function peg$parse(input, options) {
694
736
  return s0;
695
737
  }
696
738
 
697
- function peg$parsemultiLineAnyLink() {
698
- let s0;
699
-
700
- s0 = peg$parsemultiLineValueLink();
701
- if (s0 === peg$FAILED) {
702
- s0 = peg$parsemultiLineLink();
703
- }
704
-
705
- return s0;
706
- }
707
-
708
739
  function peg$parsesingleLineAnyLink() {
709
740
  let s0, s1, s2;
710
741
 
@@ -744,15 +775,32 @@ function peg$parse(input, options) {
744
775
  return s0;
745
776
  }
746
777
 
747
- function peg$parsemultiLineValueAndWhitespace() {
748
- let s0, s1, s2;
778
+ function peg$parsenestedGroup() {
779
+ let s0, s1, s2, s3;
749
780
 
750
781
  s0 = peg$currPos;
751
- s1 = peg$parsereferenceOrLink();
782
+ if (input.charCodeAt(peg$currPos) === 40) {
783
+ s1 = peg$c0;
784
+ peg$currPos++;
785
+ } else {
786
+ s1 = peg$FAILED;
787
+ if (peg$silentFails === 0) { peg$fail(peg$e2); }
788
+ }
752
789
  if (s1 !== peg$FAILED) {
753
- s2 = peg$parse_();
754
- peg$savedPos = s0;
755
- s0 = peg$f16(s1);
790
+ s2 = peg$parseENTER_NESTED_CONTEXT();
791
+ if (s2 !== peg$FAILED) {
792
+ s3 = peg$parsenestedGroupBody();
793
+ if (s3 !== peg$FAILED) {
794
+ peg$savedPos = s0;
795
+ s0 = peg$f16(s3);
796
+ } else {
797
+ peg$currPos = s0;
798
+ s0 = peg$FAILED;
799
+ }
800
+ } else {
801
+ peg$currPos = s0;
802
+ s0 = peg$FAILED;
803
+ }
756
804
  } else {
757
805
  peg$currPos = s0;
758
806
  s0 = peg$FAILED;
@@ -761,19 +809,64 @@ function peg$parse(input, options) {
761
809
  return s0;
762
810
  }
763
811
 
764
- function peg$parsemultiLineValues() {
765
- let s0, s1, s2, s3;
812
+ function peg$parsenestedGroupBody() {
813
+ let s0, s1, s2, s3, s4;
766
814
 
767
815
  s0 = peg$currPos;
768
- s1 = peg$parse_();
769
- s2 = [];
770
- s3 = peg$parsemultiLineValueAndWhitespace();
771
- while (s3 !== peg$FAILED) {
772
- s2.push(s3);
773
- s3 = peg$parsemultiLineValueAndWhitespace();
816
+ s1 = peg$parseskipEmptyLines();
817
+ s2 = peg$parselinks();
818
+ if (s2 !== peg$FAILED) {
819
+ s3 = peg$parse_();
820
+ if (input.charCodeAt(peg$currPos) === 41) {
821
+ s4 = peg$c1;
822
+ peg$currPos++;
823
+ } else {
824
+ s4 = peg$FAILED;
825
+ if (peg$silentFails === 0) { peg$fail(peg$e3); }
826
+ }
827
+ if (s4 !== peg$FAILED) {
828
+ peg$savedPos = s0;
829
+ s0 = peg$f17(s2);
830
+ } else {
831
+ peg$currPos = s0;
832
+ s0 = peg$FAILED;
833
+ }
834
+ } else {
835
+ peg$currPos = s0;
836
+ s0 = peg$FAILED;
837
+ }
838
+ if (s0 === peg$FAILED) {
839
+ s0 = peg$currPos;
840
+ s1 = peg$parse_();
841
+ if (input.charCodeAt(peg$currPos) === 41) {
842
+ s2 = peg$c1;
843
+ peg$currPos++;
844
+ } else {
845
+ s2 = peg$FAILED;
846
+ if (peg$silentFails === 0) { peg$fail(peg$e3); }
847
+ }
848
+ if (s2 !== peg$FAILED) {
849
+ peg$savedPos = s0;
850
+ s0 = peg$f18();
851
+ } else {
852
+ peg$currPos = s0;
853
+ s0 = peg$FAILED;
854
+ }
855
+ }
856
+
857
+ return s0;
858
+ }
859
+
860
+ function peg$parseENTER_NESTED_CONTEXT() {
861
+ let s0;
862
+
863
+ peg$savedPos = peg$currPos;
864
+ s0 = peg$f19();
865
+ if (s0) {
866
+ s0 = undefined;
867
+ } else {
868
+ s0 = peg$FAILED;
774
869
  }
775
- peg$savedPos = s0;
776
- s0 = peg$f17(s2);
777
870
 
778
871
  return s0;
779
872
  }
@@ -786,7 +879,7 @@ function peg$parse(input, options) {
786
879
  s2 = peg$parsereferenceOrLink();
787
880
  if (s2 !== peg$FAILED) {
788
881
  peg$savedPos = s0;
789
- s0 = peg$f18(s2);
882
+ s0 = peg$f20(s2);
790
883
  } else {
791
884
  peg$currPos = s0;
792
885
  s0 = peg$FAILED;
@@ -811,7 +904,7 @@ function peg$parse(input, options) {
811
904
  }
812
905
  if (s1 !== peg$FAILED) {
813
906
  peg$savedPos = s0;
814
- s1 = peg$f19(s1);
907
+ s1 = peg$f21(s1);
815
908
  }
816
909
  s0 = s1;
817
910
 
@@ -827,17 +920,17 @@ function peg$parse(input, options) {
827
920
  if (s2 !== peg$FAILED) {
828
921
  s3 = peg$parse__();
829
922
  if (input.charCodeAt(peg$currPos) === 58) {
830
- s4 = peg$c0;
923
+ s4 = peg$c2;
831
924
  peg$currPos++;
832
925
  } else {
833
926
  s4 = peg$FAILED;
834
- if (peg$silentFails === 0) { peg$fail(peg$e2); }
927
+ if (peg$silentFails === 0) { peg$fail(peg$e4); }
835
928
  }
836
929
  if (s4 !== peg$FAILED) {
837
930
  s5 = peg$parsesingleLineValues();
838
931
  if (s5 !== peg$FAILED) {
839
932
  peg$savedPos = s0;
840
- s0 = peg$f20(s2, s5);
933
+ s0 = peg$f22(s2, s5);
841
934
  } else {
842
935
  peg$currPos = s0;
843
936
  s0 = peg$FAILED;
@@ -854,46 +947,39 @@ function peg$parse(input, options) {
854
947
  return s0;
855
948
  }
856
949
 
857
- function peg$parsemultiLineLink() {
858
- let s0, s1, s2, s3, s4, s5, s6, s7, s8;
950
+ function peg$parsesingleLineValueLink() {
951
+ let s0, s1;
859
952
 
860
953
  s0 = peg$currPos;
861
- if (input.charCodeAt(peg$currPos) === 40) {
862
- s1 = peg$c1;
863
- peg$currPos++;
864
- } else {
865
- s1 = peg$FAILED;
866
- if (peg$silentFails === 0) { peg$fail(peg$e3); }
954
+ s1 = peg$parsesingleLineValues();
955
+ if (s1 !== peg$FAILED) {
956
+ peg$savedPos = s0;
957
+ s1 = peg$f23(s1);
867
958
  }
959
+ s0 = s1;
960
+
961
+ return s0;
962
+ }
963
+
964
+ function peg$parseindentedIdLink() {
965
+ let s0, s1, s2, s3, s4;
966
+
967
+ s0 = peg$currPos;
968
+ s1 = peg$parsereference();
868
969
  if (s1 !== peg$FAILED) {
869
- s2 = peg$parse_();
870
- s3 = peg$parsereference();
970
+ s2 = peg$parse__();
971
+ if (input.charCodeAt(peg$currPos) === 58) {
972
+ s3 = peg$c2;
973
+ peg$currPos++;
974
+ } else {
975
+ s3 = peg$FAILED;
976
+ if (peg$silentFails === 0) { peg$fail(peg$e4); }
977
+ }
871
978
  if (s3 !== peg$FAILED) {
872
- s4 = peg$parse_();
873
- if (input.charCodeAt(peg$currPos) === 58) {
874
- s5 = peg$c0;
875
- peg$currPos++;
876
- } else {
877
- s5 = peg$FAILED;
878
- if (peg$silentFails === 0) { peg$fail(peg$e2); }
879
- }
880
- if (s5 !== peg$FAILED) {
881
- s6 = peg$parsemultiLineValues();
882
- s7 = peg$parse_();
883
- if (input.charCodeAt(peg$currPos) === 41) {
884
- s8 = peg$c2;
885
- peg$currPos++;
886
- } else {
887
- s8 = peg$FAILED;
888
- if (peg$silentFails === 0) { peg$fail(peg$e4); }
889
- }
890
- if (s8 !== peg$FAILED) {
891
- peg$savedPos = s0;
892
- s0 = peg$f21(s3, s6);
893
- } else {
894
- peg$currPos = s0;
895
- s0 = peg$FAILED;
896
- }
979
+ s4 = peg$parseeol();
980
+ if (s4 !== peg$FAILED) {
981
+ peg$savedPos = s0;
982
+ s0 = peg$f24(s1);
897
983
  } else {
898
984
  peg$currPos = s0;
899
985
  s0 = peg$FAILED;
@@ -910,44 +996,153 @@ function peg$parse(input, options) {
910
996
  return s0;
911
997
  }
912
998
 
913
- function peg$parsesingleLineValueLink() {
914
- let s0, s1;
999
+ function peg$parsereference() {
1000
+ let s0;
1001
+
1002
+ s0 = peg$parsequotedReference();
1003
+ if (s0 === peg$FAILED) {
1004
+ s0 = peg$parsesimpleReference();
1005
+ }
1006
+
1007
+ return s0;
1008
+ }
1009
+
1010
+ function peg$parsesimpleReference() {
1011
+ let s0, s1, s2;
915
1012
 
916
1013
  s0 = peg$currPos;
917
- s1 = peg$parsesingleLineValues();
1014
+ s1 = [];
1015
+ s2 = peg$parsereferenceSymbol();
1016
+ if (s2 !== peg$FAILED) {
1017
+ while (s2 !== peg$FAILED) {
1018
+ s1.push(s2);
1019
+ s2 = peg$parsereferenceSymbol();
1020
+ }
1021
+ } else {
1022
+ s1 = peg$FAILED;
1023
+ }
918
1024
  if (s1 !== peg$FAILED) {
919
1025
  peg$savedPos = s0;
920
- s1 = peg$f22(s1);
1026
+ s1 = peg$f25(s1);
921
1027
  }
922
1028
  s0 = s1;
923
1029
 
924
1030
  return s0;
925
1031
  }
926
1032
 
927
- function peg$parsemultiLineValueLink() {
928
- let s0, s1, s2, s3, s4;
1033
+ function peg$parsequotedReference() {
1034
+ let s0;
1035
+
1036
+ s0 = peg$parsedoubleQuotedUniversal();
1037
+ if (s0 === peg$FAILED) {
1038
+ s0 = peg$parsesingleQuotedUniversal();
1039
+ if (s0 === peg$FAILED) {
1040
+ s0 = peg$parsebacktickQuotedUniversal();
1041
+ }
1042
+ }
1043
+
1044
+ return s0;
1045
+ }
1046
+
1047
+ function peg$parsedoubleQuotedUniversal() {
1048
+ let s0, s1, s2, s3;
929
1049
 
930
1050
  s0 = peg$currPos;
931
- if (input.charCodeAt(peg$currPos) === 40) {
932
- s1 = peg$c1;
1051
+ s1 = peg$currPos;
1052
+ peg$silentFails++;
1053
+ if (input.charCodeAt(peg$currPos) === 34) {
1054
+ s2 = peg$c3;
933
1055
  peg$currPos++;
1056
+ } else {
1057
+ s2 = peg$FAILED;
1058
+ if (peg$silentFails === 0) { peg$fail(peg$e5); }
1059
+ }
1060
+ peg$silentFails--;
1061
+ if (s2 !== peg$FAILED) {
1062
+ peg$currPos = s1;
1063
+ s1 = undefined;
934
1064
  } else {
935
1065
  s1 = peg$FAILED;
936
- if (peg$silentFails === 0) { peg$fail(peg$e3); }
937
1066
  }
938
1067
  if (s1 !== peg$FAILED) {
939
- s2 = peg$parsemultiLineValues();
940
- s3 = peg$parse_();
941
- if (input.charCodeAt(peg$currPos) === 41) {
942
- s4 = peg$c2;
1068
+ peg$savedPos = peg$currPos;
1069
+ s2 = peg$f26();
1070
+ if (s2) {
1071
+ s2 = undefined;
1072
+ } else {
1073
+ s2 = peg$FAILED;
1074
+ }
1075
+ if (s2 !== peg$FAILED) {
1076
+ s3 = peg$parseconsumeDouble();
1077
+ if (s3 !== peg$FAILED) {
1078
+ peg$savedPos = s0;
1079
+ s0 = peg$f27(s3);
1080
+ } else {
1081
+ peg$currPos = s0;
1082
+ s0 = peg$FAILED;
1083
+ }
1084
+ } else {
1085
+ peg$currPos = s0;
1086
+ s0 = peg$FAILED;
1087
+ }
1088
+ } else {
1089
+ peg$currPos = s0;
1090
+ s0 = peg$FAILED;
1091
+ }
1092
+
1093
+ return s0;
1094
+ }
1095
+
1096
+ function peg$parseconsumeDouble() {
1097
+ let s0, s1, s2, s3;
1098
+
1099
+ s0 = peg$currPos;
1100
+ if (input.length > peg$currPos) {
1101
+ s1 = input.charAt(peg$currPos);
1102
+ peg$currPos++;
1103
+ } else {
1104
+ s1 = peg$FAILED;
1105
+ if (peg$silentFails === 0) { peg$fail(peg$e6); }
1106
+ }
1107
+ if (s1 !== peg$FAILED) {
1108
+ s2 = [];
1109
+ s3 = peg$parseconsumeDoubleMore();
1110
+ while (s3 !== peg$FAILED) {
1111
+ s2.push(s3);
1112
+ s3 = peg$parseconsumeDoubleMore();
1113
+ }
1114
+ peg$savedPos = s0;
1115
+ s0 = peg$f28(s1, s2);
1116
+ } else {
1117
+ peg$currPos = s0;
1118
+ s0 = peg$FAILED;
1119
+ }
1120
+
1121
+ return s0;
1122
+ }
1123
+
1124
+ function peg$parseconsumeDoubleMore() {
1125
+ let s0, s1, s2;
1126
+
1127
+ s0 = peg$currPos;
1128
+ peg$savedPos = peg$currPos;
1129
+ s1 = peg$f29();
1130
+ if (s1) {
1131
+ s1 = undefined;
1132
+ } else {
1133
+ s1 = peg$FAILED;
1134
+ }
1135
+ if (s1 !== peg$FAILED) {
1136
+ if (input.length > peg$currPos) {
1137
+ s2 = input.charAt(peg$currPos);
943
1138
  peg$currPos++;
944
1139
  } else {
945
- s4 = peg$FAILED;
946
- if (peg$silentFails === 0) { peg$fail(peg$e4); }
1140
+ s2 = peg$FAILED;
1141
+ if (peg$silentFails === 0) { peg$fail(peg$e6); }
947
1142
  }
948
- if (s4 !== peg$FAILED) {
1143
+ if (s2 !== peg$FAILED) {
949
1144
  peg$savedPos = s0;
950
- s0 = peg$f23(s2);
1145
+ s0 = peg$f30(s2);
951
1146
  } else {
952
1147
  peg$currPos = s0;
953
1148
  s0 = peg$FAILED;
@@ -960,25 +1155,39 @@ function peg$parse(input, options) {
960
1155
  return s0;
961
1156
  }
962
1157
 
963
- function peg$parseindentedIdLink() {
964
- let s0, s1, s2, s3, s4;
1158
+ function peg$parsesingleQuotedUniversal() {
1159
+ let s0, s1, s2, s3;
965
1160
 
966
1161
  s0 = peg$currPos;
967
- s1 = peg$parsereference();
1162
+ s1 = peg$currPos;
1163
+ peg$silentFails++;
1164
+ if (input.charCodeAt(peg$currPos) === 39) {
1165
+ s2 = peg$c4;
1166
+ peg$currPos++;
1167
+ } else {
1168
+ s2 = peg$FAILED;
1169
+ if (peg$silentFails === 0) { peg$fail(peg$e7); }
1170
+ }
1171
+ peg$silentFails--;
1172
+ if (s2 !== peg$FAILED) {
1173
+ peg$currPos = s1;
1174
+ s1 = undefined;
1175
+ } else {
1176
+ s1 = peg$FAILED;
1177
+ }
968
1178
  if (s1 !== peg$FAILED) {
969
- s2 = peg$parse__();
970
- if (input.charCodeAt(peg$currPos) === 58) {
971
- s3 = peg$c0;
972
- peg$currPos++;
1179
+ peg$savedPos = peg$currPos;
1180
+ s2 = peg$f31();
1181
+ if (s2) {
1182
+ s2 = undefined;
973
1183
  } else {
974
- s3 = peg$FAILED;
975
- if (peg$silentFails === 0) { peg$fail(peg$e2); }
1184
+ s2 = peg$FAILED;
976
1185
  }
977
- if (s3 !== peg$FAILED) {
978
- s4 = peg$parseeol();
979
- if (s4 !== peg$FAILED) {
1186
+ if (s2 !== peg$FAILED) {
1187
+ s3 = peg$parseconsumeSingle();
1188
+ if (s3 !== peg$FAILED) {
980
1189
  peg$savedPos = s0;
981
- s0 = peg$f24(s1);
1190
+ s0 = peg$f32(s3);
982
1191
  } else {
983
1192
  peg$currPos = s0;
984
1193
  s0 = peg$FAILED;
@@ -995,88 +1204,101 @@ function peg$parse(input, options) {
995
1204
  return s0;
996
1205
  }
997
1206
 
998
- function peg$parsereference() {
999
- let s0;
1207
+ function peg$parseconsumeSingle() {
1208
+ let s0, s1, s2, s3;
1000
1209
 
1001
- s0 = peg$parsedoubleQuotedReference();
1002
- if (s0 === peg$FAILED) {
1003
- s0 = peg$parsesingleQuotedReference();
1004
- if (s0 === peg$FAILED) {
1005
- s0 = peg$parsesimpleReference();
1210
+ s0 = peg$currPos;
1211
+ if (input.length > peg$currPos) {
1212
+ s1 = input.charAt(peg$currPos);
1213
+ peg$currPos++;
1214
+ } else {
1215
+ s1 = peg$FAILED;
1216
+ if (peg$silentFails === 0) { peg$fail(peg$e6); }
1217
+ }
1218
+ if (s1 !== peg$FAILED) {
1219
+ s2 = [];
1220
+ s3 = peg$parseconsumeSingleMore();
1221
+ while (s3 !== peg$FAILED) {
1222
+ s2.push(s3);
1223
+ s3 = peg$parseconsumeSingleMore();
1006
1224
  }
1225
+ peg$savedPos = s0;
1226
+ s0 = peg$f33(s1, s2);
1227
+ } else {
1228
+ peg$currPos = s0;
1229
+ s0 = peg$FAILED;
1007
1230
  }
1008
1231
 
1009
1232
  return s0;
1010
1233
  }
1011
1234
 
1012
- function peg$parsesimpleReference() {
1235
+ function peg$parseconsumeSingleMore() {
1013
1236
  let s0, s1, s2;
1014
1237
 
1015
1238
  s0 = peg$currPos;
1016
- s1 = [];
1017
- s2 = peg$parsereferenceSymbol();
1018
- if (s2 !== peg$FAILED) {
1019
- while (s2 !== peg$FAILED) {
1020
- s1.push(s2);
1021
- s2 = peg$parsereferenceSymbol();
1022
- }
1239
+ peg$savedPos = peg$currPos;
1240
+ s1 = peg$f34();
1241
+ if (s1) {
1242
+ s1 = undefined;
1023
1243
  } else {
1024
1244
  s1 = peg$FAILED;
1025
1245
  }
1026
1246
  if (s1 !== peg$FAILED) {
1027
- peg$savedPos = s0;
1028
- s1 = peg$f25(s1);
1247
+ if (input.length > peg$currPos) {
1248
+ s2 = input.charAt(peg$currPos);
1249
+ peg$currPos++;
1250
+ } else {
1251
+ s2 = peg$FAILED;
1252
+ if (peg$silentFails === 0) { peg$fail(peg$e6); }
1253
+ }
1254
+ if (s2 !== peg$FAILED) {
1255
+ peg$savedPos = s0;
1256
+ s0 = peg$f35(s2);
1257
+ } else {
1258
+ peg$currPos = s0;
1259
+ s0 = peg$FAILED;
1260
+ }
1261
+ } else {
1262
+ peg$currPos = s0;
1263
+ s0 = peg$FAILED;
1029
1264
  }
1030
- s0 = s1;
1031
1265
 
1032
1266
  return s0;
1033
1267
  }
1034
1268
 
1035
- function peg$parsedoubleQuotedReference() {
1269
+ function peg$parsebacktickQuotedUniversal() {
1036
1270
  let s0, s1, s2, s3;
1037
1271
 
1038
1272
  s0 = peg$currPos;
1039
- if (input.charCodeAt(peg$currPos) === 34) {
1040
- s1 = peg$c3;
1273
+ s1 = peg$currPos;
1274
+ peg$silentFails++;
1275
+ if (input.charCodeAt(peg$currPos) === 96) {
1276
+ s2 = peg$c5;
1041
1277
  peg$currPos++;
1278
+ } else {
1279
+ s2 = peg$FAILED;
1280
+ if (peg$silentFails === 0) { peg$fail(peg$e8); }
1281
+ }
1282
+ peg$silentFails--;
1283
+ if (s2 !== peg$FAILED) {
1284
+ peg$currPos = s1;
1285
+ s1 = undefined;
1042
1286
  } else {
1043
1287
  s1 = peg$FAILED;
1044
- if (peg$silentFails === 0) { peg$fail(peg$e5); }
1045
1288
  }
1046
1289
  if (s1 !== peg$FAILED) {
1047
- s2 = [];
1048
- s3 = input.charAt(peg$currPos);
1049
- if (peg$r2.test(s3)) {
1050
- peg$currPos++;
1051
- } else {
1052
- s3 = peg$FAILED;
1053
- if (peg$silentFails === 0) { peg$fail(peg$e6); }
1054
- }
1055
- if (s3 !== peg$FAILED) {
1056
- while (s3 !== peg$FAILED) {
1057
- s2.push(s3);
1058
- s3 = input.charAt(peg$currPos);
1059
- if (peg$r2.test(s3)) {
1060
- peg$currPos++;
1061
- } else {
1062
- s3 = peg$FAILED;
1063
- if (peg$silentFails === 0) { peg$fail(peg$e6); }
1064
- }
1065
- }
1290
+ peg$savedPos = peg$currPos;
1291
+ s2 = peg$f36();
1292
+ if (s2) {
1293
+ s2 = undefined;
1066
1294
  } else {
1067
1295
  s2 = peg$FAILED;
1068
1296
  }
1069
1297
  if (s2 !== peg$FAILED) {
1070
- if (input.charCodeAt(peg$currPos) === 34) {
1071
- s3 = peg$c3;
1072
- peg$currPos++;
1073
- } else {
1074
- s3 = peg$FAILED;
1075
- if (peg$silentFails === 0) { peg$fail(peg$e5); }
1076
- }
1298
+ s3 = peg$parseconsumeBacktick();
1077
1299
  if (s3 !== peg$FAILED) {
1078
1300
  peg$savedPos = s0;
1079
- s0 = peg$f26(s2);
1301
+ s0 = peg$f37(s3);
1080
1302
  } else {
1081
1303
  peg$currPos = s0;
1082
1304
  s0 = peg$FAILED;
@@ -1093,55 +1315,56 @@ function peg$parse(input, options) {
1093
1315
  return s0;
1094
1316
  }
1095
1317
 
1096
- function peg$parsesingleQuotedReference() {
1318
+ function peg$parseconsumeBacktick() {
1097
1319
  let s0, s1, s2, s3;
1098
1320
 
1099
1321
  s0 = peg$currPos;
1100
- if (input.charCodeAt(peg$currPos) === 39) {
1101
- s1 = peg$c4;
1322
+ if (input.length > peg$currPos) {
1323
+ s1 = input.charAt(peg$currPos);
1102
1324
  peg$currPos++;
1103
1325
  } else {
1104
1326
  s1 = peg$FAILED;
1105
- if (peg$silentFails === 0) { peg$fail(peg$e7); }
1327
+ if (peg$silentFails === 0) { peg$fail(peg$e6); }
1106
1328
  }
1107
1329
  if (s1 !== peg$FAILED) {
1108
1330
  s2 = [];
1109
- s3 = input.charAt(peg$currPos);
1110
- if (peg$r3.test(s3)) {
1111
- peg$currPos++;
1112
- } else {
1113
- s3 = peg$FAILED;
1114
- if (peg$silentFails === 0) { peg$fail(peg$e8); }
1331
+ s3 = peg$parseconsumeBacktickMore();
1332
+ while (s3 !== peg$FAILED) {
1333
+ s2.push(s3);
1334
+ s3 = peg$parseconsumeBacktickMore();
1115
1335
  }
1116
- if (s3 !== peg$FAILED) {
1117
- while (s3 !== peg$FAILED) {
1118
- s2.push(s3);
1119
- s3 = input.charAt(peg$currPos);
1120
- if (peg$r3.test(s3)) {
1121
- peg$currPos++;
1122
- } else {
1123
- s3 = peg$FAILED;
1124
- if (peg$silentFails === 0) { peg$fail(peg$e8); }
1125
- }
1126
- }
1336
+ peg$savedPos = s0;
1337
+ s0 = peg$f38(s1, s2);
1338
+ } else {
1339
+ peg$currPos = s0;
1340
+ s0 = peg$FAILED;
1341
+ }
1342
+
1343
+ return s0;
1344
+ }
1345
+
1346
+ function peg$parseconsumeBacktickMore() {
1347
+ let s0, s1, s2;
1348
+
1349
+ s0 = peg$currPos;
1350
+ peg$savedPos = peg$currPos;
1351
+ s1 = peg$f39();
1352
+ if (s1) {
1353
+ s1 = undefined;
1354
+ } else {
1355
+ s1 = peg$FAILED;
1356
+ }
1357
+ if (s1 !== peg$FAILED) {
1358
+ if (input.length > peg$currPos) {
1359
+ s2 = input.charAt(peg$currPos);
1360
+ peg$currPos++;
1127
1361
  } else {
1128
1362
  s2 = peg$FAILED;
1363
+ if (peg$silentFails === 0) { peg$fail(peg$e6); }
1129
1364
  }
1130
1365
  if (s2 !== peg$FAILED) {
1131
- if (input.charCodeAt(peg$currPos) === 39) {
1132
- s3 = peg$c4;
1133
- peg$currPos++;
1134
- } else {
1135
- s3 = peg$FAILED;
1136
- if (peg$silentFails === 0) { peg$fail(peg$e7); }
1137
- }
1138
- if (s3 !== peg$FAILED) {
1139
- peg$savedPos = s0;
1140
- s0 = peg$f27(s2);
1141
- } else {
1142
- peg$currPos = s0;
1143
- s0 = peg$FAILED;
1144
- }
1366
+ peg$savedPos = s0;
1367
+ s0 = peg$f40(s2);
1145
1368
  } else {
1146
1369
  peg$currPos = s0;
1147
1370
  s0 = peg$FAILED;
@@ -1160,7 +1383,7 @@ function peg$parse(input, options) {
1160
1383
  s0 = peg$currPos;
1161
1384
  s1 = [];
1162
1385
  if (input.charCodeAt(peg$currPos) === 32) {
1163
- s2 = peg$c5;
1386
+ s2 = peg$c6;
1164
1387
  peg$currPos++;
1165
1388
  } else {
1166
1389
  s2 = peg$FAILED;
@@ -1169,7 +1392,7 @@ function peg$parse(input, options) {
1169
1392
  while (s2 !== peg$FAILED) {
1170
1393
  s1.push(s2);
1171
1394
  if (input.charCodeAt(peg$currPos) === 32) {
1172
- s2 = peg$c5;
1395
+ s2 = peg$c6;
1173
1396
  peg$currPos++;
1174
1397
  } else {
1175
1398
  s2 = peg$FAILED;
@@ -1177,7 +1400,7 @@ function peg$parse(input, options) {
1177
1400
  }
1178
1401
  }
1179
1402
  peg$savedPos = s0;
1180
- s1 = peg$f28(s1);
1403
+ s1 = peg$f41(s1);
1181
1404
  s0 = s1;
1182
1405
 
1183
1406
  return s0;
@@ -1189,7 +1412,7 @@ function peg$parse(input, options) {
1189
1412
  s0 = peg$currPos;
1190
1413
  s1 = [];
1191
1414
  if (input.charCodeAt(peg$currPos) === 32) {
1192
- s2 = peg$c5;
1415
+ s2 = peg$c6;
1193
1416
  peg$currPos++;
1194
1417
  } else {
1195
1418
  s2 = peg$FAILED;
@@ -1198,7 +1421,7 @@ function peg$parse(input, options) {
1198
1421
  while (s2 !== peg$FAILED) {
1199
1422
  s1.push(s2);
1200
1423
  if (input.charCodeAt(peg$currPos) === 32) {
1201
- s2 = peg$c5;
1424
+ s2 = peg$c6;
1202
1425
  peg$currPos++;
1203
1426
  } else {
1204
1427
  s2 = peg$FAILED;
@@ -1206,7 +1429,7 @@ function peg$parse(input, options) {
1206
1429
  }
1207
1430
  }
1208
1431
  peg$savedPos = peg$currPos;
1209
- s2 = peg$f29(s1);
1432
+ s2 = peg$f42(s1);
1210
1433
  if (s2) {
1211
1434
  s2 = undefined;
1212
1435
  } else {
@@ -1214,7 +1437,7 @@ function peg$parse(input, options) {
1214
1437
  }
1215
1438
  if (s2 !== peg$FAILED) {
1216
1439
  peg$savedPos = s0;
1217
- s0 = peg$f30(s1);
1440
+ s0 = peg$f43(s1);
1218
1441
  } else {
1219
1442
  peg$currPos = s0;
1220
1443
  s0 = peg$FAILED;
@@ -1229,7 +1452,7 @@ function peg$parse(input, options) {
1229
1452
  s0 = peg$currPos;
1230
1453
  s1 = [];
1231
1454
  if (input.charCodeAt(peg$currPos) === 32) {
1232
- s2 = peg$c5;
1455
+ s2 = peg$c6;
1233
1456
  peg$currPos++;
1234
1457
  } else {
1235
1458
  s2 = peg$FAILED;
@@ -1238,7 +1461,7 @@ function peg$parse(input, options) {
1238
1461
  while (s2 !== peg$FAILED) {
1239
1462
  s1.push(s2);
1240
1463
  if (input.charCodeAt(peg$currPos) === 32) {
1241
- s2 = peg$c5;
1464
+ s2 = peg$c6;
1242
1465
  peg$currPos++;
1243
1466
  } else {
1244
1467
  s2 = peg$FAILED;
@@ -1246,7 +1469,7 @@ function peg$parse(input, options) {
1246
1469
  }
1247
1470
  }
1248
1471
  peg$savedPos = peg$currPos;
1249
- s2 = peg$f31(s1);
1472
+ s2 = peg$f44(s1);
1250
1473
  if (s2) {
1251
1474
  s2 = undefined;
1252
1475
  } else {
@@ -1292,6 +1515,9 @@ function peg$parse(input, options) {
1292
1515
  }
1293
1516
  if (s2 === peg$FAILED) {
1294
1517
  s2 = peg$parseeof();
1518
+ if (s2 === peg$FAILED) {
1519
+ s2 = peg$parsenestedGroupEnd();
1520
+ }
1295
1521
  }
1296
1522
  if (s2 !== peg$FAILED) {
1297
1523
  s1 = [s1, s2];
@@ -1304,6 +1530,49 @@ function peg$parse(input, options) {
1304
1530
  return s0;
1305
1531
  }
1306
1532
 
1533
+ function peg$parsenestedGroupEnd() {
1534
+ let s0, s1, s2, s3;
1535
+
1536
+ s0 = peg$currPos;
1537
+ peg$savedPos = peg$currPos;
1538
+ s1 = peg$f45();
1539
+ if (s1) {
1540
+ s1 = undefined;
1541
+ } else {
1542
+ s1 = peg$FAILED;
1543
+ }
1544
+ if (s1 !== peg$FAILED) {
1545
+ s2 = peg$currPos;
1546
+ peg$silentFails++;
1547
+ if (input.charCodeAt(peg$currPos) === 41) {
1548
+ s3 = peg$c1;
1549
+ peg$currPos++;
1550
+ } else {
1551
+ s3 = peg$FAILED;
1552
+ if (peg$silentFails === 0) { peg$fail(peg$e3); }
1553
+ }
1554
+ peg$silentFails--;
1555
+ if (s3 !== peg$FAILED) {
1556
+ peg$currPos = s2;
1557
+ s2 = undefined;
1558
+ } else {
1559
+ s2 = peg$FAILED;
1560
+ }
1561
+ if (s2 !== peg$FAILED) {
1562
+ s1 = [s1, s2];
1563
+ s0 = s1;
1564
+ } else {
1565
+ peg$currPos = s0;
1566
+ s0 = peg$FAILED;
1567
+ }
1568
+ } else {
1569
+ peg$currPos = s0;
1570
+ s0 = peg$FAILED;
1571
+ }
1572
+
1573
+ return s0;
1574
+ }
1575
+
1307
1576
  function peg$parseeof() {
1308
1577
  let s0, s1;
1309
1578
 
@@ -1314,7 +1583,7 @@ function peg$parse(input, options) {
1314
1583
  peg$currPos++;
1315
1584
  } else {
1316
1585
  s1 = peg$FAILED;
1317
- if (peg$silentFails === 0) { peg$fail(peg$e10); }
1586
+ if (peg$silentFails === 0) { peg$fail(peg$e6); }
1318
1587
  }
1319
1588
  peg$silentFails--;
1320
1589
  if (s1 === peg$FAILED) {
@@ -1369,11 +1638,11 @@ function peg$parse(input, options) {
1369
1638
  let s0;
1370
1639
 
1371
1640
  s0 = input.charAt(peg$currPos);
1372
- if (peg$r4.test(s0)) {
1641
+ if (peg$r2.test(s0)) {
1373
1642
  peg$currPos++;
1374
1643
  } else {
1375
1644
  s0 = peg$FAILED;
1376
- if (peg$silentFails === 0) { peg$fail(peg$e11); }
1645
+ if (peg$silentFails === 0) { peg$fail(peg$e10); }
1377
1646
  }
1378
1647
 
1379
1648
  return s0;
@@ -1383,11 +1652,11 @@ function peg$parse(input, options) {
1383
1652
  let s0;
1384
1653
 
1385
1654
  s0 = input.charAt(peg$currPos);
1386
- if (peg$r5.test(s0)) {
1655
+ if (peg$r3.test(s0)) {
1387
1656
  peg$currPos++;
1388
1657
  } else {
1389
1658
  s0 = peg$FAILED;
1390
- if (peg$silentFails === 0) { peg$fail(peg$e12); }
1659
+ if (peg$silentFails === 0) { peg$fail(peg$e11); }
1391
1660
  }
1392
1661
 
1393
1662
  return s0;
@@ -1396,6 +1665,37 @@ function peg$parse(input, options) {
1396
1665
 
1397
1666
  let indentationStack = [0];
1398
1667
  let baseIndentation = null;
1668
+ // Saved indentation contexts of the enclosing scopes. Every parenthesised
1669
+ // group opens a nested context that starts fresh at indentation level zero,
1670
+ // so line breaks and indentation mean the same thing at every depth.
1671
+ let contextStack = [];
1672
+
1673
+ function resetState() {
1674
+ indentationStack = [0];
1675
+ baseIndentation = null;
1676
+ contextStack = [];
1677
+ return true;
1678
+ }
1679
+
1680
+ function enterNestedContext() {
1681
+ contextStack.push({ indentationStack, baseIndentation });
1682
+ indentationStack = [0];
1683
+ baseIndentation = null;
1684
+ return true;
1685
+ }
1686
+
1687
+ function exitNestedContext() {
1688
+ const saved = contextStack.pop();
1689
+ if (saved) {
1690
+ indentationStack = saved.indentationStack;
1691
+ baseIndentation = saved.baseIndentation;
1692
+ }
1693
+ return true;
1694
+ }
1695
+
1696
+ function isInsideNestedContext() {
1697
+ return contextStack.length > 0;
1698
+ }
1399
1699
 
1400
1700
  function setBaseIndentation(spaces) {
1401
1701
  if (baseIndentation === null) {
@@ -1430,6 +1730,93 @@ function peg$parse(input, options) {
1430
1730
  return indentationStack[indentationStack.length - 1];
1431
1731
  }
1432
1732
 
1733
+ // A body written between an even run of delimiters is substantive when it
1734
+ // holds at least one visible character and does not straddle a parenthesis.
1735
+ // An even run can always be read as delimiter pairs enclosing nothing, so the
1736
+ // n-quote reading is only taken when it carries something the pairs cannot.
1737
+ function isSubstantiveBody(content) {
1738
+ let depth = 0;
1739
+ let hasVisible = false;
1740
+
1741
+ for (const c of content) {
1742
+ if (c === '(') {
1743
+ depth++;
1744
+ } else if (c === ')') {
1745
+ depth--;
1746
+ if (depth < 0) {
1747
+ return false;
1748
+ }
1749
+ }
1750
+ if (!/\s/.test(c)) {
1751
+ hasVisible = true;
1752
+ }
1753
+ }
1754
+
1755
+ return hasVisible && depth === 0;
1756
+ }
1757
+
1758
+ // Universal procedural parser for N-quote strings (any N >= 1)
1759
+ // Parses from the given position in the input string
1760
+ // A run of an even number of delimiters that does not open a reference with a
1761
+ // substantive body is the empty reference: the shortest reading, a bare
1762
+ // delimiter pair enclosing nothing, wins over a longer n-quote delimiter.
1763
+ // Returns { value, length } or null
1764
+ function parseQuotedStringAt(inputStr, startPos, quoteChar) {
1765
+ if (startPos >= inputStr.length || inputStr[startPos] !== quoteChar) {
1766
+ return null;
1767
+ }
1768
+
1769
+ // Count opening quotes
1770
+ let quoteCount = 0;
1771
+ let pos = startPos;
1772
+ while (pos < inputStr.length && inputStr[pos] === quoteChar) {
1773
+ quoteCount++;
1774
+ pos++;
1775
+ }
1776
+
1777
+ const isEvenRun = quoteCount % 2 === 0;
1778
+ const emptyReference = isEvenRun ? { value: '', length: quoteCount } : null;
1779
+
1780
+ const closeSeq = quoteChar.repeat(quoteCount);
1781
+ const escapeSeq = quoteChar.repeat(quoteCount * 2);
1782
+
1783
+ let content = '';
1784
+ while (pos < inputStr.length) {
1785
+ // Check for escape sequence (2*N quotes)
1786
+ if (inputStr.substr(pos, escapeSeq.length) === escapeSeq) {
1787
+ content += closeSeq; // 2*N quotes become N quotes
1788
+ pos += escapeSeq.length;
1789
+ continue;
1790
+ }
1791
+
1792
+ // Check for closing sequence (exactly N quotes)
1793
+ if (inputStr.substr(pos, quoteCount) === closeSeq) {
1794
+ // Verify it's exactly N quotes (not followed by more of same char)
1795
+ const afterClose = pos + quoteCount;
1796
+ if (afterClose >= inputStr.length || inputStr[afterClose] !== quoteChar) {
1797
+ // Found valid closing
1798
+ if (isEvenRun && !isSubstantiveBody(content)) {
1799
+ return emptyReference;
1800
+ }
1801
+ return {
1802
+ value: content,
1803
+ length: afterClose - startPos
1804
+ };
1805
+ }
1806
+ }
1807
+
1808
+ // Add character to content
1809
+ content += inputStr[pos];
1810
+ pos++;
1811
+ }
1812
+
1813
+ return emptyReference; // No valid closing found
1814
+ }
1815
+
1816
+ // Global state for passing parsed values between predicate and action
1817
+ let parsedValue = null;
1818
+ let parsedLength = 0;
1819
+
1433
1820
  peg$result = peg$startRuleFunction();
1434
1821
 
1435
1822
  const peg$success = (peg$result !== peg$FAILED && peg$currPos === input.length);