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.
- package/HISTORY.md +556 -0
- package/README.md +230 -12
- package/VERSION +1 -1
- package/bin/wikipeg +8 -4
- package/examples/css.pegphp +9 -8
- package/lib/compiler/asts.js +30 -10
- package/lib/compiler/charsets.js +306 -0
- package/lib/compiler/language/javascript.js +107 -33
- package/lib/compiler/language/php.js +193 -55
- package/lib/compiler/passes/analyze-always-match.js +141 -0
- package/lib/compiler/passes/analyze-first.js +245 -0
- package/lib/compiler/passes/ast-to-code.js +316 -100
- package/lib/compiler/passes/inline-simple-rules.js +96 -0
- package/lib/compiler/passes/optimize-character-class.js +147 -0
- package/lib/compiler/passes/optimize-failure-reporting.js +65 -0
- package/lib/compiler/passes/remove-proxy-rules.js +7 -5
- package/lib/compiler/passes/report-infinite-loops.js +4 -1
- package/lib/compiler/passes/report-left-recursion.js +3 -4
- package/lib/compiler/passes/report-unknown-attributes.js +39 -0
- package/lib/compiler/passes/transform-common-lang.js +1 -1
- package/lib/compiler/traverser.js +1 -2
- package/lib/compiler/visitor.js +5 -7
- package/lib/compiler.js +24 -10
- package/lib/parser.js +2784 -3088
- package/lib/peg.js +7 -15
- package/lib/runtime/template.js +9 -1
- package/lib/utils/CaseFolding.txt +1654 -0
- package/lib/utils/arrays.js +0 -72
- package/lib/utils/casefold.js +697 -0
- package/lib/utils/objects.js +9 -39
- package/lib/utils/unicode.js +34 -0
- package/package.json +6 -4
- package/src/DefaultTracer.php +18 -18
- package/src/PEGParserBase.php +53 -28
- package/src/SyntaxError.php +4 -4
- package/src/Tracer.php +1 -1
- package/lib/compiler/opcodes.js +0 -54
package/lib/peg.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
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: "
|
|
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
|
-
|
|
26
|
+
let converted = {};
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
49
|
+
plugins.forEach( (p) => { p.use(config, options); });
|
|
58
50
|
|
|
59
51
|
return this.compiler.compile(
|
|
60
52
|
config.parser.parse(grammar),
|
package/lib/runtime/template.js
CHANGED
|
@@ -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.
|
|
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;
|