80 Commits (a1ad351c2c745ecf60a3f0a75720348206971066)

Author SHA1 Message Date
Futago-za Ryuu d7d5f375f1 Removed redundant .eslintrc
See 55bcaa46ef
7 years ago
David Majda 9956b42392 Switch from Make to Gulp
The core of the transition is getting rid of Makefile and replacing it
with gulpfile.js. The rest is details (fixing dependencies, changing all
references to "make", etc.).

Target/task names mostly stay the same, so in most cases "gulp foo" does
what "make foo" did before. The only exceptions are "make browser" and
"make browserclean", which are now "gulp browser:build" and "gulp
browser:clean" (it feels more systematic).

Functionality is mostly unchanged (modulo Gulp clutter in the console),
but there are two small exceptions:

  gulp spec

    The reporter now displays just dots while previously it displayed
    spec descriptions. There is also a deprecation warning (most likely
    because I used an old version of gulp-jasmine in order to support
    Jasmine 1.x). I kept these issues unfixed because I plan to switch
    to Mocha soon (#409).

  gulp browser:build

    The copyright header is now added manually both to the development
    and minified build. Before, it was added only to the development
    build and the minified build relied on preserving it using "uglify
    --comments". This was broken since switching to //-style comments.

    There is now also an empty line between the header and the source
    code.

Fixes #444.
8 years ago
David Majda 7d6ad99e33 Code style: Remove unnecessary "eslint-disable" directives
Part of #407.
8 years ago
David Majda 8471b621a8 Code style: Fix ESLint "newline-before-return" errors
Part of #407.
8 years ago
David Majda 1870308afb Code style: Fix ESLint "object-shorthand" errors
Part of #407.
8 years ago
David Majda fb26d6425b Remove extra newlines 8 years ago
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
  };
8 years ago
David Majda c0efd83394 benchmark/README.md: Fix command to execute the benchmark suite 8 years ago
David Majda 6e463e2113 {spec,benchmark}/server: Use template literals 8 years ago
David Majda 70e59fc5d0 {spec,benchmark}/server: Remove extra trailing newline 8 years ago
David Majda 9648ca53d7 Use the "eslint-disable" directive instead of "eslint"
The "eslint-disable" directive is more specific.
8 years ago
David Majda 60821bb80b Sort "require" calls by variable names and group them
This makes things consistent and reduces thinking about "require"
ordering.
8 years ago
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.
8 years ago
David Majda ff7193776e Avoid aligning "="
The only exception left are instances where aligning "=" helps to
express symmetry between lines.

See #443.
8 years ago
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.
8 years ago
David Majda 6294bb5b13 Use only "//" comments
See #443.
8 years ago
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.
8 years ago
Mingun 26ded450f4 Add "use strict" for spec and benchmark servers 8 years ago
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.
8 years ago
David Majda d00e9526c3 Minimize variable scope
Where possible, move "let" statements into inner blocks, loop headers,
etc.

See #442.
8 years ago
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.
8 years ago
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.
8 years ago
David Majda 9fbb45a2c9 Replace suitable for loops with Array methods (in /benchmark)
See #441.
8 years ago
David Majda 671166bbe8 Update version to 0.10.0 8 years ago
David Majda f09271493c Use jQuery.scrollTo 2.1.2 8 years ago
David Majda 0753d8d4d5 Use jQuery 1.12.4 8 years ago
David Majda c50ad15461 Use http-server to serve specs and benchmarks to the browser
Previously, the instructions recommended using Python's SimpleHTTPServer
module, which created unnecessary dependency on Python.
8 years ago
David Majda 138405d89d Add syntax highlighting to code blocks in README.md files 8 years ago
David Majda f4504a93fe Rename the "buildParser" function to "generate"
In most places, we talk about "generating a parser", not "building a
parser", which the function name should reflect. Also, mentioning a
parser in the name is not necessary as in case of a parser generator
it's pretty clear what is generated.
8 years ago
David Majda 0847a69643 Rename the "PEG" variable to "peg"
So far, PEG.js was exported in a "PEG" global variable when no module
loader was detected. The same variable name was also conventionally used
when requiring it in Node.js or otherwise referring to it. This was
reflected in various places in the code, documentation, examples, etc.

