unexpectedly 3.0.3 → 4.0.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.
package/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import {Runner, SKIPPED} from './runner.js';
2
2
  import {hexlify, mapObj} from './utils.js';
3
3
  import Mocha from 'mocha';
4
+ // eslint-disable-next-line n/prefer-import/assert-strict
4
5
  import assert from 'node:assert';
5
6
  import fs from 'node:fs/promises';
6
7
  import {parse} from './testFile.peg.js';
package/package.json CHANGED
@@ -1,9 +1,18 @@
1
1
  {
2
2
  "name": "unexpectedly",
3
- "version": "3.0.3",
3
+ "version": "4.0.0",
4
4
  "description": "Keep a bunch of test cases in a file, with their expected results",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
+ "files": [
8
+ "index.js",
9
+ "runner.js",
10
+ "testFile.peg.js",
11
+ "utils.js",
12
+ "version.js",
13
+ "vendor/",
14
+ "bin/"
15
+ ],
7
16
  "bin": {
8
17
  "unexpectedly": "bin/unexpectedly.js"
9
18
  },
@@ -23,11 +32,18 @@
23
32
  },
24
33
  "license": "MPL-2.0",
25
34
  "dependencies": {
26
- "@peggyjs/from-mem": "3.1.1",
27
- "commander": "14.0.0",
28
- "mocha": "^11.7.1"
35
+ "@peggyjs/from-mem": "4.0.0",
36
+ "commander": "^15.0.0",
37
+ "mocha": "^12.0.3"
38
+ },
39
+ "packageManager": "pnpm@12.14.0",
40
+ "pnpm": {
41
+ "overrides": {
42
+ "mocha@11.7.5>diff": "8.0.3",
43
+ "mocha@11.7.5>serialize-javascript": "7.0.4"
44
+ }
29
45
  },
30
46
  "engines": {
31
- "node": ">=20"
47
+ "node": ">=22"
32
48
  }
33
49
  }
package/testFile.peg.js CHANGED
@@ -1,4 +1,4 @@
1
- // @generated by Peggy 5.0.6.
1
+ // @generated by Peggy 5.1.1.
2
2
  //
3
3
  // https://peggyjs.org/
4
4
 
@@ -61,10 +61,9 @@ class peg$SyntaxError extends SyntaxError {
61
61
  return s;
62
62
  }
63
63
 
