Commit graph

207 commits

Author SHA1 Message Date
David Majda 266f17d11c Adapt to using HTTPS on PEG.js website
PEG.js website is now served exclusively using HTTPS. Change protocol in
all links to it to avoid redirects.
2016-12-04 11:24:33 +01:00
David Majda a733beb933 Remove unnecessary escaping of "]" in a regexp
This fixes the following ESLint error, which started to appear after
eslint/eslint#7424 was fixed:

  /Users/dmajda/Programming/PEG.js/pegjs/lib/compiler/js.js
    37:17  error  Unnecessary escape character: \]  no-useless-escape

This should fix broken Travis CI builds:

  https://travis-ci.org/pegjs/pegjs/builds/180092802
2016-12-01 16:30:10 +01:00
David Majda ef3abf33b9 Fix error when generating AMD/UMD dependencies
Generating AMD/UMD dependencies lead to an error:

  $ bin/pegjs --format amd --dependency $:jquery examples/arithmetics.pegjs
  dependencyIds is not defined

  $ bin/pegjs --format umd --dependency $:jquery examples/arithmetics.pegjs
  dependencyIds is not defined

This commit fixes the problem, which was caused by a mistake done in
d2569b9bf3.
2016-10-10 14:29:27 +02:00
David Majda 83d748d522 Code style: Make all static "require" calls global
The "global-require" rule is disabled in ESLint configuration used by
PEG.js, but the idea is not bad, so let's make all static "require"
calls global.

Follow-up to #407.
2016-10-10 13:38:39 +02:00
David Majda f4df9ddde1 Code style: Fix some ESLint errors in generated code
Running ESLint on generated code with the configuration used on PEG.js
itself produces a lot of errors. This commit fixes some unnecessary ones
caught by these rules:

  - max-len
  - new-cap
  - newline-before-return
  - no-unused-vars

See also 5dd8e797f7.

Follow-up to #407.
2016-10-10 13:32:33 +02:00
David Majda 80a9e03614 Code style: Fix ESLint "no-empty-function" errors
Part of #407.
2016-10-10 10:58:06 +02:00
David Majda fd07f64637 Code style: Fix ESLint "indent" errors
Part of #407.
2016-10-10 10:58:06 +02:00
David Majda e61ae59681 Code style: Fix ESLint "default-case" errors
Part of #407.
2016-10-10 10:58:06 +02:00
David Majda 364482dd68 Code style: Fix ESLint "no-prototype-builtins" errors
Part of #407.
2016-10-10 10:58:06 +02:00
David Majda 1870308afb Code style: Fix ESLint "object-shorthand" errors
Part of #407.
2016-10-10 10:58:05 +02:00
David Majda f82d9872ba Replace stray "var" by "let"
Likely missed in bdf91b5941.
2016-10-05 10:08:17 +02:00
David Majda 7495e6e03f Add missing semicolons 2016-10-05 10:08:04 +02:00
David Majda b81afb1471 Do not quote the "class" key
Quoting reserved words in property names is not needed since dropping
support of IE < 9.
2016-10-05 10:07:59 +02:00
David Majda ec3f7f5bb0 Remove extra indentation 2016-10-04 11:37:41 +02:00
David Majda 7ca229a432 Improve indentation of variable declarations
Before this commit, continuation lines of multi-line values in variable
declaration initializers were aligned with the variable name:

  let foo = {
        a: 5,
        b: 6
      };

This was highly irregular, maintenance intensive, and made declarations
look different from assignments.

This commit changes the indentation to be more regular and similar to
assignments:

  let foo = {
    a: 5,
    b: 6
  };
2016-10-04 11:30:52 +02:00
David Majda 60821bb80b Sort "require" calls by variable names and group them
This makes things consistent and reduces thinking about "require"
ordering.
2016-09-22 16:59:47 +02:00
David Majda ff7193776e Avoid aligning "="
The only exception left are instances where aligning "=" helps to
express symmetry between lines.

See #443.
2016-09-22 09:56:29 +02:00
David Majda 400a3cfa3c Avoid aligning object keys
The only exception left are objects representing a mapping with simple
keys and values -- essentially tables written as object literals.

See #443.
2016-09-22 07:55:30 +02:00
David Majda 12112310f2 Use only double quotes for strings
See #443
2016-09-21 15:06:56 +02:00
David Majda 6294bb5b13 Use only "//" comments
See #443.
2016-09-20 15:07:39 +02:00
David Majda 1da6abc458 Use one var/let/const per variable (fixup)
Fix few instances in generated code which I missed in the previous
commit.

See #443.
2016-09-20 14:47:10 +02:00
David Majda 516023546d Use one var/let/const per variable (for initialized variables)
Use one var/let/const per variable, but only for initialized variables.
Uninitialized variables are still grouped into one var/let/const
declaration as I don't see any value in separating them. This approach
reflects the fact that initialized and uninitialized var/let/const
declarations are really two different things.

See #443.
2016-09-17 15:09:07 +02:00
David Majda 7f01db2fb8 Get rid of for-in loops
The for-in statement in JavaScript iterates also over inherited
properties. This is typically not desired and requires adding a
check using Object.prototype.hasOwnProperty inside the loop.

This commit replaces all for-in statements and related checks inside
them with iteration over Object.keys(...). The iteration is performed
using either Array.prototype.forEach of a plain for loop.
2016-09-14 16:08:32 +02:00
David Majda 66ca7e2168 Don't use "objects" in lib/compiler/visitor.js
The "objects" module will be removed.

See #442.
2016-09-14 13:53:23 +02:00
David Majda 76e70c3923 Don't use "objects" in lib/compiler/passes/report-duplicate-labels.js
The "objects" module will be removed.

See #442.
2016-09-14 13:48:12 +02:00
David Majda d2569b9bf3 Don't use "objects" in lib/compiler/passes/generate-js.js
The "objects" module will be removed.

See #442.
2016-09-14 13:42:44 +02:00
David Majda 8a75d19468 Don't use "objects" in lib/compiler/passes/generate-bytecode.js
The "objects" module will be removed.

See #442.
2016-09-14 13:35:49 +02:00
David Majda 97d92c9d8b Don't use "objects" in lib/compiler/index.js
The "objects" module will be removed.

See #442.
2016-09-14 11:09:53 +02:00
David Majda f81ae1845b Don't use "arrays" in lib/compiler/passes/report-infinite-recursion.js
The "arrays" module will be removed.

See #442.
2016-09-14 10:03:59 +02:00
David Majda 71ef4c9b91 Don't use "arrays" in lib/compiler/passes/remove-proxy-rules.js
The "arrays" module will be removed.

See #442.
2016-09-14 10:01:47 +02:00
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 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 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 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 fad4ab74d1 Replace suitable for loops with Array methods (in /lib)
See #441.
2016-09-01 13:02:44 +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 671166bbe8 Update version to 0.10.0 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