This commit changes the variable name to "peg" and fixes all relevant
occurrences. The main reason for the change is that in Node.js, modules
are generally referred to by lower-case variable names, so "PEG" was
sticking out when used in Node.js projects.
8 years ago
David Majda e61c23c634 ESLint: Set environments better
Instead of setting ESLint environment to "node" globally, set it on
per-directory basis using separate .eslintrc.json files:

  Directory   Environment
  -----------------------
  bin         node
  lib         commonjs
  spec        jasmine

It was impossible to use this approach for the "benchmark" directory
which contains a mix of files used in various environments. For
benchmark/run, the environment is set inline. For the other files, as
well as spec/helpers.js, the globals are declared manually (it is
impossible to express how these files are used just by a list of
environments).

Fixes #408.
8 years ago
David Majda ee66113130 Fix ESLint errors in benchmark/run
Fix the following errors:

   37:3   error  Unexpected console statement      no-console
   38:3   error  Unexpected console statement      no-console
   42:3   error  Unexpected console statement      no-console
   43:3   error  Unexpected console statement      no-console
   44:3   error  Unexpected console statement      no-console
   51:3   error  Unexpected console statement      no-console
   64:3   error  Unexpected console statement      no-console
   68:3   error  Unexpected console statement      no-console
   74:3   error  Unexpected console statement      no-console
   75:3   error  Unexpected console statement      no-console
   76:3   error  Unexpected console statement      no-console
   77:3   error  Unexpected console statement      no-console
   78:3   error  Unexpected console statement      no-console
   79:3   error  Unexpected console statement      no-console
   80:3   error  Unexpected console statement      no-console
   81:3   error  Unexpected console statement      no-console
   82:3   error  Unexpected console statement      no-console
   94:3   error  Unexpected console statement      no-console
  126:11  error  "runCount" is already defined     no-redeclare
  169:34  error  "test" is defined but never used  no-unused-vars
  194:4   error  Unexpected trailing comma         comma-dangle
8 years ago
David Majda 488f32e661 Fix ESLint errors in benchmark/index.js
Fix the following errors:

  74:14  error  "benchmarks" is not defined       no-undef
  84:36  error  "test" is defined but never used  no-unused-vars
8 years ago
David Majda 768ece28e6 Use ESLint instead of JSHint
Implement the swap and change various directives in the source code. The
"make hint" target becomes "make lint".

The change leads to quite some errors being reported by ESLint. These
will be fixed in subsequent commits.

Note the configuration enables just the recommended rules. Later I plan
to enable more rules to enforce the coding standard. The configuration
also sets the environment to "node", which is far from ideal as the
codebase contains a mix of CommonJS, Node.js and browser code. I hope to
clean this up at some point.
8 years ago
David Majda 60ebd9e695 Simplify JSHint directives 9 years ago
David Majda 20a4fb2e7f Update version to 0.9.0 9 years ago
David Majda be5d14eb27 Update jQuery.scrollTo's LICENSE file
I forgot to do that after upgrading jQuery.scrollTo itself.
9 years ago
David Majda 2d0ab55fa2 Use jQuery.scrollTo 2.1.1 9 years ago
David Majda b929f6ed97 Use jQuery 1.11.3 9 years ago
David Majda de1704f007 Replace |util.{puts,error}| by |console.{log,error}|
The |util.puts| and |util.error| functions are deprecated in Node.js
0.12.x.

Based on a pull request by Jan Stránský (@burningtree):

  https://github.com/pegjs/pegjs/pull/334
9 years ago
Arlo Breault 12c169e7b5 Convert PEG.js code to strict mode
* Issues #323
9 years ago
Arlo Breault f4d2357609 Make jshint aware of node globals 9 years ago
Arlo Breault 7a94f97b46 Convert benchmark files to modules 9 years ago
David Majda c6f0818d49 Use sentence case consistently in {spec,benchmark}/README.md headers 10 years ago
David Majda 4d456402be Small cleanup of benchmark/index.js
Update coding style to match the rest of PEG.js.
10 years ago
David Majda 811a5c0f01 Small cleanup of benchmark/runner.js
Update coding style to match the rest of PEG.js.
10 years ago
David Majda b901a5c37a Rewrite benchmark/README.md
More clarity, better grammar (hopefully).
10 years ago
David Majda fc1d54d049 Convert benchmark/README to Markdown
It will look nicer on GitHub.
10 years ago
David Majda 2263a30034 Update version to 0.8.0 10 years ago
David Majda ff0beb5a8c benchmark/run: Always parse the -n/--run-count value as decimal integer 11 years ago