Commit graph

1117 commits

Author SHA1 Message Date
David Majda 8f8484b1a1 Don't use "arrays" in lib/compiler/passes/generate-js.js
The "arrays" module will be removed.

See #442.
2016-09-14 09:41:19 +02:00
David Majda 33f23ee4be Don't use "arrays" in lib/compiler/passes/generate-bytecode.js
The "arrays" module will be removed.

See #442.
2016-09-14 09:37:02 +02:00
David Majda 4dec5e52ba Don't use "arrays" in lib/compiler/asts.js
The "arrays" module will be removed.

See #442.
2016-09-14 09:33:31 +02:00
David Majda 5822596ab8 Replace classes.subclass with native classes
See #442.
2016-09-13 09:09:40 +02:00
David Majda 6fa8ad63f9 Replace some functions with arrow functions
Because arrow functions work rather differently than normal functions (a
bad design mistake if you ask me), I decided to be conservative with the
conversion.

I converted:

  * event handlers
  * callbacks
  * arguments to Array.prototype.map & co.
  * small standalone lambda functions

I didn't convert:

  * functions assigned to object literal properties (the new shorthand
    syntax would be better here)
  * functions passed to "describe", "it", etc. in specs (because Jasmine
    relies on dynamic "this")

See #442.
2016-09-12 16:07:43 +02:00
David Majda d00e9526c3 Minimize variable scope
Where possible, move "let" statements into inner blocks, loop headers,
etc.

See #442.
2016-09-09 12:42:20 +02:00
David Majda bdf91b5941 Replace "var" with "let" & "const"
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.
2016-09-09 10:44:00 +02:00
David Majda 5249814fc0 .eslintrc.json: Set parserOptions.ecmaVersion to 6
This means all code will be parsed as ES2015 by ESLint.

See #442.
2016-09-08 16:10:16 +02:00
David Majda 4a49e910ac package.json: Remove http-server
It is no longer used after introducing spec/server and benchmark/server.

See #442.
2016-09-08 14:54:18 +02:00
David Majda 959f20f6e2 Pass benchmark code through Babel before serving it to the browser
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.
2016-09-08 14:53:12 +02:00
David Majda 5c40fff136 Pass spec code through Babel before serving it to the browser
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.
2016-09-08 14:53:00 +02:00
David Majda d239bf0107 package.json: Add packages that will be needed soon
Add "express" and "morgan" packages, which will be needed by
soon-to-be-introduced spec server and benchmark server.

See #442.
2016-09-08 13:26:31 +02:00
David Majda 4e38617748 Pass the browser version through Babel
This will allow to use ES2015 constructs in PEG.js code.

See #442.
2016-09-07 18:08:27 +02:00
David Majda 16f38f6380 Drop Node 0.10.x & 0.12.x support
See #442.
2016-09-07 11:26:52 +02:00
David Majda 5ad1bc2add CSS example: Switch from first/rest to head/tail
Follow-up to e510ecc3d0.
2016-09-01 15:36:24 +02:00
David Majda f0657ba628 generated-parser-behavior.spec.js: Switch from first/rest to head/tail
Follow-up to these commits:

  e510ecc3d0
  a4a66a2e5b
