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/utils/arrays.js
CHANGED
|
@@ -31,78 +31,6 @@ var arrays = {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
|
-
|
|
35
|
-
indexOf: function(array, valueOrPredicate) {
|
|
36
|
-
var length = array.length, i;
|
|
37
|
-
|
|
38
|
-
if (typeof valueOrPredicate === "function") {
|
|
39
|
-
for (i = 0; i < length; i++) {
|
|
40
|
-
if (valueOrPredicate(array[i])) {
|
|
41
|
-
return i;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
} else {
|
|
45
|
-
for (i = 0; i < length; i++) {
|
|
46
|
-
if (array[i] === valueOrPredicate) {
|
|
47
|
-
return i;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return -1;
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
contains: function(array, valueOrPredicate) {
|
|
56
|
-
return arrays.indexOf(array, valueOrPredicate) !== -1;
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
each: function(array, iterator) {
|
|
60
|
-
var length = array.length, i;
|
|
61
|
-
|
|
62
|
-
for (i = 0; i < length; i++) {
|
|
63
|
-
iterator(array[i], i);
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
map: function(array, iterator) {
|
|
68
|
-
var length = array.length,
|
|
69
|
-
result = new Array(length),
|
|
70
|
-
i;
|
|
71
|
-
|
|
72
|
-
for (i = 0; i < length; i++) {
|
|
73
|
-
result[i] = iterator(array[i], i);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return result;
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
pluck: function(array, key) {
|
|
80
|
-
return arrays.map(array, function (e) { return e[key]; });
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
every: function(array, predicate) {
|
|
84
|
-
var length = array.length, i;
|
|
85
|
-
|
|
86
|
-
for (i = 0; i < length; i++) {
|
|
87
|
-
if (!predicate(array[i])) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return true;
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
some: function(array, predicate) {
|
|
96
|
-
var length = array.length, i;
|
|
97
|
-
|
|
98
|
-
for (i = 0; i < length; i++) {
|
|
99
|
-
if (predicate(array[i])) {
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
34
|
};
|
|
107
35
|
|
|
108
36
|
module.exports = arrays;
|