256 Commits (27904791542a53437d89fa37dd96fc67c373d9e2)

Author SHA1 Message Date
Futago-za Ryuu 94ca36469b Move compiler/vm.js to util/vm.js 7 years ago
Futago-za Ryuu 01555ebbac Move compiler/js.js to util/js.js 7 years ago
Futago-za Ryuu 8d3dc109ed Rename js.regexpClassEscape to js.regexpEscape 7 years ago
Futago-za Ryuu 83e3b9edc4 Add missing whitespace to generated parsers 7 years ago
Futago-za Ryuu af917b1e4d Refactor removeProxyRules 7 years ago
Futago-za Ryuu 1fca2daff6 Move processOptions to utils 7 years ago
Futago-za Ryuu 3745195315 Make the default tracer an optional feature 7 years ago
Futago-za Ryuu f4ca7ca461 Remove grammar option for Session API 7 years ago
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
7 years ago
Futago-za Ryuu 15d364587c Update tsd to include changes since 8e9be9a 7 years ago
Futago-za Ryuu fedf0f3480 Resolve 'vm.runInContext' bottleneck
Calling 'vm.runInContext'  is slightly more expensive then calling `eval`, but removing the string template and extracting the variable generator helps abit.
7 years ago
Futago-za Ryuu b3135690b0 Not session.fail but session.fatal 7 years ago
Futago-za Ryuu 30cfa29553 Provide context to parser (#517) 7 years ago
Futago-za Ryuu 04dfef3b63 Use error emitter (Closes #430) 7 years ago
Futago-za Ryuu ef0595596f Implement error emitter (Closes #431)
Along with commit 851d8ed, this resolves #431 based on the fact that plugins can overwrite session methods, allowing use cases like multiple or limited errors (and/or warnings) to be an opt-in feature.
7 years ago
Futago-za Ryuu 621b11b715 Disable no-unused-vars in Session API 7 years ago
Futago-za Ryuu 6500189d58 Report unused rules (Closes #200) 7 years ago
Futago-za Ryuu 851d8edfdd Implement warning emitter (Closes #327) 7 years ago
Futago-za Ryuu f4c67993f6 Added the Session API 7 years ago
Futago-za Ryuu a5d7cc11a4 ECMA, not ESMA 7 years ago
Futago-za Ryuu fe6f09238a Relay parser opts from peg.generate (#553) 7 years ago
Futago-za Ryuu 5476eca59f Moved AST and visitor classes 7 years ago
Futago-za Ryuu 9d266625b4 Merge ast utils into Grammar class 7 years ago
Mingun 1a713d0175 Add some useful debug information to some exceptions (#475)
* Add some useful debug information to some exceptions

* Add guard for visitor functions preventing from cryptic errors due to incomplete visitors

* Add guard for js generator for preventing from cryptic errors due to incarrect stack manipulations
7 years ago
Futago-za Ryuu d06a5b52ef Restore silentFails guard for rule$expects 7 years ago
Futago-za Ryuu 75a4101622 Some cosmetic changes
- Remove unused '__slice' variable
- Nicely indent a map/concat chain
- 'forEach' instead of 'map' in emitted code
7 years ago
Futago-za Ryuu f5b323b401 Report consistent errors on look ahead + cached results
This should resolve issue #452, and is based entirely on a fix @nikku did on a local branch of PEG.js v0.10.0 (Currently at https://github.com/nikku/pegjs/tree/452-peg-js-0.10-fix).

Also his test case from #555 is included.

Fixes #452, Closes #555
7 years ago
Mingun 9b90fa1d81 Move all codegeneration from `generateBytecode` pass to `generateJs` pass (#459)
* Split 'consts' collection by content types into:

  - literals: for literal expressions, like `"a"`
  - classes: for character class expressions, like `[a]`
  - expectations: for constants describing expected values when parse failed
  - functions: for constants with function code

* Move any JavaScript code generation from 'generateBytecode' to 'generateJs'.
* Rename opcode 'MATCH_REGEXP' to 'MATCH_CLASS' (name reflects purpose, not implementation).
* Replace 'PUSH' opcode with 'PUSH_EMPTY_STRING' opcode because it is only used with empty strings
7 years ago
Futago-za Ryuu 617b6b7425 Updated utils and tsd
- Exposed 'visitor.ASTVisitor'
- Remoed 'util.createVisitor'
- Added type 'peg.SourceLocation'
- Updated tsd for 'peg.compiler.visitor'
- Added tsd for 'peg.util.enforceFastProperties'
- Added tsd for new parser modules
7 years ago
Futago-za Ryuu 27ec5ed9b1 Ensure we are nearly always in fast mode on V8
See: https://stackoverflow.com/a/24989927/1518408
7 years ago
Futago-za Ryuu 7a19d46e8a Add the ASTVisitor class (#451)
For compatibility with pre-0.11 plugins, this class lives on the same namespace as the orignal visitor helper and also exports a static method called 'build'.
7 years ago
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.
7 years ago
Mingun 534dc53ac2 Optimize redundant fail checks (#400)
eliminate unnecessary checks for the result of parse, when it can be statically determined
7 years ago
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).
7 years ago
Mingun 669f782a5f Partial fix #194 - nonsenses error messages with semantic predicates (#547)
* Remove stack manipulations from FAIL opcode and rename FAIL to EXPECT
* Always save the expected values regardless of the match result of expression
* Remove unnecessary check for match result in the `named` node
* Collect and process expectations from predicates
7 years ago
Futago-za Ryuu ea688abd02 Fix shadowing issue on UMD format (#499) 7 years ago
Mingun 3e89534bb7 Auto-add `allowedStartRules` to test options for `changeAST` and `reportError` methods if it not defined 7 years ago
Mingun f0e5eebe1a Add code coverage by Intanbul 7 years ago
Futago-za Ryuu 1dd1487f9b Set version to v0.11.0-dev 7 years ago
Futago-za Ryuu db70215c4a Added 'header' option (#491) 7 years ago
Futago-za Ryuu b4e5b97a2e Disabled eslint rule 'prefer-spread' 7 years ago
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).
7 years ago
felix ee00a1ae6a Check allowedStartRules exist. (#532)
Fixes #524
7 years ago
felix 958e15879d Reimplement offset() and add range(). (#528)
* Reimplement offset()
* Implement range()

Fixes #526, thanks @felix9
7 years ago
Futago-za Ryuu 5cde815341 Add default export for es format.
This is a minor addition that add's a default export statement (e.g. `export default { ... };`) for the es output format.

Fixes #525
7 years ago
Alan Mimms 4cdc6d6353 Do not indent backtick quoted strings in code blocks (#492)
* Do not indent backtick quoted strings in initializer or rule action code blocks
* Use const instead of var for ESLint happiness
* Fix ESLint issues for double quotes and indent6
7 years ago
Mingun 575db38d1f Simplify bytecode: remove unnecessary opcode.
Now generated sources looks little better :)
7 years ago
fatfisz e3b7f0c3a9 Change "esm" to "es" 8 years ago
fatfisz aab928de91 Add support for ES modules 8 years ago
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.
8 years ago