64
- function literalEscape(s) {
64
+ function escape(s, special) {
65
65
  return unicodeEscape(s
66
- .replace(/\\/g, "\\\\")
67
- .replace(/"/g, "\\\"")
66
+ .replace(special, "\\$&")
68
67
  .replace(/\0/g, "\\0")
69
68
  .replace(/\t/g, "\\t")
70
69
  .replace(/\n/g, "\\n")
@@ -73,18 +72,12 @@ class peg$SyntaxError extends SyntaxError {
73
72
  .replace(/[\x10-\x1F\x7F-\x9F]/g, ch => "\\x" + hex(ch)));
74
73
  }
75
74
 
75
+ function literalEscape(s) {
76
+ return escape(s, /[\\"]/g);
77
+ }
78
+
76
79
  function classEscape(s) {
77
- return unicodeEscape(s
78
- .replace(/\\/g, "\\\\")
79
- .replace(/\]/g, "\\]")
80
- .replace(/\^/g, "\\^")
81
- .replace(/-/g, "\\-")
82
- .replace(/\0/g, "\\0")
83
- .replace(/\t/g, "\\t")
84
- .replace(/\n/g, "\\n")
85
- .replace(/\r/g, "\\r")
86
- .replace(/[\x00-\x0F]/g, ch => "\\x0" + hex(ch))
87
- .replace(/[\x10-\x1F\x7F-\x9F]/g, ch => "\\x" + hex(ch)));
80
+ return escape(s, /[\\\]^-]/g);
88
81
  }
89
82
 
90
83
  const DESCRIBE_EXPECTATION_FNS = {
@@ -189,14 +182,6 @@ function peg$parse(input, options) {
189
182
  const peg$c19 = "\r\n";
190
183
  const peg$c20 = "\r";
191
184
 
192
- const peg$r0 = /^[^\\"]/;
193
- const peg$r1 = /^[^\\']/;
194
- const peg$r2 = /^[^\\`]/;
195
- const peg$r3 = /^[a-fA-F0-9]/;
196
- const peg$r4 = /^[^ #:'"\t\r\n]/;
197
- const peg$r5 = /^[^\r\n]/;
198
- const peg$r6 = /^[ \t]/;
199
- const peg$r7 = /^[ \t\r\n]/;
200
185
 
201
186
  const peg$e0 = peg$literalExpectation("#!", false);
202
187
  const peg$e1 = peg$literalExpectation("!", false);
@@ -289,6 +274,7 @@ function peg$parse(input, options) {
289
274
  let peg$silentFails = options.peg$silentFails | 0;
290
275
 
291
276
  let peg$result;
277
+ let peg$charCode;
292
278
 
293
279
  if (options.startRule) {
294
280
  if (!(options.startRule in peg$startRuleFunctions)) {
@@ -592,22 +578,7 @@ function peg$parse(input, options) {
592
578
  s1 = peg$parseresults();
593
579
  if (s1 !== peg$FAILED) {
594
580
  s2 = [];
595
- s3 = peg$currPos;
596
- s4 = peg$parseLWS();
597
- if (s4 !== peg$FAILED) {
598
- s5 = peg$parsechunk();
599
- if (s5 !== peg$FAILED) {
600
- s3 = s5;
601
- } else {
602
- peg$currPos = s3;
603
- s3 = peg$FAILED;
604
- }
605
- } else {
606
- peg$currPos = s3;
607
- s3 = peg$FAILED;
608
- }
609
- while (s3 !== peg$FAILED) {
610
- s2.push(s3);
581
+ for (;;) {
611
582
  s3 = peg$currPos;
612
583
  s4 = peg$parseLWS();
613
584
  if (s4 !== peg$FAILED) {
@@ -622,6 +593,8 @@ function peg$parse(input, options) {
622
593
  peg$currPos = s3;
623
594
  s3 = peg$FAILED;
624
595
  }
596
+ if (s3 === peg$FAILED) { break; }
597
+ s2.push(s3);
625
598
  }
626
599
  s3 = peg$parsecomment();
627
600
  if (s3 === peg$FAILED) {
@@ -687,10 +660,10 @@ function peg$parse(input, options) {
687
660
  }
688
661
  if (s1 !== peg$FAILED) {
689
662
  s2 = [];
690
- s3 = peg$parsedqchar();
691
- while (s3 !== peg$FAILED) {
692
- s2.push(s3);
663
+ for (;;) {
693
664
  s3 = peg$parsedqchar();
665
+ if (s3 === peg$FAILED) { break; }
666
+ s2.push(s3);
694
667
  }
695
668
  if (input.charCodeAt(peg$currPos) === 34) {
696
669
  s3 = peg$c3;
@@ -721,10 +694,10 @@ function peg$parse(input, options) {
721
694
  }
722
695
  if (s1 !== peg$FAILED) {
723
696
  s2 = [];
724
- s3 = peg$parsesqchar();
725
- while (s3 !== peg$FAILED) {
726
- s2.push(s3);
697
+ for (;;) {
727
698
  s3 = peg$parsesqchar();
699
+ if (s3 === peg$FAILED) { break; }
700
+ s2.push(s3);
728
701
  }
729
702
  if (input.charCodeAt(peg$currPos) === 39) {
730
703
  s3 = peg$c4;
@@ -755,10 +728,10 @@ function peg$parse(input, options) {
755
728
  }
756
729
  if (s1 !== peg$FAILED) {
757
730
  s2 = [];
758
- s3 = peg$parsebqchar();
759
- while (s3 !== peg$FAILED) {
760
- s2.push(s3);
731
+ for (;;) {
761
732
  s3 = peg$parsebqchar();
733
+ if (s3 === peg$FAILED) { break; }
734
+ s2.push(s3);
762
735
  }
763
736
  if (input.charCodeAt(peg$currPos) === 96) {
764
737
  s3 = peg$c5;
@@ -806,25 +779,18 @@ function peg$parse(input, options) {
806
779
  if (s0 === peg$FAILED) {
807
780
  s0 = peg$currPos;
808
781
  s1 = [];
809
- s2 = input.charAt(peg$currPos);
810
- if (peg$r0.test(s2)) {
811
- peg$currPos++;
812
- } else {
813
- s2 = peg$FAILED;
814
- if (peg$silentFails === 0) { peg$fail(peg$e8); }
815
- }
816
- if (s2 !== peg$FAILED) {
817
- while (s2 !== peg$FAILED) {
818
- s1.push(s2);
819
- s2 = input.charAt(peg$currPos);
820
- if (peg$r0.test(s2)) {
821
- peg$currPos++;
822
- } else {
823
- s2 = peg$FAILED;
824
- if (peg$silentFails === 0) { peg$fail(peg$e8); }
825
- }
782
+ for (;;) {
783
+ s2 = input.charAt(peg$currPos);
784
+ if (s2 !== "" && !(peg$charCode = s2.charCodeAt(0), peg$charCode === 92 || peg$charCode === 34)) {
785
+ peg$currPos++;
786
+ } else {
787
+ s2 = peg$FAILED;
788
+ if (peg$silentFails === 0) { peg$fail(peg$e8); }
826
789
  }
827
- } else {
790
+ if (s2 === peg$FAILED) { break; }
791
+ s1.push(s2);
792
+ }
793
+ if (s1.length < 1) {
828
794
  s1 = peg$FAILED;
829
795
  }
830
796
  if (s1 !== peg$FAILED) {
@@ -865,25 +831,18 @@ function peg$parse(input, options) {
865
831
  if (s0 === peg$FAILED) {
866
832
  s0 = peg$currPos;
867
833
  s1 = [];
868
- s2 = input.charAt(peg$currPos);
869
- if (peg$r1.test(s2)) {
870
- peg$currPos++;
871
- } else {
872
- s2 = peg$FAILED;
873
- if (peg$silentFails === 0) { peg$fail(peg$e11); }
874
- }
875
- if (s2 !== peg$FAILED) {
876
- while (s2 !== peg$FAILED) {
877
- s1.push(s2);
878
- s2 = input.charAt(peg$currPos);
879
- if (peg$r1.test(s2)) {
880
- peg$currPos++;
881
- } else {
882
- s2 = peg$FAILED;
883
- if (peg$silentFails === 0) { peg$fail(peg$e11); }
884
- }
834
+ for (;;) {
835
+ s2 = input.charAt(peg$currPos);
836
+ if (s2 !== "" && !(peg$charCode = s2.charCodeAt(0), peg$charCode === 92 || peg$charCode === 39)) {
837
+ peg$currPos++;
838
+ } else {
839
+ s2 = peg$FAILED;
840
+ if (peg$silentFails === 0) { peg$fail(peg$e11); }
885
841
  }
886
- } else {
842
+ if (s2 === peg$FAILED) { break; }
843
+ s1.push(s2);
844
+ }
845
+ if (s1.length < 1) {
887
846
  s1 = peg$FAILED;
888
847
  }
889
848
  if (s1 !== peg$FAILED) {
@@ -924,25 +883,18 @@ function peg$parse(input, options) {
924
883
  if (s0 === peg$FAILED) {
925
884
  s0 = peg$currPos;
926
885
  s1 = [];
927
- s2 = input.charAt(peg$currPos);
928
- if (peg$r2.test(s2)) {
929
- peg$currPos++;
930
- } else {
931
- s2 = peg$FAILED;
932
- if (peg$silentFails === 0) { peg$fail(peg$e14); }
933
- }
934
- if (s2 !== peg$FAILED) {
935
- while (s2 !== peg$FAILED) {
936
- s1.push(s2);
937
- s2 = input.charAt(peg$currPos);
938
- if (peg$r2.test(s2)) {
939
- peg$currPos++;
940
- } else {
941
- s2 = peg$FAILED;
942
- if (peg$silentFails === 0) { peg$fail(peg$e14); }
943
- }
886
+ for (;;) {
887
+ s2 = input.charAt(peg$currPos);
888
+ if (s2 !== "" && !(peg$charCode = s2.charCodeAt(0), peg$charCode === 92 || peg$charCode === 96)) {
889
+ peg$currPos++;
890
+ } else {
891
+ s2 = peg$FAILED;
892
+ if (peg$silentFails === 0) { peg$fail(peg$e14); }
944
893
  }
945
- } else {
894
+ if (s2 === peg$FAILED) { break; }
895
+ s1.push(s2);
896
+ }
897
+ if (s1.length < 1) {
946
898
  s1 = peg$FAILED;
947
899
  }
948
900
  if (s1 !== peg$FAILED) {
@@ -975,25 +927,18 @@ function peg$parse(input, options) {
975
927
  if (s1 !== peg$FAILED) {
976
928
  s2 = peg$currPos;
977
929
  s3 = [];
978
- s4 = input.charAt(peg$currPos);
979
- if (peg$r3.test(s4)) {
980
- peg$currPos++;
981
- } else {
982
- s4 = peg$FAILED;
983
- if (peg$silentFails === 0) { peg$fail(peg$e16); }
984
- }
985
- if (s4 !== peg$FAILED) {
986
- while (s4 !== peg$FAILED) {
987
- s3.push(s4);
988
- s4 = input.charAt(peg$currPos);
989
- if (peg$r3.test(s4)) {
990
- peg$currPos++;
991
- } else {
992
- s4 = peg$FAILED;
993
- if (peg$silentFails === 0) { peg$fail(peg$e16); }
994
- }
930
+ for (;;) {
931
+ s4 = input.charAt(peg$currPos);
932
+ if ((peg$charCode = s4.charCodeAt(0), (peg$charCode >= 97 && peg$charCode <= 102) || (peg$charCode >= 65 && peg$charCode <= 70) || (peg$charCode >= 48 && peg$charCode <= 57))) {
933
+ peg$currPos++;
934
+ } else {
935
+ s4 = peg$FAILED;
936
+ if (peg$silentFails === 0) { peg$fail(peg$e16); }
995
937
  }
996
- } else {
938
+ if (s4 === peg$FAILED) { break; }
939
+ s3.push(s4);
940
+ }
941
+ if (s3.length < 1) {
997
942
  s3 = peg$FAILED;
998
943
  }
999
944
  if (s3 !== peg$FAILED) {
@@ -1021,13 +966,12 @@ function peg$parse(input, options) {
1021
966
 
1022
967
  s0 = peg$currPos;
1023
968
  s1 = [];
1024
- s2 = peg$parsewchar();
1025
- if (s2 !== peg$FAILED) {
1026
- while (s2 !== peg$FAILED) {
1027
- s1.push(s2);
1028
- s2 = peg$parsewchar();
1029
- }
1030
- } else {
969
+ for (;;) {
970
+ s2 = peg$parsewchar();
971
+ if (s2 === peg$FAILED) { break; }
972
+ s1.push(s2);
973
+ }
974
+ if (s1.length < 1) {
1031
975
  s1 = peg$FAILED;
1032
976
  }
1033
977
  if (s1 !== peg$FAILED) {
@@ -1044,37 +988,29 @@ function peg$parse(input, options) {
1044
988
 
1045
989
  peg$silentFails++;
1046
990
  s0 = [];
1047
- s1 = peg$parseqchar();
1048
- if (s1 !== peg$FAILED) {
1049
- while (s1 !== peg$FAILED) {
1050
- s0.push(s1);
1051
- s1 = peg$parseqchar();
1052
- }
1053
- } else {
991
+ for (;;) {
992
+ s1 = peg$parseqchar();
993
+ if (s1 === peg$FAILED) { break; }
994
+ s0.push(s1);
995
+ }
996
+ if (s0.length < 1) {
1054
997
  s0 = peg$FAILED;
1055
998
  }
1056
999
  if (s0 === peg$FAILED) {
1057
1000
  s0 = peg$currPos;
1058
1001
  s1 = [];
1059
- s2 = input.charAt(peg$currPos);
1060
- if (peg$r4.test(s2)) {
1061
- peg$currPos++;
1062
- } else {
1063
- s2 = peg$FAILED;
1064
- if (peg$silentFails === 0) { peg$fail(peg$e18); }
1065
- }
1066
- if (s2 !== peg$FAILED) {
1067
- while (s2 !== peg$FAILED) {
1068
- s1.push(s2);
1069
- s2 = input.charAt(peg$currPos);
1070
- if (peg$r4.test(s2)) {
1071
- peg$currPos++;
1072
- } else {
1073
- s2 = peg$FAILED;
1074
- if (peg$silentFails === 0) { peg$fail(peg$e18); }
1075
- }
1002
+ for (;;) {
1003
+ s2 = input.charAt(peg$currPos);
1004
+ if (s2 !== "" && !(peg$charCode = s2.charCodeAt(0), peg$charCode === 32 || peg$charCode === 35 || peg$charCode === 58 || peg$charCode === 39 || peg$charCode === 34 || peg$charCode === 9 || peg$charCode === 13 || peg$charCode === 10)) {
1005
+ peg$currPos++;
1006
+ } else {
1007
+ s2 = peg$FAILED;
1008
+ if (peg$silentFails === 0) { peg$fail(peg$e18); }
1076
1009
  }
1077
- } else {
1010
+ if (s2 === peg$FAILED) { break; }
1011
+ s1.push(s2);
1012
+ }
1013
+ if (s1.length < 1) {
1078
1014
  s1 = peg$FAILED;
1079
1015
  }
1080
1016
  if (s1 !== peg$FAILED) {
@@ -1239,22 +1175,16 @@ function peg$parse(input, options) {
1239
1175
  }
1240
1176
  if (s3 !== peg$FAILED) {
1241
1177
  s4 = [];
1242
- s5 = input.charAt(peg$currPos);
1243
- if (peg$r5.test(s5)) {
1244
- peg$currPos++;
1245
- } else {
1246
- s5 = peg$FAILED;
1247
- if (peg$silentFails === 0) { peg$fail(peg$e28); }
1248
- }
1249
- while (s5 !== peg$FAILED) {
1250
- s4.push(s5);
1178
+ for (;;) {
1251
1179
  s5 = input.charAt(peg$currPos);
1252
- if (peg$r5.test(s5)) {
1180
+ if (s5 !== "" && !(peg$charCode = s5.charCodeAt(0), peg$charCode === 13 || peg$charCode === 10)) {
1253
1181
  peg$currPos++;
1254
1182
  } else {
1255
1183
  s5 = peg$FAILED;
1256
1184
  if (peg$silentFails === 0) { peg$fail(peg$e28); }
1257
1185
  }
1186
+ if (s5 === peg$FAILED) { break; }
1187
+ s4.push(s5);
1258
1188
  }
1259
1189
  peg$savedPos = s0;
1260
1190
  s0 = peg$f20();
@@ -1276,22 +1206,16 @@ function peg$parse(input, options) {
1276
1206
  peg$silentFails++;
1277
1207
  s0 = peg$currPos;
1278
1208
  s1 = [];
1279
- s2 = input.charAt(peg$currPos);
1280
- if (peg$r6.test(s2)) {
1281
- peg$currPos++;
1282
- } else {
1283
- s2 = peg$FAILED;
1284
- if (peg$silentFails === 0) { peg$fail(peg$e29); }
1285
- }
1286
- while (s2 !== peg$FAILED) {
1287
- s1.push(s2);
1209
+ for (;;) {
1288
1210
  s2 = input.charAt(peg$currPos);
1289
- if (peg$r6.test(s2)) {
1211
+ if ((peg$charCode = s2.charCodeAt(0), peg$charCode === 32 || peg$charCode === 9)) {
1290
1212
  peg$currPos++;
1291
1213
  } else {
1292
1214
  s2 = peg$FAILED;
1293
1215
  if (peg$silentFails === 0) { peg$fail(peg$e29); }
1294
1216
  }
1217
+ if (s2 === peg$FAILED) { break; }
1218
+ s1.push(s2);
1295
1219
  }
1296
1220
  peg$savedPos = s0;
1297
1221
  s1 = peg$f21();
@@ -1307,22 +1231,16 @@ function peg$parse(input, options) {
1307
1231
  peg$silentFails++;
1308
1232
  s0 = peg$currPos;
1309
1233
  s1 = [];
1310
- s2 = input.charAt(peg$currPos);
1311
- if (peg$r7.test(s2)) {
1312
- peg$currPos++;
1313
- } else {
1314
- s2 = peg$FAILED;
1315
- if (peg$silentFails === 0) { peg$fail(peg$e30); }
1316
- }
1317
- while (s2 !== peg$FAILED) {
1318
- s1.push(s2);
1234
+ for (;;) {
1319
1235
  s2 = input.charAt(peg$currPos);
1320
- if (peg$r7.test(s2)) {
1236
+ if ((peg$charCode = s2.charCodeAt(0), peg$charCode === 32 || peg$charCode === 9 || peg$charCode === 13 || peg$charCode === 10)) {
1321
1237
  peg$currPos++;
1322
1238
  } else {
1323
1239
  s2 = peg$FAILED;
1324
1240
  if (peg$silentFails === 0) { peg$fail(peg$e30); }
1325
1241
  }
1242
+ if (s2 === peg$FAILED) { break; }
1243
+ s1.push(s2);
1326
1244
  }
1327
1245
  peg$savedPos = s0;
1328
1246
  s1 = peg$f22();
@@ -1338,25 +1256,18 @@ function peg$parse(input, options) {
1338
1256
  peg$silentFails++;
1339
1257
  s0 = peg$currPos;
1340
1258
  s1 = [];
1341
- s2 = input.charAt(peg$currPos);
1342
- if (peg$r6.test(s2)) {
1343
- peg$currPos++;
1344
- } else {
1345
- s2 = peg$FAILED;
1346
- if (peg$silentFails === 0) { peg$fail(peg$e29); }
1347
- }
1348
- if (s2 !== peg$FAILED) {
1349
- while (s2 !== peg$FAILED) {
1350
- s1.push(s2);
1351
- s2 = input.charAt(peg$currPos);
1352
- if (peg$r6.test(s2)) {
1353
- peg$currPos++;
1354
- } else {
1355
- s2 = peg$FAILED;
1356
- if (peg$silentFails === 0) { peg$fail(peg$e29); }
1357
- }
1259
+ for (;;) {
1260
+ s2 = input.charAt(peg$currPos);
1261
+ if ((peg$charCode = s2.charCodeAt(0), peg$charCode === 32 || peg$charCode === 9)) {
1262
+ peg$currPos++;
1263
+ } else {
1264
+ s2 = peg$FAILED;
1265
+ if (peg$silentFails === 0) { peg$fail(peg$e29); }
1358
1266
  }
1359
- } else {
1267
+ if (s2 === peg$FAILED) { break; }
1268
+ s1.push(s2);
1269
+ }
1270
+ if (s1.length < 1) {
1360
1271
  s1 = peg$FAILED;
1361
1272
  }
1362
1273
  if (s1 !== peg$FAILED) {
package/version.js CHANGED
@@ -1,4 +1,4 @@
1
- // Generated by package-extract v3.1.3
1
+ // Generated by package-extract v4.0.2
2
2
  // Do not modify by hand.
3
3
 
4
- export const version = '3.0.3';
4
+ export const version = '4.0.0';
package/eslint.config.js DELETED
@@ -1,26 +0,0 @@
1
- import base from '@cto.af/eslint-config';
2
- import mocha from '@cto.af/eslint-config/mocha.js';
3
- import mod from '@cto.af/eslint-config/module.js';
4
-
5
- export default [
6
- {
7
- ignores: [
8
- 'docs/**',
9
- 'coverage/**',
10
- '**/*.peg.js',
11
- '**/*.d.ts',
12
- 'test/pkg_bad/package.json',
13
- ],
14
- },
15
- ...base,
16
- ...mod,
17
- ...mocha,
18
- {
19
- files: [
20
- 'test/**/*.js',
21
- ],
22
- rules: {
23
- 'n/no-top-level-await': 'off',
24
- },
25
- },
26
- ];
package/testFile.peggy DELETED
@@ -1,111 +0,0 @@
1
- {{
2
- import { mapObj } from './utils.js'
3
- }}
4
-
5
- {
6
- let vars = {};
7
- }
8
- start
9
- = all:(WS @line? _)|.., EOL| {
10
- return all.filter(t => t && t.hasOwnProperty('expected'));
11
- }
12
-
13
- line
14
- = var
15
- / comment
16
- / test
17
- / '' // hack
18
-
19
- var
20
- = '#!' env:"!"? _ name:chunk _ ':' _ value:(@val _)? {
21
- if (!value) {
22
- const start = location().start;
23
- value = {
24
- value: undefined,
25
- line: start.line,
26
- column: start.column,
27
- }
28
- }
29
- value.env = Boolean(env);
30
- vars = {
31
- ...vars,
32
- [name]: value
33
- }
34
- }
35
-
36
- val
37
- = value:chunk {
38
- const start = location().start;
39
- return { value, line: start.line, column: start.column}
40
- }
41
-
42
- test
43
- = expected:results inputs:(LWS @chunk)* comment? {
44
- const start = location().start;
45
- return { expected, inputs, vars, line: start.line, column: start.column }
46
- }
47
-
48
- results
49
- = "!" { return options.EXCEPTION || "!" }
50
- / chunk
51
-
52
- chunk
53
- = quoted
54
- / hex
55
- / word
56
-
57
- quoted
58
- = '"' info:dqchar* '"' { return info.join('') }
59
- / "'" info:sqchar* "'" { return info.join('') }
60
- / "`" info:bqchar* "`" { return info.join('') }
61
-
62
- dqchar "characters that go inside double quotes, including escaped dquotes"
63
- = '\\"' { return '"' }
64
- / qchar
65
- / $[^\\"]+
66
-
67
- sqchar "characters that go inside single quotes, including escaped squotes"
68
- = "\\'" { return "'" }
69
- / qchar
70
- / $[^\\']+
71
-
72
- bqchar "characters that go inside back quotes, including escaped bquotes"
73
- = "\\`" { return "`" }
74
- / qchar
75
- / $[^\\`]+
76
-
77
- hex
78
- = '0x' hx:$[a-fA-F0-9]+ { return '0x' + hx.toLowerCase(hx) }
79
-
80
- word
81
- = chars:wchar+ { return chars.join('') }
82
-
83
- wchar "words can contain quoted bits"
84
- = qchar+
85
- / $[^ #:'"\t\r\n]+
86
-
87
- qchar "other quoted characters, as needed"
88
- = '\\\\' { return '\\' }
89
- / '\\r' { return '\r' }
90
- / '\\n' { return '\n' }
91
- / '\\t' { return '\t' }
92
- / '\\#' { return '#' }
93
- / '\\:' { return ':' }
94
- / '\\ ' { return ' ' }
95
-
96
- comment
97
- = WS "#" !"!" [^\r\n]* { return undefined }
98
-
99
- _ "optional whitespace"
100
- = [ \t]* { return undefined }
101
-
102
- WS "optional whitespace, including newlines"
103
- = [ \t\r\n]* { return undefined}
104
-
105
- LWS "required whitespace"
106
- = [ \t]+ { return undefined }
107
-
108
- EOL "End of line"
109
- = '\n'
110
- / '\r\n'
111
- / '\r'