wikipeg 4.0.2 → 6.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.
Files changed (37) hide show
  1. package/HISTORY.md +556 -0
  2. package/README.md +230 -12
  3. package/VERSION +1 -1
  4. package/bin/wikipeg +8 -4
  5. package/examples/css.pegphp +9 -8
  6. package/lib/compiler/asts.js +30 -10
  7. package/lib/compiler/charsets.js +306 -0
  8. package/lib/compiler/language/javascript.js +107 -33
  9. package/lib/compiler/language/php.js +193 -55
  10. package/lib/compiler/passes/analyze-always-match.js +141 -0
  11. package/lib/compiler/passes/analyze-first.js +245 -0
  12. package/lib/compiler/passes/ast-to-code.js +316 -100
  13. package/lib/compiler/passes/inline-simple-rules.js +96 -0
  14. package/lib/compiler/passes/optimize-character-class.js +147 -0
  15. package/lib/compiler/passes/optimize-failure-reporting.js +65 -0
  16. package/lib/compiler/passes/remove-proxy-rules.js +7 -5
  17. package/lib/compiler/passes/report-infinite-loops.js +4 -1
  18. package/lib/compiler/passes/report-left-recursion.js +3 -4
  19. package/lib/compiler/passes/report-unknown-attributes.js +39 -0
  20. package/lib/compiler/passes/transform-common-lang.js +1 -1
  21. package/lib/compiler/traverser.js +1 -2
  22. package/lib/compiler/visitor.js +5 -7
  23. package/lib/compiler.js +24 -10
  24. package/lib/parser.js +2784 -3088
  25. package/lib/peg.js +7 -15
  26. package/lib/runtime/template.js +9 -1
  27. package/lib/utils/CaseFolding.txt +1654 -0
  28. package/lib/utils/arrays.js +0 -72
  29. package/lib/utils/casefold.js +697 -0
  30. package/lib/utils/objects.js +9 -39
  31. package/lib/utils/unicode.js +34 -0
  32. package/package.json +6 -4
  33. package/src/DefaultTracer.php +18 -18
  34. package/src/PEGParserBase.php +53 -28
  35. package/src/SyntaxError.php +4 -4
  36. package/src/Tracer.php +1 -1
  37. package/lib/compiler/opcodes.js +0 -54
package/lib/peg.js CHANGED
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
 
3
- var arrays = require("./utils/arrays"),
4
- objects = require("./utils/objects");
3
+ var objects = require("./utils/objects");
5
4
 
6
5
  var PEG = {
7
6
  /* WikiPEG version (uses semantic versioning). */
8
- VERSION: "4.0.2",
7
+ VERSION: "6.0.0",
9
8
 
10
9
  GrammarError: require("./grammar-error"),
11
10
  parser: require("./parser"),
@@ -24,13 +23,11 @@ var PEG = {
24
23
  */
25
24
  buildParser: function(grammar) {
26
25
  function convertPasses(passes) {
27
- var converted = {}, stage;
26
+ let converted = {};
28
27
 
29
- for (stage in passes) {
30
- if (passes.hasOwnProperty(stage)) {
31
- converted[stage] = objects.values(passes[stage]);
32
- }
33
- }
28
+ Object.getOwnPropertyNames(passes).forEach((stage) => {
29
+ converted[stage] = Object.values(passes[stage]);
30
+ });
34
31
 
35
32
  return converted;
36
33
  }
@@ -43,18 +40,13 @@ var PEG = {
43
40
  generate: this.compiler.passes.generate
44
41
  };
45
42
 
46
- if (options.allowLoops) {
47
- defaultPasses.check = objects.clone(defaultPasses.check);
48
- delete defaultPasses.check.reportInfiniteLoops;
49
- }
50
-
51
43
  var plugins = "plugins" in options ? options.plugins : [],
52
44
  config = {
53
45
  parser: this.parser,
54
46
  passes: convertPasses(defaultPasses)
55
47
  };
56
48
 
57
- arrays.each(plugins, function(p) { p.use(config, options); });
49
+ plugins.forEach( (p) => { p.use(config, options); });
58
50
 
59
51
  return this.compiler.compile(
60
52
  config.parser.parse(grammar),
@@ -229,7 +229,15 @@ function peg$parse(input, options = {}) {
229
229
  var i = 1;
230
230
 
231
231
  expected.sort(function(a, b) {
232
- if (a.description < b.description) {
232
+ if (a.type < b.type) {
233
+ return -1;
234
+ } else if (a.type > b.type) {
235
+ return 1;
236
+ } else if (a.value < b.value) {
237
+ return -1;
238
+ } else if (a.value > b.value) {
239
+ return 1;
240
+ } else if (a.description < b.description) {
233
241
  return -1;
234
242
  } else if (a.description > b.description) {
235
243
  return 1;