Commit graph

32 commits

Author SHA1 Message Date
Futago-za Ryuu 94ca36469b Move compiler/vm.js to util/vm.js 2018-04-04 20:21:31 +01:00
Futago-za Ryuu 1fca2daff6 Move processOptions to utils 2018-03-28 23:56:23 +01:00
Futago-za Ryuu 21a6de06d5 Optional features
This commit enables optional features that are enabled by default in the generated parser.

For now, only some of the helpers and filename are generated based on this new option, but this will change in the future most likely.

Resolves #421
2018-03-17 04:08:05 +00:00
Futago-za Ryuu 15d364587c Update tsd to include changes since 8e9be9a 2018-03-12 19:57:43 +00:00
Futago-za Ryuu 30cfa29553 Provide context to parser (#517) 2018-02-02 06:42:03 +00:00
Futago-za Ryuu 04dfef3b63 Use error emitter (Closes #430) 2018-02-02 04:32:39 +00:00
Futago-za Ryuu 6500189d58 Report unused rules (Closes #200) 2018-01-31 02:17:27 +00:00
Futago-za Ryuu f4c67993f6 Added the Session API 2018-01-30 02:38:49 +00:00
Futago-za Ryuu 5476eca59f Moved AST and visitor classes 2018-01-28 02:00:28 +00:00
Futago-za Ryuu 7cdfc03e9f Added utility methods for objects
Before there used to be some internal utility methods for arrays and objects, but as the code base moved to ES5+ use  case only, these were removed in favour of native alternatives, but most of these were only beneficial for arrays.

This commit add's common utility methods for objects, and also exposes these as they can be used by plugin developer's on the PEG.js AST.
2018-01-14 20:44:53 +00:00
Mingun 534dc53ac2 Optimize redundant fail checks (#400)
eliminate unnecessary checks for the result of parse, when it can be statically determined
2018-01-05 21:28:09 +00:00
Mingun 42ec335d13 Optimize silent fails: remove checks that always false (#399)
* Optimization: do not generate unreachable calls |peg$fail| and constants for it (local to the rule).
* Optimization: do not generate unreachable calls |peg$fail| and constants for it (non-local to rule).
2018-01-01 19:35:59 +00:00
Futago-za Ryuu e6d018a88d Update code format and style
This is related to my last commit. I've updated all the JavaScript files to satisfy 'eslint-config-futagozaryuu', my eslint configuration.

I'm sure I've probally missed something, but I've run all NPM scripts and Gulp tasks, fixed any bugs that cropped up, and updated some stuff (mainly related to generated messages), so as far as I can, tell this conversion is over (I know I've probally jixed it just by saying this ;P).
2017-10-25 19:19:42 +01: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 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 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 6294bb5b13 Use only "//" comments
See #443.
2016-09-20 15:07:39 +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 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 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 f36a667376 Remove "undefined" redefinition protection
See #441.
2016-09-01 14:12:16 +02:00
David Majda b044a021c4 Replace arrays.each with Array.prototype.forEach
See #441.
2016-08-27 16:33:05 +02:00
David Majda 67d85f2de8 Align names of compiler passes that detect infinite loops
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).
2016-07-29 18:06:16 +02:00
David Majda 9717dc3417 Talk about "undefined rules" instead of "missing rules" internally
The new terminology is more precise and in line with commonly used
programming languages.

The change involves mainly renaming related compiler pass and files
associated with it.
2016-07-29 15:16:56 +02:00
David Majda eb67cbedb4 Report duplicate labels as errors
Resolves #270.
2016-06-27 13:45:59 +02:00
David Majda eb5875bc6a Report duplicate rule definitions as errors
Based on a pull request by Futago-za Ryuu (@futagoza):

  https://github.com/pegjs/pegjs/pull/329

Resolves #318.
2016-06-22 15:19:56 +02:00
David Majda 149c829897 lib/compiler/index.js: Order default option values alphabetically 2016-06-22 09:48:09 +02:00
David Majda 930877c3ba Move lib/compiler.js to lib/compiler/index.js
This makes "compiler" a regular Node.js module.
2016-06-20 08:06:14 +02:00
Renamed from lib/compiler.js (Browse further)