state-machine-cat 12.0.4 → 12.0.6

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016-2023 Sander Verweij
3
+ Copyright (c) 2016-2024 Sander Verweij
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -403,7 +403,12 @@ the tape player is on:
403
403
  ```
404
404
  initial,
405
405
  "tape player off",
406
- "tape player on" {
406
+ "tape player on":
407
+ entry/ LED on
408
+ exit/ LED off
409
+ {
410
+ stopped, playing, paused;
411
+
407
412
  stopped => playing : play;
408
413
  playing => stopped : stop;
409
414
  playing => paused : pause;
@@ -414,8 +419,13 @@ initial,
414
419
  initial => "tape player off";
415
420
  "tape player off" => stopped : power;
416
421
  "tape player on" => "tape player off" : power;
422
+
417
423
  ```
418
424
 
425
+ As you can see in this sample you can use activities (like entry and exit
426
+ triggers) in the composite state declaration, just as you'd do for state that
427
+ does not contain a state machine.
428
+
419
429
  <img width="653" alt="tape player rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/main/docs/pics/05tape_player.png">
420
430
 
421
431
  #### parallel states
@@ -630,7 +640,8 @@ The values you can use for the `type` of a state:
630
640
  #### grammar
631
641
 
632
642
  I made the parser with peggy - you can find it at
