This is purely a mechanical change, not taking advantage of block scope
of "let" and "const". Minimizing variable scope will come in the next
commit.
In general, "var" is converted into "let" and "const" is used only for
immutable variables of permanent character (generally spelled in
ALL_CAPS). Using it for any immutable variable regardless on its
permanence would feel confusing.
Any code which is not transpiled and needs to run in ES6 environment
(examples, code in grammars embedded in specs, ...) is kept unchanged.
This is also true for code generated by PEG.js.
See #442.
This will allow to use ES2015 constructs in benchmark code.
The change required introducing a small server, which serves both PEG.js
and benchmark code passed through Babel and bundled together. This
allowed to convert the benchmark to regular modules and to get rid of
the hackery that was previously needed to make it run both in Node.js
and in the browser.
Note the benchmark no longer exercises the browser version.
See #442.
This will allow to use ES2015 constructs in spec code.
The change required introducing a small server, which serves both PEG.js
and spec code passed through Babel and bundled together. This allowed to
convert the specs to regular modules and get rid of the hackery that was
previously needed to make them run both in Node.js and in the browser.
Note the specs no longer exercise the browser version. This will allow
to spec PEG.js internals in the future.
See #442.
The buildLogicalExpression function was defined, but not used;
specifically, the Logical(AND|OR)Expression(NoIn)? rules were
constructing BinaryExpression nodes, but are now LogicalExpression
nodes as per the ESTree spec (es5.md).
The JavaScript example grammar's VariableDeclaration nodes were missing
the "kind" member (which is always set to "var", according to the
ESTree spec).
Parsers generated in this format use module.exports, so they are not
strictly CommonJS, but this is a common extension and the original name
would be confusing once Node.js implements ES2015 modules.
Note the update required disabling the "no-control-regex" rule, which
started reporting following errors:
/Users/dmajda/Programming/PEG.js/pegjs/lib/compiler/js.js
22:16 error Unexpected control character in regular expression no-control-regex
27:16 error Unexpected control character in regular expression no-control-regex
28:16 error Unexpected control character in regular expression no-control-regex
51:16 error Unexpected control character in regular expression no-control-regex
52:16 error Unexpected control character in regular expression no-control-regex
/Users/dmajda/Programming/PEG.js/pegjs/lib/parser.js
76:16 error Unexpected control character in regular expression no-control-regex
77:16 error Unexpected control character in regular expression no-control-regex
90:16 error Unexpected control character in regular expression no-control-regex
91:16 error Unexpected control character in regular expression no-control-regex
Rename compiler passes as follows:
reportLeftRecursion -> reportInfiniteRecursion
reportInfiniteLoops -> reportInfiniteRepetition
This reflects the fact that both passes detect different ways of causing
the same problem (possible infinite loop when parsing).