2016-09-01 15:31:26 +02:00
David Majda 0d48ffca2b generated-parser-behavior.spec.js: s/==/===/ 2016-09-01 15:29:47 +02:00
David Majda c3e7072fa2 Remove unused arrays.pluck function 2016-09-01 15:25:23 +02:00
David Majda 062c6ae706 Escape backspace in regexp classes as "\b", not "\x08"
The "\x08" escaping is necessary only outside of classes (where "\b"
means "word boundary").
2016-09-01 15:20:33 +02:00
David Majda 1c71bf6cd7 spec/index.html: Add <!DOCTYPE html>
This ensures the specs are run in standards mode in Internet Explorer.
2016-09-01 15:09:57 +02:00
David Majda bd62ddf846 Use "[]" & "[^]" for empty character classes, not "(?!)" & "[\\S\\s]"
See #441.
2016-09-01 15:03:47 +02:00
David Majda 9c04c94c85 Escape vertical tab as "\v", not "\x0B"
See #441.
2016-09-01 15:03:47 +02:00
David Majda f36a667376 Remove "undefined" redefinition protection
See #441.
2016-09-01 14:12:16 +02:00
David Majda aa1a2e74cf Replace suitable for loops with Array methods (in /examples)
See #441.
2016-09-01 13:55:41 +02:00
David Majda 9fbb45a2c9 Replace suitable for loops with Array methods (in /benchmark)
See #441.
2016-09-01 13:25:53 +02:00
David Majda df5f86103e Replace suitable for loops with Array methods (in /spec)
See #441.
2016-09-01 13:03:51 +02:00
David Majda fad4ab74d1 Replace suitable for loops with Array methods (in /lib)
See #441.
2016-09-01 13:02:44 +02:00
David Majda 3e8bcbea73 Replace suitable for loops with Array methods (in /src)
See #441.
2016-09-01 12:55:26 +02:00
David Majda 1c3fbf6cb0 Replace "... instanceof Array" with "Array.isArray(...)"
See #441.
2016-08-30 16:37:05 +02:00
David Majda d346d2a66d Replace objects.keys with Object.keys
See #441.
2016-08-30 08:17:22 +02:00
David Majda 0059cc3bdd Replace arrays.some with Array.prototype.some
See #441.
2016-08-27 16:33:53 +02:00
David Majda d162fe1cfc Replace arrays.every with Array.prototype.every
See #441.
2016-08-27 16:33:47 +02:00
David Majda 5f65de92bc Replace arrays.map with Array.prototype.map
See #441.
2016-08-27 16:33:41 +02:00
David Majda b044a021c4 Replace arrays.each with Array.prototype.forEach
See #441.
2016-08-27 16:33:05 +02:00
David Majda 2a6a058c9c Merge pull request #440 from atavakoli/fix-js-example-logicalexpr
JavaScript example: Use LogicalExpression nodes for "&&" and "||"
2016-08-26 08:38:43 +02:00
Ali Tavakoli d914c7b150 JavaScript example: Use LogicalExpression nodes for "&&" and "||"
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).
2016-08-25 15:41:32 -04:00
David Majda bf08c6cbc3 JavaScript example: Declare built AST as compatible with ESTree
ESTree is now the canonical JavaScript AST format. Mozilla SpiderMonkey
Parser API, which we delared compatibility with before, is obsolete.
2016-08-24 11:01:23 +02:00
David Majda 567655e72f JavaScript example: Add "type" to ObjectExpression properties
Nodes representing ObjectExpression properties were missing the "type"
property (set to "Property") so let's add it.
2016-08-24 10:55:58 +02:00
David Majda 7fd273d893 Merge pull request #439 from atavakoli/fix-js-example-vardecl
Added 'kind' to VariableDeclaration in example
2016-08-24 10:49:22 +02:00
Ali Tavakoli 5f9bc6ed4d JavaScript example: Add "kind" to VariableDeclaration nodes
The JavaScript example grammar's VariableDeclaration nodes were missing
the "kind" member (which is always set to "var", according to the
ESTree spec).
2016-08-23 14:51:24 -04:00
David Majda 671166bbe8 Update version to 0.10.0 2016-08-19 09:13:44 +02:00
David Majda 86c040e05f Update CHANGELOG.md 2016-08-19 09:13:44 +02:00
David Majda 8003edafc9 Rename the "node" module format to "commonjs"
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.
2016-08-06 18:05:03 +02:00
David Majda 8962dcfd16 Rename the "global" module format to "globals"
I think the new name is more widely used when describing the pattern.
2016-08-06 17:59:32 +02:00
David Majda 0478f8a6cf package.json: Sort files alphabetically 2016-08-06 17:00:42 +02:00
David Majda b77d33ca05 generate-js.js: Quote the "class" key in DESCRIBE_EXPECTATION_FNS
"class" is a reserved word. Having it as a key unquoted broke IE 8 (both
in standards and quirks mode) and IE 9 (in quirks mode).
2016-08-05 14:46:32 +02:00
David Majda 2a8544d86c README.md: Remove io.js from the list of compatible environments 2016-08-05 11:39:02 +02:00
David Majda 5c0f0add95 Downgrade eslint to 2.13.1
It turns out ESLint 3.x works only with Node.js >= 4, which breaks Travis
CI builds:

  https://travis-ci.org/pegjs/pegjs/builds/149205616
2016-08-02 16:57:47 +02:00
David Majda f09271493c Use jQuery.scrollTo 2.1.2 2016-08-02 16:36:29 +02:00
David Majda 0753d8d4d5 Use jQuery 1.12.4 2016-08-02 16:32:17 +02:00