From 69dbe3a4e495fa6ed627c9ecf2500c851e2c847a Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sat, 24 Oct 2020 21:32:17 +0200 Subject: [PATCH] Fork preparation --- README.md | 88 +-- package.json | 9 +- yarn.lock | 2136 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 2173 insertions(+), 60 deletions(-) create mode 100644 yarn.lock diff --git a/README.md b/README.md index 3c1f1f9..d870232 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,6 @@ -[![Build status](https://img.shields.io/travis/pegjs/pegjs.svg)](https://travis-ci.org/pegjs/pegjs) -[![npm version](https://img.shields.io/npm/v/pegjs.svg)](https://www.npmjs.com/package/pegjs) -[![Bower version](https://img.shields.io/bower/v/pegjs.svg)](https://github.com/pegjs/bower) [![License](https://img.shields.io/badge/license-mit-blue.svg)](https://opensource.org/licenses/MIT) -PEG.js +PEG-Redux ====== PEG.js is a simple parser generator for JavaScript that produces fast parsers @@ -11,6 +8,10 @@ with excellent error reporting. You can use it to process complex data or computer languages and build transformers, interpreters, compilers and other tools easily. +PEG-Redux is a __work-in-progress__ fork of PEG.js, with the aim of continuing +maintenance on the PEG.js project, while adding support for modern features +such as modules. + Features -------- @@ -20,49 +21,48 @@ Features * Based on [parsing expression grammar](http://en.wikipedia.org/wiki/Parsing_expression_grammar) formalism — more powerful than traditional LL(*k*) and LR(*k*) parsers - * Usable [from your browser](https://pegjs.org/online), from the command line, - or via JavaScript API + * Usable from your browser, from the command line, or via JavaScript API -Getting Started ---------------- +Differences from the original PEG.js +-------- -[Online version](https://pegjs.org/online) is the easiest way to generate a -parser. Just enter your grammar, try parsing few inputs, and download generated -parser code. + * The plugin API has been dropped for now, as it was underspecified and not very commonly used. A new, more robust and extensive plugin API may come to exist in the future, if it turns out that there is a high demand for customizations that wouldn't fit into the PEG-Redux project itself. + * Bower and stand-alone browser builds have been discontinued. Please use a bundler (see below) instead. + * AMD, UMD and globals support have been discontinued. The generated parsers now only support CommonJS. + * Module support. Both for importing other PEGRedux files, and for `require()`ing JS modules. Installation ------------ ### Node.js -To use the `pegjs` command, install PEG.js globally: +To use the `pegjs` command, install PEG-Redux globally: ```console -$ npm install -g pegjs +$ npm install -g peg-redux ``` -To use the JavaScript API, install PEG.js locally: +To use the JavaScript API, install PEG-Redux locally: ```console -$ npm install pegjs +$ npm install peg-redux ``` -If you need both the `pegjs` command and the JavaScript API, install PEG.js both -ways. +If you need both the `pegjs` command and the JavaScript API, install PEG-Redux +both ways. ### Browser -[Download](https://pegjs.org/#download) the PEG.js library (regular or minified -version) or install it using Bower: +PEG-Redux works with bundlers such as [Browserify](http://browserify.org/), [Parcel](https://parceljs.org/) and [Webpack](https://webpack.js.org/). -```console -$ bower install pegjs -``` +Simply `require()` and use the module like you would in Node.js. The one exception is that modules (either PEG-Redux or Javascript modules) are not currently supported in browser environments. + +Bower and standalone builds have been discontinued in this fork. Getting started with Browserify will only take a few minutes, and give you a better developer experience. Generating a Parser ------------------- -PEG.js generates parser from a grammar that describes expected input and can +PEG-Redux generates parser from a grammar that describes expected input and can specify what the parser returns (using semantic actions on matched parts of the input). Generated parser itself is a JavaScript object with a simple API. @@ -100,26 +100,20 @@ You can tweak the generated parser with several options: `peg.generate` * `--extra-options-file` — file with additional options (in JSON format) to pass to `peg.generate` - * `--format` — format of the generated parser: `amd`, `commonjs`, `globals`, - `umd` (default: `commonjs`) * `--optimize` — selects between optimizing the generated parser for parsing speed (`speed`) or code size (`size`) (default: `speed`) - * `--plugin` — makes PEG.js use a specified plugin (can be specified multiple + * `--plugin` — makes PEG-Redux use a specified plugin (can be specified multiple times) * `--trace` — makes the parser trace its progress ### JavaScript API -In Node.js, require the PEG.js parser generator module: +Require the PEG-Redux parser generator module: ```javascript -var peg = require("pegjs"); +var peg = require("peg-redux"); ``` -In browser, include the PEG.js library in your web page or application using the -`