633
- [src/parse/peg/smcat-parser.peggy](src/parse/smcat/peg/smcat-parser.peggy)
643
+ [src/parse/peg/smcat-parser.peggy](src/parse/smcat/peg/smcat-parser.peggy), and
644
+ railroad diagrams generated from these on [state-machine-cat.js.org/grammar.html](https://state-machine-cat.js.org/grammar.html)
634
645
 
635
646
  ## Status
636
647
 
@@ -5,7 +5,7 @@ const LICENSE = `
5
5
 
6
6
  The MIT License (MIT)
7
7
 
8
- Copyright (c) 2016-2023 Sander Verweij
8
+ Copyright (c) 2016-2024 Sander Verweij
9
9
 
10
10
  Permission is hereby granted, free of charge, to any person obtaining
11
11
  a copy of this software and associated documentation files (the
@@ -149,15 +149,12 @@ function peg$parse(input, options) {
149
149
  var peg$c0 = "=";
150
150
  var peg$c1 = "\"";
151
151
  var peg$c2 = "\\\"";
152
- var peg$c3 = " ";
153
- var peg$c4 = "\t";
154
- var peg$c5 = "\n";
155
- var peg$c6 = "\r";
156
- var peg$c7 = "true";
157
- var peg$c8 = "false";
158
- var peg$c9 = ".";
159
- var peg$r0 = /^[0-9]/;
160
- var peg$r1 = /^[ \t\n\r]/;
152
+ var peg$c3 = "true";
153
+ var peg$c4 = "false";
154
+ var peg$c5 = ".";
155
+ var peg$r0 = /^[\t-\n\r =]/;
156
+ var peg$r1 = /^[0-9]/;
157
+ var peg$r2 = /^[ \t\n\r]/;
161
158
  var peg$e0 = peg$otherExpectation("name value pair");
162
159
  var peg$e1 = peg$literalExpectation("=", false);
163
160
  var peg$e2 = peg$otherExpectation("valid value");
@@ -166,19 +163,16 @@ function peg$parse(input, options) {
166
163
  var peg$e5 = peg$literalExpectation("\"", false);
167
164
  var peg$e6 = peg$literalExpectation("\\\"", false);
168
165
  var peg$e7 = peg$anyExpectation();
169
- var peg$e8 = peg$literalExpectation(" ", false);
170
- var peg$e9 = peg$literalExpectation("\t", false);
171
- var peg$e10 = peg$literalExpectation("\n", false);
172
- var peg$e11 = peg$literalExpectation("\r", false);
173
- var peg$e12 = peg$otherExpectation("boolean");
174
- var peg$e13 = peg$literalExpectation("true", false);
175
- var peg$e14 = peg$literalExpectation("false", false);
176
- var peg$e15 = peg$otherExpectation("integer");
177
- var peg$e16 = peg$classExpectation([["0", "9"]], false, false);
178
- var peg$e17 = peg$otherExpectation("number");
179
- var peg$e18 = peg$literalExpectation(".", false);
180
- var peg$e19 = peg$otherExpectation("whitespace");
181
- var peg$e20 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false);
166
+ var peg$e8 = peg$classExpectation([["\t", "\n"], "\r", " ", "="], false, false);
167
+ var peg$e9 = peg$otherExpectation("boolean");
168
+ var peg$e10 = peg$literalExpectation("true", false);
169
+ var peg$e11 = peg$literalExpectation("false", false);
170
+ var peg$e12 = peg$otherExpectation("integer");
171
+ var peg$e13 = peg$classExpectation([["0", "9"]], false, false);
172
+ var peg$e14 = peg$otherExpectation("number");
173
+ var peg$e15 = peg$literalExpectation(".", false);
174
+ var peg$e16 = peg$otherExpectation("whitespace");
175
+ var peg$e17 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false);
182
176
  var peg$f0 = function (name, value) { return { name, value }; };
183
177
  var peg$f1 = function (s) { return s.join(""); };
184
178
  var peg$f2 = function (c) { return c; };
@@ -187,14 +181,14 @@ function peg$parse(input, options) {
187
181
  var peg$f5 = function (bool) { return (bool === "true"); };
188
182
  var peg$f6 = function () { return parseInt(text(), 10); };
189
183
  var peg$f7 = function () { return parseFloat(text()); };
190
- var peg$currPos = 0;
191
- var peg$savedPos = 0;
184
+ var peg$currPos = options.peg$currPos | 0;
185
+ var peg$savedPos = peg$currPos;
192
186
  var peg$posDetailsCache = [{ line: 1, column: 1 }];
193
- var peg$maxFailPos = 0;
194
- var peg$maxFailExpected = [];
195
- var peg$silentFails = 0;
187
+ var peg$maxFailPos = peg$currPos;
188
+ var peg$maxFailExpected = options.peg$maxFailExpected || [];
189
+ var peg$silentFails = options.peg$silentFails | 0;
196
190
  var peg$result;
197
- if ("startRule" in options) {
191
+ if (options.startRule) {
198
192
  if (!(options.startRule in peg$startRuleFunctions)) {
199
193
  throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
200
194
  }
@@ -250,9 +244,12 @@ function peg$parse(input, options) {
250
244
  return details;
251
245
  }
252
246
  else {
253
- p = pos - 1;
254
- while (!peg$posDetailsCache[p]) {
255
- p--;
247
+ if (pos >= peg$posDetailsCache.length) {
248
+ p = peg$posDetailsCache.length - 1;
249
+ }
250
+ else {
251
+ p = pos;
252
+ while (!peg$posDetailsCache[--p]) { }
256
253
  }
257
254
  details = peg$posDetailsCache[p];
258
255
  details = {
@@ -608,8 +605,8 @@ function peg$parse(input, options) {
608
605
  s1 = peg$currPos;
609
606
  s2 = peg$currPos;
610
607
  peg$silentFails++;
611
- if (input.charCodeAt(peg$currPos) === 32) {
612
- s3 = peg$c3;
608
+ s3 = input.charAt(peg$currPos);
609
+ if (peg$r0.test(s3)) {
613
610
  peg$currPos++;
614
611
  }
615
612
  else {
@@ -618,54 +615,6 @@ function peg$parse(input, options) {
618
615
  peg$fail(peg$e8);
619
616
  }
620
617
  }
621
- if (s3 === peg$FAILED) {
622
- if (input.charCodeAt(peg$currPos) === 61) {
623
- s3 = peg$c0;
624
- peg$currPos++;
625
- }
626
- else {
627
- s3 = peg$FAILED;
628
- if (peg$silentFails === 0) {
629
- peg$fail(peg$e1);
630
- }
631
- }
632
- if (s3 === peg$FAILED) {
633
- if (input.charCodeAt(peg$currPos) === 9) {
634
- s3 = peg$c4;
635
- peg$currPos++;
636
- }
637
- else {
638
- s3 = peg$FAILED;
639
- if (peg$silentFails === 0) {
640
- peg$fail(peg$e9);
641
- }
642
- }
643
- if (s3 === peg$FAILED) {
644
- if (input.charCodeAt(peg$currPos) === 10) {
645
- s3 = peg$c5;
646
- peg$currPos++;
647
- }
648
- else {
649
- s3 = peg$FAILED;
650
- if (peg$silentFails === 0) {
651
- peg$fail(peg$e10);
652
- }
653
- }
654
- if (s3 === peg$FAILED) {
655
- if (input.charCodeAt(peg$currPos) === 13) {
656
- s3 = peg$c6;
657
- peg$currPos++;
658
- }
659
- else {
660
- s3 = peg$FAILED;
661
- if (peg$silentFails === 0) {
662
- peg$fail(peg$e11);
663
- }
664
- }
665
- }
666
- }
667
- }
668
- }
669
618
  peg$silentFails--;
670
619
  if (s3 === peg$FAILED) {
671
620
  s2 = undefined;
@@ -704,8 +653,8 @@ function peg$parse(input, options) {
704
653
  s1 = peg$currPos;
705
654
  s2 = peg$currPos;
706
655
  peg$silentFails++;
707
- if (input.charCodeAt(peg$currPos) === 32) {
708
- s3 = peg$c3;
656
+ s3 = input.charAt(peg$currPos);
657
+ if (peg$r0.test(s3)) {
709
658
  peg$currPos++;
710
659
  }
711
660
  else {
@@ -714,54 +663,6 @@ function peg$parse(input, options) {
714
663
  peg$fail(peg$e8);
715
664
  }
716
665
  }
717
- if (s3 === peg$FAILED) {
718
- if (input.charCodeAt(peg$currPos) === 61) {
719
- s3 = peg$c0;
720
- peg$currPos++;
721
- }
722
- else {
723
- s3 = peg$FAILED;
724
- if (peg$silentFails === 0) {
725
- peg$fail(peg$e1);
726
- }
727
- }
728
- if (s3 === peg$FAILED) {
729
- if (input.charCodeAt(peg$currPos) === 9) {
730
- s3 = peg$c4;
731
- peg$currPos++;
732
- }
733
- else {
734
- s3 = peg$FAILED;
735
- if (peg$silentFails === 0) {
736
- peg$fail(peg$e9);
737
- }
738
- }
739
- if (s3 === peg$FAILED) {
740
- if (input.charCodeAt(peg$currPos) === 10) {
741
- s3 = peg$c5;
742
- peg$currPos++;
743
- }
744
- else {
745
- s3 = peg$FAILED;
746
- if (peg$silentFails === 0) {
747
- peg$fail(peg$e10);
748
- }
749
- }
750
- if (s3 === peg$FAILED) {
751
- if (input.charCodeAt(peg$currPos) === 13) {
752
- s3 = peg$c6;
753
- peg$currPos++;
754
- }
755
- else {
756
- s3 = peg$FAILED;
757
- if (peg$silentFails === 0) {
758
- peg$fail(peg$e11);
759
- }
760
- }
761
- }
762
- }
763
- }
764
- }
765
666
  peg$silentFails--;
766
667
  if (s3 === peg$FAILED) {
767
668
  s2 = undefined;
@@ -805,25 +706,25 @@ function peg$parse(input, options) {
805
706
  var s0, s1;
806
707
  peg$silentFails++;
807
708
  s0 = peg$currPos;
808
- if (input.substr(peg$currPos, 4) === peg$c7) {
809
- s1 = peg$c7;
709
+ if (input.substr(peg$currPos, 4) === peg$c3) {
710
+ s1 = peg$c3;
810
711
  peg$currPos += 4;
811
712
  }
812
713
  else {
813
714
  s1 = peg$FAILED;
814
715
  if (peg$silentFails === 0) {
815
- peg$fail(peg$e13);
716
+ peg$fail(peg$e10);
816
717
  }
817
718
  }
818
719
  if (s1 === peg$FAILED) {
819
- if (input.substr(peg$currPos, 5) === peg$c8) {
820
- s1 = peg$c8;
720
+ if (input.substr(peg$currPos, 5) === peg$c4) {
721
+ s1 = peg$c4;
821
722
  peg$currPos += 5;
822
723
  }
823
724
  else {
824
725
  s1 = peg$FAILED;
825
726
  if (peg$silentFails === 0) {
826
- peg$fail(peg$e14);
727
+ peg$fail(peg$e11);
827
728
  }
828
729
  }
829
730
  }
@@ -836,7 +737,7 @@ function peg$parse(input, options) {
836
737
  if (s0 === peg$FAILED) {
837
738
  s1 = peg$FAILED;
838
739
  if (peg$silentFails === 0) {
839
- peg$fail(peg$e12);
740
+ peg$fail(peg$e9);
840
741
  }
841
742
  }
842
743
  return s0;
@@ -846,27 +747,27 @@ function peg$parse(input, options) {
846
747
  peg$silentFails++;
847
748
  s0 = peg$currPos;
848
749
  s1 = [];
849
- if (peg$r0.test(input.charAt(peg$currPos))) {
850
- s2 = input.charAt(peg$currPos);
750
+ s2 = input.charAt(peg$currPos);
751
+ if (peg$r1.test(s2)) {
851
752
  peg$currPos++;
852
753
  }
853
754
  else {
854
755
  s2 = peg$FAILED;
855
756
  if (peg$silentFails === 0) {
856
- peg$fail(peg$e16);
757
+ peg$fail(peg$e13);
857
758
  }
858
759
  }
859
760
  if (s2 !== peg$FAILED) {
860
761
  while (s2 !== peg$FAILED) {
861
762
  s1.push(s2);
862
- if (peg$r0.test(input.charAt(peg$currPos))) {
863
- s2 = input.charAt(peg$currPos);
763
+ s2 = input.charAt(peg$currPos);
764
+ if (peg$r1.test(s2)) {
864
765
  peg$currPos++;
865
766
  }
866
767
  else {
867
768
  s2 = peg$FAILED;
868
769
  if (peg$silentFails === 0) {
869
- peg$fail(peg$e16);
770
+ peg$fail(peg$e13);
870
771
  }
871
772
  }
872
773
  }
@@ -883,7 +784,7 @@ function peg$parse(input, options) {
883
784
  if (s0 === peg$FAILED) {
884
785
  s1 = peg$FAILED;
885
786
  if (peg$silentFails === 0) {
886
- peg$fail(peg$e15);
787
+ peg$fail(peg$e12);
887
788
  }
888
789
  }
889
790
  return s0;
@@ -896,13 +797,13 @@ function peg$parse(input, options) {
896
797
  if (s1 !== peg$FAILED) {
897
798
  s2 = peg$currPos;
898
799
  if (input.charCodeAt(peg$currPos) === 46) {
899
- s3 = peg$c9;
800
+ s3 = peg$c5;
900
801
  peg$currPos++;
901
802
  }
902
803
  else {
903
804
  s3 = peg$FAILED;
904
805
  if (peg$silentFails === 0) {
905
- peg$fail(peg$e18);
806
+ peg$fail(peg$e15);
906
807
  }
907
808
  }
908
809
  if (s3 !== peg$FAILED) {
@@ -934,7 +835,7 @@ function peg$parse(input, options) {
934
835
  if (s0 === peg$FAILED) {
935
836
  s1 = peg$FAILED;
936
837
  if (peg$silentFails === 0) {
937
- peg$fail(peg$e17);
838
+ peg$fail(peg$e14);
938
839
  }
939
840
  }
940
841
  return s0;
@@ -943,37 +844,46 @@ function peg$parse(input, options) {
943
844
  var s0, s1;
944
845
  peg$silentFails++;
945
846
  s0 = [];
946
- if (peg$r1.test(input.charAt(peg$currPos))) {
947
- s1 = input.charAt(peg$currPos);
847
+ s1 = input.charAt(peg$currPos);
848
+ if (peg$r2.test(s1)) {
948
849
  peg$currPos++;
949
850
  }
950
851
  else {
951
852
  s1 = peg$FAILED;
952
853
  if (peg$silentFails === 0) {
953
- peg$fail(peg$e20);
854
+ peg$fail(peg$e17);
954
855
  }
955
856
  }
956
857
  while (s1 !== peg$FAILED) {
957
858
  s0.push(s1);
958
- if (peg$r1.test(input.charAt(peg$currPos))) {
959
- s1 = input.charAt(peg$currPos);
859
+ s1 = input.charAt(peg$currPos);
860
+ if (peg$r2.test(s1)) {
960
861
  peg$currPos++;
961
862
  }
962
863
  else {
963
864
  s1 = peg$FAILED;
964
865
  if (peg$silentFails === 0) {
965
- peg$fail(peg$e20);
866
+ peg$fail(peg$e17);
966
867
  }
967
868
  }
968
869
  }
969
870
  peg$silentFails--;
970
871
  s1 = peg$FAILED;
971
872
  if (peg$silentFails === 0) {
972
- peg$fail(peg$e19);
873
+ peg$fail(peg$e16);
973
874
  }
974
875
  return s0;
975
876
  }
976
877
  peg$result = peg$startRuleFunction();
878
+ if (options.peg$library) {
879
+ return ({
880
+ peg$result,
881
+ peg$currPos,
882
+ peg$FAILED,
883
+ peg$maxFailExpected,
884
+ peg$maxFailPos
885
+ });
886
+ }
977
887
  if (peg$result !== peg$FAILED && peg$currPos === input.length) {
978
888
  return peg$result;
979
889
  }
@@ -986,4 +896,7 @@ function peg$parse(input, options) {
986
896
  : peg$computeLocation(peg$maxFailPos, peg$maxFailPos));
987
897
  }
988
898
  }
989
- export { peg$SyntaxError as SyntaxError, peg$parse as parse };
899
+ const peg$allowedStartRules = [
900
+ "properties"
901
+ ];
902
+ export { peg$allowedStartRules as StartRules, peg$SyntaxError as SyntaxError, peg$parse as parse };
@@ -196,10 +196,12 @@ function peg$parse(input, options) {
196
196
  var peg$c46 = "//";
197
197
  var peg$r0 = /^[0-9]/;
198
198
  var peg$r1 = /^[a-zA-Z0-9_\- ]/;
199
- var peg$r2 = /^[^;, "\t\n\r=\-><:{[]/;
200
- var peg$r3 = /^[ \t]/;
201
- var peg$r4 = /^[\r\n]/;
202
- var peg$r5 = /^[^\r\n]/;
199
+ var peg$r2 = /^[,;{]/;
200
+ var peg$r3 = /^[;{]/;
201
+ var peg$r4 = /^[^;, "\t\n\r=\-><:{[]/;
202
+ var peg$r5 = /^[ \t]/;
203
+ var peg$r6 = /^[\r\n]/;
204
+ var peg$r7 = /^[^\r\n]/;
203
205
  var peg$e0 = peg$otherExpectation("statemachine");
204
206
  var peg$e1 = peg$literalExpectation(",", false);
205
207
  var peg$e2 = peg$literalExpectation(";", false);
@@ -267,17 +269,19 @@ function peg$parse(input, options) {
267
269
  var peg$e64 = peg$anyExpectation();
268
270
  var peg$e65 = peg$otherExpectation("valid class string");
269
271
  var peg$e66 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"], "_", "-", " "], false, false);
270
- var peg$e67 = peg$otherExpectation("identifier");
271
- var peg$e68 = peg$classExpectation([";", ",", " ", "\"", "\t", "\n", "\r", "=", "-", ">", "<", ":", "{", "["], true, false);
272
- var peg$e69 = peg$otherExpectation("whitespace");
273
- var peg$e70 = peg$classExpectation([" ", "\t"], false, false);
274
- var peg$e71 = peg$otherExpectation("line end");
275
- var peg$e72 = peg$classExpectation(["\r", "\n"], false, false);
276
- var peg$e73 = peg$literalExpectation("/*", false);
277
- var peg$e74 = peg$literalExpectation("*/", false);
278
- var peg$e75 = peg$literalExpectation("//", false);
279
- var peg$e76 = peg$classExpectation(["\r", "\n"], true, false);
280
- var peg$e77 = peg$otherExpectation("comment");
272
+ var peg$e67 = peg$classExpectation([",", ";", "{"], false, false);
273
+ var peg$e68 = peg$classExpectation([";", "{"], false, false);
274
+ var peg$e69 = peg$otherExpectation("identifier");
275
+ var peg$e70 = peg$classExpectation([";", ",", " ", "\"", "\t", "\n", "\r", "=", "-", ">", "<", ":", "{", "["], true, false);
276
+ var peg$e71 = peg$otherExpectation("whitespace");
277
+ var peg$e72 = peg$classExpectation([" ", "\t"], false, false);
278
+ var peg$e73 = peg$otherExpectation("line end");
279
+ var peg$e74 = peg$classExpectation(["\r", "\n"], false, false);
280
+ var peg$e75 = peg$literalExpectation("/*", false);
281
+ var peg$e76 = peg$literalExpectation("*/", false);
282
+ var peg$e77 = peg$literalExpectation("//", false);
283
+ var peg$e78 = peg$classExpectation(["\r", "\n"], true, false);
284
+ var peg$e79 = peg$otherExpectation("comment");
281
285
  var peg$f0 = function (statemachine) {
282
286
  statemachine.states = parserHelpers.extractUndeclaredStates(statemachine);
283
287
  return parserHelpers.classifyForkJoins(statemachine);
@@ -389,14 +393,14 @@ function peg$parse(input, options) {
389
393
  var peg$f38 = function (c) { return c; };
390
394
  var peg$f39 = function (c) { return c; };
391
395
  var peg$f40 = function (chars) { return chars.join(""); };
392
- var peg$currPos = 0;
393
- var peg$savedPos = 0;
396
+ var peg$currPos = options.peg$currPos | 0;
397
+ var peg$savedPos = peg$currPos;
394
398
  var peg$posDetailsCache = [{ line: 1, column: 1 }];
395
- var peg$maxFailPos = 0;
396
- var peg$maxFailExpected = [];
397
- var peg$silentFails = 0;
399
+ var peg$maxFailPos = peg$currPos;
400
+ var peg$maxFailExpected = options.peg$maxFailExpected || [];
401
+ var peg$silentFails = options.peg$silentFails | 0;
398
402
  var peg$result;
399
- if ("startRule" in options) {
403
+ if (options.startRule) {
400
404
  if (!(options.startRule in peg$startRuleFunctions)) {
401
405
  throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
402
406
  }
@@ -452,9 +456,12 @@ function peg$parse(input, options) {
452
456
  return details;
453
457
  }
454
458
  else {
455
- p = pos - 1;
456
- while (!peg$posDetailsCache[p]) {
457
- p--;
459
+ if (pos >= peg$posDetailsCache.length) {
460
+ p = peg$posDetailsCache.length - 1;
461
+ }
462
+ else {
463
+ p = pos;
464
+ while (!peg$posDetailsCache[--p]) { }
458
465
  }
459
466
  details = peg$posDetailsCache[p];
460
467
  details = {
@@ -958,8 +965,8 @@ function peg$parse(input, options) {
958
965
  var s0, s1;
959
966
  peg$silentFails++;
960
967
  s0 = peg$currPos;
961
- if (input.substr(peg$currPos, 5).toLowerCase() === peg$c8) {
962
- s1 = input.substr(peg$currPos, 5);
968
+ s1 = input.substr(peg$currPos, 5);
969
+ if (s1.toLowerCase() === peg$c8) {
963
970
  peg$currPos += 5;
964
971
  }
965
972
  else {
@@ -969,8 +976,8 @@ function peg$parse(input, options) {
969
976
  }
970
977
  }
971
978
  if (s1 === peg$FAILED) {
972
- if (input.substr(peg$currPos, 5).toLowerCase() === peg$c9) {
973
- s1 = input.substr(peg$currPos, 5);
979
+ s1 = input.substr(peg$currPos, 5);
980
+ if (s1.toLowerCase() === peg$c9) {
974
981
  peg$currPos += 5;
975
982
  }
976
983
  else {
@@ -998,8 +1005,8 @@ function peg$parse(input, options) {
998
1005
  var s0, s1;
999
1006
  peg$silentFails++;
1000
1007
  s0 = peg$currPos;
1001
- if (input.substr(peg$currPos, 5).toLowerCase() === peg$c10) {
1002
- s1 = input.substr(peg$currPos, 5);
1008
+ s1 = input.substr(peg$currPos, 5);
1009
+ if (s1.toLowerCase() === peg$c10) {
1003
1010
  peg$currPos += 5;
1004
1011
  }
1005
1012
  else {
@@ -1026,8 +1033,8 @@ function peg$parse(input, options) {
1026
1033
  var s0, s1;
1027
1034
  peg$silentFails++;
1028
1035
  s0 = peg$currPos;
1029
- if (input.substr(peg$currPos, 6).toLowerCase() === peg$c11) {
1030
- s1 = input.substr(peg$currPos, 6);
1036
+ s1 = input.substr(peg$currPos, 6);
1037
+ if (s1.toLowerCase() === peg$c11) {
1031
1038
  peg$currPos += 6;
1032
1039
  }
1033
1040
  else {
@@ -1054,8 +1061,8 @@ function peg$parse(input, options) {
1054
1061
  var s0, s1;
1055
1062
  peg$silentFails++;
1056
1063
  s0 = peg$currPos;
1057
- if (input.substr(peg$currPos, 4).toLowerCase() === peg$c12) {
1058
- s1 = input.substr(peg$currPos, 4);
1064
+ s1 = input.substr(peg$currPos, 4);
1065
+ if (s1.toLowerCase() === peg$c12) {
1059
1066
  peg$currPos += 4;
1060
1067
  }
1061
1068
  else {
@@ -1595,8 +1602,8 @@ function peg$parse(input, options) {
1595
1602
  var s0, s1;
1596
1603
  peg$silentFails++;
1597
1604
  s0 = peg$currPos;
1598
- if (input.substr(peg$currPos, 5).toLowerCase() === peg$c9) {
1599
- s1 = input.substr(peg$currPos, 5);
1605
+ s1 = input.substr(peg$currPos, 5);
1606
+ if (s1.toLowerCase() === peg$c9) {
1600
1607
  peg$currPos += 5;
1601
1608
  }
1602
1609
  else {
@@ -1623,8 +1630,8 @@ function peg$parse(input, options) {
1623
1630
  var s0, s1;
1624
1631
  peg$silentFails++;
1625
1632
  s0 = peg$currPos;
1626
- if (input.substr(peg$currPos, 4).toLowerCase() === peg$c12) {
1627
- s1 = input.substr(peg$currPos, 4);
1633
+ s1 = input.substr(peg$currPos, 4);
1634
+ if (s1.toLowerCase() === peg$c12) {
1628
1635
  peg$currPos += 4;
1629
1636
  }
1630
1637
  else {
@@ -1651,8 +1658,8 @@ function peg$parse(input, options) {
1651
1658
  var s0, s1;
1652
1659
  peg$silentFails++;
1653
1660
  s0 = peg$currPos;
1654
- if (input.substr(peg$currPos, 5).toLowerCase() === peg$c25) {
1655
- s1 = input.substr(peg$currPos, 5);
1661
+ s1 = input.substr(peg$currPos, 5);
1662
+ if (s1.toLowerCase() === peg$c25) {
1656
1663
  peg$currPos += 5;
1657
1664
  }
1658
1665
  else {
@@ -1958,8 +1965,8 @@ function peg$parse(input, options) {
1958
1965
  var s0, s1, s2;
1959
1966
  s0 = peg$currPos;
1960
1967
  s1 = [];
1961
- if (peg$r0.test(input.charAt(peg$currPos))) {
1962
- s2 = input.charAt(peg$currPos);
1968
+ s2 = input.charAt(peg$currPos);
1969
+ if (peg$r0.test(s2)) {
1963
1970
  peg$currPos++;
1964
1971
  }
1965
1972
  else {
@@ -1971,8 +1978,8 @@ function peg$parse(input, options) {
1971
1978
  if (s2 !== peg$FAILED) {
1972
1979
  while (s2 !== peg$FAILED) {
1973
1980
  s1.push(s2);
1974
- if (peg$r0.test(input.charAt(peg$currPos))) {
1975
- s2 = input.charAt(peg$currPos);
1981
+ s2 = input.charAt(peg$currPos);
1982
+ if (peg$r0.test(s2)) {
1976
1983
  peg$currPos++;
1977
1984
  }
1978
1985
  else {
@@ -2252,8 +2259,8 @@ function peg$parse(input, options) {
2252
2259
  s2 = peg$FAILED;
2253
2260
  }
2254
2261
  if (s2 !== peg$FAILED) {
2255
- if (peg$r1.test(input.charAt(peg$currPos))) {
2256
- s3 = input.charAt(peg$currPos);
2262
+ s3 = input.charAt(peg$currPos);
2263
+ if (peg$r1.test(s3)) {
2257
2264
  peg$currPos++;
2258
2265
  }
2259
2266
  else {
@@ -2299,8 +2306,8 @@ function peg$parse(input, options) {
2299
2306
  s2 = peg$FAILED;
2300
2307
  }
2301
2308
  if (s2 !== peg$FAILED) {
2302
- if (peg$r1.test(input.charAt(peg$currPos))) {
2303
- s3 = input.charAt(peg$currPos);
2309
+ s3 = input.charAt(peg$currPos);
2310
+ if (peg$r1.test(s3)) {
2304
2311
  peg$currPos++;
2305
2312
  }
2306
2313
  else {
@@ -2349,38 +2356,14 @@ function peg$parse(input, options) {
2349
2356
  s1 = peg$currPos;
2350
2357
  s2 = peg$currPos;
2351
2358
  peg$silentFails++;
2352
- if (input.charCodeAt(peg$currPos) === 44) {
2353
- s3 = peg$c0;
2359
+ s3 = input.charAt(peg$currPos);
2360
+ if (peg$r2.test(s3)) {
2354
2361
  peg$currPos++;
2355
2362
  }
2356
2363
  else {
2357
2364
  s3 = peg$FAILED;
2358
2365
  if (peg$silentFails === 0) {
2359
- peg$fail(peg$e1);
2360
- }
2361
- }
2362
- if (s3 === peg$FAILED) {
2363
- if (input.charCodeAt(peg$currPos) === 59) {
2364
- s3 = peg$c1;
2365
- peg$currPos++;
2366
- }
2367
- else {
2368
- s3 = peg$FAILED;
2369
- if (peg$silentFails === 0) {
2370
- peg$fail(peg$e2);
2371
- }
2372
- }
2373
- if (s3 === peg$FAILED) {
2374
- if (input.charCodeAt(peg$currPos) === 123) {
2375
- s3 = peg$c5;
2376
- peg$currPos++;
2377
- }
2378
- else {
2379
- s3 = peg$FAILED;
2380
- if (peg$silentFails === 0) {
2381
- peg$fail(peg$e7);
2382
- }
2383
- }
2366
+ peg$fail(peg$e67);
2384
2367
  }
2385
2368
  }
2386
2369
  peg$silentFails--;
@@ -2420,38 +2403,14 @@ function peg$parse(input, options) {
2420
2403
  s1 = peg$currPos;
2421
2404
  s2 = peg$currPos;
2422
2405
  peg$silentFails++;
2423
- if (input.charCodeAt(peg$currPos) === 44) {
2424
- s3 = peg$c0;
2406
+ s3 = input.charAt(peg$currPos);
2407
+ if (peg$r2.test(s3)) {
2425
2408
  peg$currPos++;
2426
2409
  }
2427
2410
  else {
2428
2411
  s3 = peg$FAILED;
2429
2412
  if (peg$silentFails === 0) {
2430
- peg$fail(peg$e1);
2431
- }
2432
- }
2433
- if (s3 === peg$FAILED) {
2434
- if (input.charCodeAt(peg$currPos) === 59) {
2435
- s3 = peg$c1;
2436
- peg$currPos++;
2437
- }
2438
- else {
2439
- s3 = peg$FAILED;
2440
- if (peg$silentFails === 0) {
2441
- peg$fail(peg$e2);
2442
- }
2443
- }
2444
- if (s3 === peg$FAILED) {
2445
- if (input.charCodeAt(peg$currPos) === 123) {
2446
- s3 = peg$c5;
2447
- peg$currPos++;
2448
- }
2449
- else {
2450
- s3 = peg$FAILED;
2451
- if (peg$silentFails === 0) {
2452
- peg$fail(peg$e7);
2453
- }
2454
- }
2413
+ peg$fail(peg$e67);
2455
2414
  }
2456
2415
  }
2457
2416
  peg$silentFails--;
@@ -2495,26 +2454,14 @@ function peg$parse(input, options) {
2495
2454
  s1 = peg$currPos;
2496
2455
  s2 = peg$currPos;
2497
2456
  peg$silentFails++;
2498
- if (input.charCodeAt(peg$currPos) === 59) {
2499
- s3 = peg$c1;
2457
+ s3 = input.charAt(peg$currPos);
2458
+ if (peg$r3.test(s3)) {
2500
2459
  peg$currPos++;
2501
2460
  }
2502
2461
  else {
2503
2462
  s3 = peg$FAILED;
2504
2463
  if (peg$silentFails === 0) {
2505
- peg$fail(peg$e2);
2506
- }
2507
- }
2508
- if (s3 === peg$FAILED) {
2509
- if (input.charCodeAt(peg$currPos) === 123) {
2510
- s3 = peg$c5;
2511
- peg$currPos++;
2512
- }
2513
- else {
2514
- s3 = peg$FAILED;
2515
- if (peg$silentFails === 0) {
2516
- peg$fail(peg$e7);
2517
- }
2464
+ peg$fail(peg$e68);
2518
2465
  }
2519
2466
  }
2520
2467
  peg$silentFails--;
@@ -2554,26 +2501,14 @@ function peg$parse(input, options) {
2554
2501
  s1 = peg$currPos;
2555
2502
  s2 = peg$currPos;
2556
2503
  peg$silentFails++;
2557
- if (input.charCodeAt(peg$currPos) === 59) {
2558
- s3 = peg$c1;
2504
+ s3 = input.charAt(peg$currPos);
2505
+ if (peg$r3.test(s3)) {
2559
2506
  peg$currPos++;
2560
2507
  }
2561
2508
  else {
2562
2509
  s3 = peg$FAILED;
2563
2510
  if (peg$silentFails === 0) {
2564
- peg$fail(peg$e2);
2565
- }
2566
- }
2567
- if (s3 === peg$FAILED) {
2568
- if (input.charCodeAt(peg$currPos) === 123) {
2569
- s3 = peg$c5;
2570
- peg$currPos++;
2571
- }
2572
- else {
2573
- s3 = peg$FAILED;
2574
- if (peg$silentFails === 0) {
2575
- peg$fail(peg$e7);
2576
- }
2511
+ peg$fail(peg$e68);
2577
2512
  }
2578
2513
  }
2579
2514
  peg$silentFails--;
@@ -2616,27 +2551,27 @@ function peg$parse(input, options) {
2616
2551
  peg$silentFails++;
2617
2552
  s0 = peg$currPos;
2618
2553
  s1 = [];
2619
- if (peg$r2.test(input.charAt(peg$currPos))) {
2620
- s2 = input.charAt(peg$currPos);
2554
+ s2 = input.charAt(peg$currPos);
2555
+ if (peg$r4.test(s2)) {
2621
2556
  peg$currPos++;
2622
2557
  }
2623
2558
  else {
2624
2559
  s2 = peg$FAILED;
2625
2560
  if (peg$silentFails === 0) {
2626
- peg$fail(peg$e68);
2561
+ peg$fail(peg$e70);
2627
2562
  }
2628
2563
  }
2629
2564
  if (s2 !== peg$FAILED) {
2630
2565
  while (s2 !== peg$FAILED) {
2631
2566
  s1.push(s2);
2632
- if (peg$r2.test(input.charAt(peg$currPos))) {
2633
- s2 = input.charAt(peg$currPos);
2567
+ s2 = input.charAt(peg$currPos);
2568
+ if (peg$r4.test(s2)) {
2634
2569
  peg$currPos++;
2635
2570
  }
2636
2571
  else {
2637
2572
  s2 = peg$FAILED;
2638
2573
  if (peg$silentFails === 0) {
2639
- peg$fail(peg$e68);
2574
+ peg$fail(peg$e70);
2640
2575
  }
2641
2576
  }
2642
2577
  }
@@ -2656,7 +2591,7 @@ function peg$parse(input, options) {
2656
2591
  if (s0 === peg$FAILED) {
2657
2592
  s1 = peg$FAILED;
2658
2593
  if (peg$silentFails === 0) {
2659
- peg$fail(peg$e67);
2594
+ peg$fail(peg$e69);
2660
2595
  }
2661
2596
  }
2662
2597
  return s0;
@@ -2664,21 +2599,21 @@ function peg$parse(input, options) {
2664
2599
  function peg$parsewhitespace() {
2665
2600
  var s0, s1;
2666
2601
  peg$silentFails++;
2667
- if (peg$r3.test(input.charAt(peg$currPos))) {
2668
- s0 = input.charAt(peg$currPos);
2602
+ s0 = input.charAt(peg$currPos);
2603
+ if (peg$r5.test(s0)) {
2669
2604
  peg$currPos++;
2670
2605
  }
2671
2606
  else {
2672
2607
  s0 = peg$FAILED;
2673
2608
  if (peg$silentFails === 0) {
2674
- peg$fail(peg$e70);
2609
+ peg$fail(peg$e72);
2675
2610
  }
2676
2611
  }
2677
2612
  peg$silentFails--;
2678
2613
  if (s0 === peg$FAILED) {
2679
2614
  s1 = peg$FAILED;
2680
2615
  if (peg$silentFails === 0) {
2681
- peg$fail(peg$e69);
2616
+ peg$fail(peg$e71);
2682
2617
  }
2683
2618
  }
2684
2619
  return s0;
@@ -2686,21 +2621,21 @@ function peg$parse(input, options) {
2686
2621
  function peg$parselineend() {
2687
2622
  var s0, s1;
2688
2623
  peg$silentFails++;
2689
- if (peg$r4.test(input.charAt(peg$currPos))) {
2690
- s0 = input.charAt(peg$currPos);
2624
+ s0 = input.charAt(peg$currPos);
2625
+ if (peg$r6.test(s0)) {
2691
2626
  peg$currPos++;
2692
2627
  }
2693
2628
  else {
2694
2629
  s0 = peg$FAILED;
2695
2630
  if (peg$silentFails === 0) {
2696
- peg$fail(peg$e72);
2631
+ peg$fail(peg$e74);
2697
2632
  }
2698
2633
  }
2699
2634
  peg$silentFails--;
2700
2635
  if (s0 === peg$FAILED) {
2701
2636
  s1 = peg$FAILED;
2702
2637
  if (peg$silentFails === 0) {
2703
- peg$fail(peg$e71);
2638
+ peg$fail(peg$e73);
2704
2639
  }
2705
2640
  }
2706
2641
  return s0;
@@ -2714,7 +2649,7 @@ function peg$parse(input, options) {
2714
2649
  else {
2715
2650
  s0 = peg$FAILED;
2716
2651
  if (peg$silentFails === 0) {
2717
- peg$fail(peg$e73);
2652
+ peg$fail(peg$e75);
2718
2653
  }
2719
2654
  }
2720
2655
  return s0;
@@ -2728,7 +2663,7 @@ function peg$parse(input, options) {
2728
2663
  else {
2729
2664
  s0 = peg$FAILED;
2730
2665
  if (peg$silentFails === 0) {
2731
- peg$fail(peg$e74);
2666
+ peg$fail(peg$e76);
2732
2667
  }
2733
2668
  }
2734
2669
  return s0;
@@ -2745,7 +2680,7 @@ function peg$parse(input, options) {
2745
2680
  else {
2746
2681
  s2 = peg$FAILED;
2747
2682
  if (peg$silentFails === 0) {
2748
- peg$fail(peg$e74);
2683
+ peg$fail(peg$e76);
2749
2684
  }
2750
2685
  }
2751
2686
  peg$silentFails--;
@@ -2818,21 +2753,21 @@ function peg$parse(input, options) {
2818
2753
  else {
2819
2754
  s0 = peg$FAILED;
2820
2755
  if (peg$silentFails === 0) {
2821
- peg$fail(peg$e75);
2756
+ peg$fail(peg$e77);
2822
2757
  }
2823
2758
  }
2824
2759
  return s0;
2825
2760
  }
2826
2761
  function peg$parseslcomtok() {
2827
2762
  var s0;
2828
- if (peg$r5.test(input.charAt(peg$currPos))) {
2829
- s0 = input.charAt(peg$currPos);
2763
+ s0 = input.charAt(peg$currPos);
2764
+ if (peg$r7.test(s0)) {
2830
2765
  peg$currPos++;
2831
2766
  }
2832
2767
  else {
2833
2768
  s0 = peg$FAILED;
2834
2769
  if (peg$silentFails === 0) {
2835
- peg$fail(peg$e76);
2770
+ peg$fail(peg$e78);
2836
2771
  }
2837
2772
  }
2838
2773
  return s0;
@@ -2868,7 +2803,7 @@ function peg$parse(input, options) {
2868
2803
  if (s0 === peg$FAILED) {
2869
2804
  s1 = peg$FAILED;
2870
2805
  if (peg$silentFails === 0) {
2871
- peg$fail(peg$e77);
2806
+ peg$fail(peg$e79);
2872
2807
  }
2873
2808
  }
2874
2809
  return s0;
@@ -2896,6 +2831,15 @@ function peg$parse(input, options) {
2896
2831
  return s0;
2897
2832
  }
2898
2833
  peg$result = peg$startRuleFunction();
2834
+ if (options.peg$library) {
2835
+ return ({
2836
+ peg$result,
2837
+ peg$currPos,
2838
+ peg$FAILED,
2839
+ peg$maxFailExpected,
2840
+ peg$maxFailPos
2841
+ });
2842
+ }
2899
2843
  if (peg$result !== peg$FAILED && peg$currPos === input.length) {
2900
2844
  return peg$result;
2901
2845
  }
@@ -2908,4 +2852,7 @@ function peg$parse(input, options) {
2908
2852
  : peg$computeLocation(peg$maxFailPos, peg$maxFailPos));
2909
2853
  }
2910
2854
  }
2911
- export { peg$SyntaxError as SyntaxError, peg$parse as parse };
2855
+ const peg$allowedStartRules = [
2856
+ "program"
2857
+ ];
2858
+ export { peg$allowedStartRules as StartRules, peg$SyntaxError as SyntaxError, peg$parse as parse };
package/dist/version.mjs CHANGED
@@ -1 +1 @@
1
- export const version = "12.0.4";
1
+ export const version = "12.0.6";
package/package.json CHANGED
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "name": "state-machine-cat",
3
- "version": "12.0.4",
3
+ "version": "12.0.6",
4
4
  "description": "write beautiful state charts",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.mjs",
7
7
  "exports": {
8
8
  ".": [
9
9
  {
10
+ "types": "./types/state-machine-cat.d.mts",
10
11
  "import": "./dist/index.mjs"
11
12
  }
12
13
  ]
13
14
  },
15
+ "types": "types/state-machine-cat.d.mts",
14
16
  "imports": {
15
17
  "#*": "./src/*"
16
18
  },
@@ -48,19 +50,18 @@
48
50
  "state-machine-cat": "bin/smcat.mjs"
49
51
  },
50
52
  "dependencies": {
51
- "@hpcc-js/wasm": "2.15.3",
53
+ "@hpcc-js/wasm": "2.16.0",
52
54
  "ajv": "8.12.0",
53
- "commander": "11.1.0",
54
- "fast-xml-parser": "4.3.2",
55
+ "commander": "12.0.0",
56
+ "fast-xml-parser": "4.3.5",
55
57
  "handlebars": "4.7.8",
56
58
  "he": "1.2.0",
57
- "semver": "^7.5.4",
59
+ "semver": "^7.6.0",
58
60
  "traverse": "0.6.8"
59
61
  },
60
62
  "engines": {
61
63
  "node": "^18.17||>=20"
62
64
  },
63
- "types": "types/state-machine-cat.d.ts",
64
65
  "homepage": "https://state-machine-cat.js.org",
65
66
  "repository": {
66
67
  "type": "git",
@@ -68,5 +69,8 @@
68
69
  },
69
70
  "bugs": {
70
71
  "url": "https://github.com/sverweij/state-machine-cat/issues"
72
+ },
73
+ "scripts": {
74
+ "test": "echo for test, build and static analysis scripts: see the github repository"
71
75
  }
72
- }
76
+ }