Commit graph

1210 commits

Author SHA1 Message Date
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 fb26d6425b Remove extra newlines 2016-10-05 10:07:38 +02:00
David Majda 45b62d66d2 Whitespace fixes 2016-10-05 10:07:32 +02:00
David Majda 47bc456dcd Remove useless variable reference 2016-10-05 10:07:25 +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 b5eb1a0ec4 Use eslint 3.6.1 2016-09-30 14:30:54 +02:00
David Majda ca5ac6bd5f LICENSE: Use more standard format
The LICENSE file used weird word wrapping and it didn't explicitly name
the license. I'm not sure where I originally copied it from.

I decided to replace it with more standard form from here:

  http://choosealicense.com/licenses/mit/

The content of the license stays exactly the same.
2016-09-29 11:50:54 +02:00
David Majda c0efd83394 benchmark/README.md: Fix command to execute the benchmark suite 2016-09-29 11:36:18 +02:00
David Majda e29d62558d Do not prepend the "eslint-env" directive to lib/parser.js
The lib/parser.js file is a CommonJS module like all the other files in
lib/, so setting the environment explicitly is not needed. Besides, the
environment set by "eslint-env" was wrong (since transitioning from the
AMD format).
2016-09-29 11:24:51 +02:00
David Majda c721b9bf6e Omit PEG.js version from browser version file name
This makes upgrades easier for browser version users and it is in line
with most other JavaScript projects.
2016-09-29 11:14:22 +02:00
David Majda ff3cc7930e CSS Example: Move null filtering from extractList to buildList
This makes extractList identical to the same function in other grammars
and makes it so that nulls are dealt with in only one function (until
now, they were dealt with both in extractList and buildList).

The refactoring should be safe as extractList isn't by itself used in
contexts where it can be passed a list containing nulls.
2016-09-23 06:30:52 +02:00
David Majda 647d488147 JSON example: Fix link to RFC 4234. 2016-09-23 06:20:08 +02:00
David Majda 2baeace235 JSON example: Expand some one-line rules to multiple lines
Blocks of one-line rules with aligned "=" signs should be used only in
cases where the rules are symmetric and we want to emphasize that.

Follow-up to ff7193776e.
2016-09-23 06:16:23 +02:00
David Majda 1508e804a6 parser.spec.js: Remove extra spaces 2016-09-23 06:01:04 +02:00
David Majda 65ea01cd63 parser.spec.js: Fix comment typo 2016-09-23 06:00:27 +02:00
David Majda 9808b88ccb generated-parser-behavior.spec.js: Move variable inside loop 2016-09-23 05:56:52 +02:00
David Majda 6e463e2113 {spec,benchmark}/server: Use template literals 2016-09-22 19:20:50 +02:00
David Majda 70e59fc5d0 {spec,benchmark}/server: Remove extra trailing newline 2016-09-22 19:16:32 +02:00
David Majda 9648ca53d7 Use the "eslint-disable" directive instead of "eslint"
The "eslint-disable" directive is more specific.
2016-09-22 17:05:42 +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 c134e06229 Move "use strict" directives up
Move "use strict" directives to the first line of each file. In
particular, move them above any ESLint comments, which are far less
important.

There are few exceptions:

  Executable files

    In these, the "use strict" directive must give way to the shebang.

  lib/parser.js

    Here, the "Generated by..." comment comes first. Also, ESLint
    comments are prepended in post-processing.
2016-09-22 16:43:42 +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 381b5f4db7 Merge pull request #455 from Mingun/fix-testing 2016-09-14 21:31:47 +02:00
Mingun fcddfbebdd Add glob dev dependency used in spec and benchmark servers 2016-09-14 21:39:04 +05:00
Mingun 26ded450f4 Add "use strict" for spec and benchmark servers 2016-09-14 21:38:29 +05: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 b2a9dabcff Remove now unused lib/utils/objects.js
See #442.
2016-09-14 14:06:59 +02:00
David Majda 5fbb557f80 Don't use "objects" in lib/peg.js
The "objects" module will be removed.

See #442.
2016-09-14 14:04:28 +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 c344460855 Remove now unused lib/utils/arrays.js
See #442.
2016-09-14 10:06:36 +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 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