initial commit taken from gitlab.lrz.de

This commit is contained in:
privatereese
2018-08-24 18:09:42 +02:00
parent ae54ed4c48
commit fc05486403
28494 changed files with 2159823 additions and 0 deletions

618
node_modules/pegjs/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,618 @@
Change Log
==========
This file documents all notable changes to PEG.js. The releases follow [semantic
versioning](http://semver.org/).
0.10.0
------
Released: August 19, 2016
### Major Changes
* **Parsers can be generated in multiple module formats.** The available
formats are: CommonJS (the default), AMD, UMD, globals, and bare (not
available from the command-line).
The format can be specified using the `format` option of the `peg.generate`
function or the `--format` option on the command-line.
It is also possible to specify parser dependencies using the `dependencies`
option of the `peg.generate` function or the `--dependency`/`-d` option on
the command-line. This is mainly useful for the UMD format, where the
dependencies are translated into both AMD dependencies and CommonJS
`require` calls.
* **Browser version of PEG.js is now in the UMD format.** This means it will try
to detect AMD or Node.js/CommonJS module loader and define itself as a
module. If no loader is found, it will export itself using a global
variable.
* **API polishing.** The `peg.buildParser` function was renamed to
`peg.generate`. The global variable the browser version of PEG.js is
available in when no loader is detected was renamed from `PEG` to `peg`.
* **CLI improvements.** There is new `--output`/`-o` command-line option which
allows to specify the output file. The old way of specifying the output file
using a second argument was removed. To make room for the new `-o` option
the old one (a shortcut for `--optimize`) was renamed to `-O`. All these
changes make PEG.js conform to traditional compiler command-line interface.
It is now also possible to use `-` as a file name on the command-line (with
the usual meaning of standard input/output).
* **Improved error messages.** Both messages produced by PEG.js and generated
parsers were improved.
* **Duplicate rule definitions are reported as errors.**
* **Duplicate labels are reported as errors.**
### Minor Changes
* Exposed the AST node visitor builder as `peg.compiler.visitor`. This is
useful mainly for plugins which manipulate the AST.
* Exposed the function which builds messages of exceptions produced by
generated parsers as `SyntaxError.buildMessage`. This is useful mainly for
customizing these error messages.
* The `error` and `expected` functions now accept an optional `location`
parameter. This allows to customize the location in which the resulting
syntax error is reported.
* Refactored expectations reported in the `expected` property of exceptions
produced by generated parsers. They are no longer de-duplicated and sorted,
their format changed to be more machine-readable, and they no longer contain
human-readable descriptions.
* The `found` property of exceptions produced by the `error` function is now
set to `null`.
* Removed access to the parser object in parser code via the `parser`
variable.
* Made handling of optional parameters consistent with ES 2015. Specifically,
passing `undefined` as a parameter value is now equivalent to not passing
the parameter at all.
* Renamed several compiler passes.
* Generated parsers no longer consider `\r`, `\u2028`, and `\u2029` as
newlines (only `\n` and `\r\n`).
* Simplified the arithmetics example grammar.
* Switched from `first`/`rest` to `head`/`tail` in PEG.js grammar and example
grammars.
* Started using ESLint instead of JSHint and fixed various problems it found.
* Added [contribution
guidelines](https://github.com/pegjs/pegjs/blob/master/CONTRIBUTING.md).
* Removed support for io.js.
### Bug Fixes
* Fixed `bin/pegjs` so that invoking it with one non-option argument which is
an extension-less file doesnt cause that file to be overwritten.
* Fixed label scoping so that labels in expressions like `(a:"a")` or `(a:"a"
b:"b" c:"c")` arent visible from the outside.
* Fixed escaping of generated JavaScript strings & regexps to also escape DEL
(U+007F).
* Fixed the JSON example grammar to correctly handle characters with code
points above U+10FF in strings.
* Fixed multiple compatibility issues of `tools/impact` on OS X.
* Fixed slow deduplication of expectation descriptions.
[Complete set of changes](https://github.com/pegjs/pegjs/compare/v0.9.0...v0.10.0)
0.9.0
-----
Released: August 30, 2015
### Major Changes
* **Tracing support.** Parsers can be compiled with support for tracing their
progress, which can help debugging complex grammars. This feature is
experimental and is expected to evolve over time as experience is gained.
[More details](https://github.com/pegjs/pegjs/commit/da57118a43a904f753d44d407994cf0b36358adc)
* **Infinite loop detection.** Grammar constructs that could cause infinite
loops in generated parsers are detected during compilation and cause errors.
* **Improved location information API.** The `line`, `column`, and `offset`
functions available in parser code were replaced by a single `location`
function which returns an object describing the current location. Similarly,
the `line`, `column`, and `offset` properties of exceptions were replaced by
a single `location` property. The location is no longer a single point but a
character range, which is meaningful mainly in actions where the range
covers actions expression.
[More details](https://github.com/pegjs/pegjs/compare/e75f21dc8f0e66b3d87c4c19b3fcb8f89d9c3acd...eaca5f0acf97b66ef141fed84aa95d4e72e33757)
* **Improved error reporting.** All exceptions thrown when generating a parser
have associated location information. And all exceptions thrown by generated
parser and PEG.js itself have a stack trace (the `stack` property) in
environments that support `Error.captureStackTrace`.
* **Strict mode code**. All PEG.js and generated parser code is written using
[JavaScript strict mode](https://developer.mozilla.org/cs/docs/Web/JavaScript/Reference/Strict_mode).
### Minor Changes
* Labels behave like block-scoped variables. This means parser code can see
labels defined outside expressions containing code.
* Empty sequences are no longer allowed.
* Label names cant be JavaScript reserved words.
* Rule and label names can contain Unicode characters like in JavaScript.
* Rules have to be separated either by `;` or a newline (until now, any
whitespace was enough).
* The PEG.js grammar and all the example grammars were completely rewritten.
This rewrite included a number of cleanups, formatting changes, naming
changes, and bug fixes.
* The parser object can now be accessed as `parser` in parser code.
* Location information computation is faster.
* Added support for Node.js >= 0.10.x, io.js, and Edge. Removed support for
Node.js < 0.10.x.
### Bug Fixes
* Fixed left recursion detector which missed many cases.
* Fixed escaping of U+0100—U+107F and U+1000—U+107F in generated code and
error messages.
* Renamed `parse` and `SyntaxError` to `peg$parse` and `peg$SyntaxError` to
mark them as internal identifiers.
[Complete set of changes](https://github.com/pegjs/pegjs/compare/v0.8.0...v0.9.0)
0.8.0
-----
Released: December 24, 2013
### Big Changes
* Completely rewrote the code generator. Among other things, it allows
optimizing generated parsers for parsing speed or code size using the
`optimize` option of the `PEG.buildParser` method or the `--optimize`/`-o`
option on the command-line. All internal identifiers in generated code now
also have a `peg$` prefix to discourage their use and avoid conflicts.
[[#35](https://github.com/dmajda/pegjs/issues/35),
[#92](https://github.com/dmajda/pegjs/issues/92)]
* Completely redesigned error handling. Instead of returning `null` inside
actions to indicate match failure, new `expected` and `error` functions can
be called to trigger an error. Also, expectation inside the `SyntaxError`
exceptions are now structured to allow easier machine processing.
[[#198](https://github.com/dmajda/pegjs/issues/198)]
* Implemented a plugin API. The list of plugins to use can be specified using
the `plugins` option of the `PEG.buildParser` method or the `--plugin`
option on the command-line. Also implemented the `--extra-options` and
`--extra-options-file` command-line options, which are mainly useful to pass
additional options to plugins.
[[#106](https://github.com/dmajda/pegjs/issues/106)]
* Made `offset`, `line` and `column` functions, not variables. They are now
available in all parsers and return lazily-computed position data. Removed
now useless `trackLineAndColumn` option of the `PEG.buildParser` method and
the `--track-line-and-column` option on the command-line.
* Added a new `text` function. When called inside an action, it returns the
text matched by action's expression.
[[#131](https://github.com/dmajda/pegjs/issues/131)]
* Added a new `$` operator. It extracts matched strings from expressions.
* The `?` operator now returns `null` on unsuccessful match.
* Predicates now always return `undefined`.
* Replaced the `startRule` parameter of the `parse` method in generated
parsers with more generic `options` parameter. The start rule can now be
specified as the `startRule` option. The `options` parameter can be also
used to pass custom options to the parser because it is visible as the
`options` variable inside parser code.
[[#37](https://github.com/dmajda/pegjs/issues/37)]
* The list of allowed start rules of a generated parser now has to be
specified explicitly using the `allowedStartRules` option of the
`PEG.buildParser` method or the `--allowed-start-rule` option on the
command-line. This will make certain optimizations like rule inlining easier
in the future.
* Removed the `toSource` method of generated parsers and introduced a new
`output` option of the `PEG.buildParser` method. It allows callers to
specify whether they want to get back the parser object or its source code.
* The source code is now a valid npm package. This makes using development
versions easier.
[[#32](https://github.com/dmajda/pegjs/issues/32)]
* Generated parsers are now ~25% faster and ~62%/~3% smaller (when optimized
for size/speed) than those generated by 0.7.0.
* Requires Node.js 0.8.0+.
### Small Changes
* `bin/pegjs` now outputs just the parser source if the value of the
`--export-var` option is empty. This makes embedding generated parsers into
other files easier.
[[#143](https://github.com/dmajda/pegjs/issues/143)]
* Changed the value of the `name` property of `PEG.GrammarError` instances
from “PEG.GrammarError” to just “GrammarError”. This better reflects the
fact that PEG.js can get required with different variable name than `PEG`.
* Setup prototype chain for `PEG.GrammarError` correctly.
* Setup prototype chain for `SyntaxError` in generated parsers correctly.
* Fixed error messages in certain cases with trailing input
[[#119](https://github.com/dmajda/pegjs/issues/119)]
* Fixed code generated for classes starting with `\^`.
[[#125](https://github.com/dmajda/pegjs/issues/125)]
* Fixed too eager proxy rules removal.
[[#137](https://github.com/dmajda/pegjs/issues/137)]
* Added a license to all vendored libraries.
[[#207](https://github.com/dmajda/pegjs/issues/207)]
* Converted the test suite from QUnit to Jasmine, cleaning it up on the way.
* Travis CI integration.
* Various internal code improvements and fixes.
* Various generated code improvements and fixes.
* Various example grammar improvements and fixes.
* Improved `README.md`.
* Converted `CHANGELOG` to Markdown.
0.7.0
-----
Released: April 18, 2012
### Big Changes
* Added ability to pass options to `PEG.buildParser`.
* Implemented the `trackLineAndColumn` option for `PEG.buildParser` (together
with the `--track-line-and-column` command-line option). It makes the
generated parser track line and column during parsing. These are made
available inside actions and predicates as `line` and `column` variables.
* Implemented the `cache` option for `PEG.buildParser` (together with the
`--cache` command-line option). This option enables/disables the results
cache in generated parsers, resulting in dramatic speedup when the cache is
disabled (the default now). The cost is breaking the linear parsing time
guarantee.
* The current parse position is visible inside actions and predicates as the
`offset` variable.
* Exceptions thrown by the parser have `offset`, `expected` and `found`
properties containing machine-readable information about the parse failure
(based on a patch by Marcin Stefaniuk).
* Semantic predicates have access to preceding labels.
[[GH-69](https://github.com/dmajda/pegjs/issues/69)]
* Implemented case-insensitive literal and class matching.
[[GH-34](https://github.com/dmajda/pegjs/issues/34)]
* Rewrote the code generator — split some computations into separate passes
and based it on a proper templating system (Codie).
* Rewrote variable handling in generated parsers in a stack-like fashion,
simplifying the code and making the parsers smaller and faster.
* Adapted to Node.js 0.6.6+ (no longer supported in older versions).
* Dropped support for IE < 8.
* As a result of several optimizations, parsers generated by 0.7.0 are ~6.4
times faster and ~19% smaller than those generated by 0.6.2 (as reported by
`/tools/impact`).
### Small Changes
* Fixed reported error position when part of the input is not consumed.
[[GH-48](https://github.com/dmajda/pegjs/issues/48)]
* Fixed incorrect disjunction operator in `computeErrorPosition` (original
patch by Wolfgang Kluge).
* Fixed regexp for detecting command-line options in `/bin/pegjs`.
[[GH-51](https://github.com/dmajda/pegjs/issues/51)]
* Generate more efficient code for empty literals (original patch by Wolfgang
Kluge).
* Fixed comment typos (patches by Wolfgang Kluge and Jason Davies).
[[GH-59](https://github.com/dmajda/pegjs/issues/59)]
* Fixed a typo in JavaScript example grammar.
[[GH-62](https://github.com/dmajda/pegjs/issues/62)]
* Made copy & paste inclusion of the PEG.js library into another code easier
by changing how the library is exported.
* Improved the copyright comment and the “Generated by...” header.
* Replaced `Jakefile` with `Makefile`.
* Added `make hint` task that checks all JavaScript files using JSHint and
resolved all issues it reported. All JavaScript files and also generated
parsers are JSHint-clean now.
* Fixed output printed during test failures (expected value was being printed
instead of the actual one). Original patch by Wolfgang Kluge.
* Added a `/tools/impact` script to measure speed and size impact of commits.
* Various generated code improvements and fixes.
* Various internal code improvements and fixes.
* Improved `README.md`.
0.6.2
-----
Released: August 20, 2011
### Small Changes
* Reset parser position when action returns `null`.
* Fixed typo in JavaScript example grammar.
0.6.1
-----
Released: April 14, 2011
### Small Changes
* Use `--ascii` option when generating a minified version.
0.6.0
-----
Released: April 14, 2011
### Big Changes
* Rewrote the command-line mode to be based on Node.js instead of Rhino — no
more Java dependency. This also means that PEG.js is available as a Node.js
package and can be required as a module.
* Version for the browser is built separately from the command-line one in two
flavors (normal and minified).
* Parser variable name is no longer required argument of `bin/pegjs` — it is
`module.exports` by default and can be set using the `-e`/`--export-var`
option. This makes parsers generated by `/bin/pegjs` Node.js modules by
default.
* Added ability to start parsing from any grammar rule.
* Added several compiler optimizations — 0.6 is ~12% faster than 0.5.1 in the
benchmark on V8.
### Small Changes
* Split the source code into multiple files combined together using a build
system.
* Jake is now used instead of Rake for build scripts — no more Ruby
dependency.
* Test suite can be run from the command-line.
* Benchmark suite can be run from the command-line.
* Benchmark browser runner improvements (users can specify number of runs,
benchmarks are run using `setTimeout`, table is centered and fixed-width).
* Added PEG.js version to “Generated by...” line in generated parsers.
* Added PEG.js version information and homepage header to `peg.js`.
* Generated code improvements and fixes.
* Internal code improvements and fixes.
* Rewrote `README.md`.
0.5.1
-----
Released: November 28, 2010
### Small Changes
* Fixed a problem where “SyntaxError: Invalid range in character class.” error
appeared when using command-line version on Widnows
([GH-13](https://github.com/dmajda/pegjs/issues/13)).
* Fixed wrong version reported by `bin/pegjs --version`.
* Removed two unused variables in the code.
* Fixed incorrect variable name on two places.
0.5
---
Released: June 10, 2010
### Big Changes
* Syntax change: Use labeled expressions and variables instead of `$1`, `$2`,
etc.
* Syntax change: Replaced `:` after a rule name with `=`.
* Syntax change: Allow trailing semicolon (`;`) for rules
* Semantic change: Start rule of the grammar is now implicitly its first rule.
* Implemented semantic predicates.
* Implemented initializers.
* Removed ability to change the start rule when generating the parser.
* Added several compiler optimizations — 0.5 is ~11% faster than 0.4 in the
benchmark on V8.
### Small Changes
* `PEG.buildParser` now accepts grammars only in string format.
* Added “Generated by ...” message to the generated parsers.
* Formatted all grammars more consistently and transparently.
* Added notes about ECMA-262, 5th ed. compatibility to the JSON example
grammar.
* Guarded against redefinition of `undefined`.
* Made `bin/pegjs` work when called via a symlink
([issue #1](https://github.com/dmajda/pegjs/issues/1)).
* Fixed bug causing incorrect error messages
([issue #2](https://github.com/dmajda/pegjs/issues/2)).
* Fixed error message for invalid character range.
* Fixed string literal parsing in the JavaScript grammar.
* Generated code improvements and fixes.
* Internal code improvements and fixes.
* Improved `README.md`.
0.4
---
Released: April 17, 2010
### Big Changes
* Improved IE compatibility — IE6+ is now fully supported.
* Generated parsers are now standalone (no runtime is required).
* Added example grammars for JavaScript, CSS and JSON.
* Added a benchmark suite.
* Implemented negative character classes (e.g. `[^a-z]`).
* Project moved from BitBucket to GitHub.
### Small Changes
* Code generated for the character classes is now regexp-based (= simpler and
more scalable).
* Added `\uFEFF` (BOM) to the definition of whitespace in the metagrammar.
* When building a parser, left-recursive rules (both direct and indirect) are
reported as errors.
* When building a parser, missing rules are reported as errors.
* Expected items in the error messages do not contain duplicates and they are
sorted.
* Fixed several bugs in the example arithmetics grammar.
* Converted `README` to GitHub Flavored Markdown and improved it.
* Added `CHANGELOG`.
* Internal code improvements.
0.3
---
Released: March 14, 2010
* Wrote `README`.
* Bootstrapped the grammar parser.
* Metagrammar recognizes JavaScript-like comments.
* Changed standard grammar extension from `.peg` to `.pegjs` (it is more
specific).
* Simplified the example arithmetics grammar + added comment.
* Fixed a bug with reporting of invalid ranges such as `[b-a]` in the
metagrammar.
* Fixed `--start` vs. `--start-rule` inconsistency between help and actual
option processing code.
* Avoided ugliness in QUnit output.
* Fixed typo in help: `parserVar` → `parser_var`.
* Internal code improvements.
0.2.1
-----
Released: March 8, 2010
* Added `pegjs-` prefix to the name of the minified runtime file.
0.2
---
Released: March 8, 2010
* Added `Rakefile` that builds minified runtime using Google Closure Compiler
API.
* Removed trailing commas in object initializers (Google Closure does not like
them).
0.1
---
Released: March 8, 2010
* Initial release.

22
node_modules/pegjs/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,22 @@
Copyright (c) 2010-2016 David Majda
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

1
node_modules/pegjs/VERSION generated vendored Normal file
View File

@@ -0,0 +1 @@
0.10.0

331
node_modules/pegjs/bin/pegjs generated vendored Executable file
View File

@@ -0,0 +1,331 @@
#!/usr/bin/env node
"use strict";
var fs = require("fs");
var path = require("path");
var peg = require("../lib/peg");
var objects = require("../lib/utils/objects");
/* Helpers */
function printVersion() {
console.log("PEG.js " + peg.VERSION);
}
function printHelp() {
console.log("Usage: pegjs [options] [--] [<input_file>]");
console.log("");
console.log("Options:");
console.log(" --allowed-start-rules <rules> comma-separated list of rules the generated");
console.log(" parser will be allowed to start parsing");
console.log(" from (default: the first rule in the");
console.log(" grammar)");
console.log(" --cache make generated parser cache results");
console.log(" -d, --dependency <dependency> use specified dependency (can be specified");
console.log(" multiple times)");
console.log(" -e, --export-var <variable> name of a global variable into which the");
console.log(" parser object is assigned to when no module");
console.log(" loader is detected");
console.log(" --extra-options <options> additional options (in JSON format) to pass");
console.log(" to peg.generate");
console.log(" --extra-options-file <file> file with additional options (in JSON");
console.log(" format) to pass to peg.generate");
console.log(" --format <format> format of the generated parser: amd,");
console.log(" commonjs, globals, umd (default: commonjs)");
console.log(" -h, --help print help and exit");
console.log(" -O, --optimize <goal> select optimization for speed or size");
console.log(" (default: speed)");
console.log(" -o, --output <file> output file");
console.log(" --plugin <plugin> use a specified plugin (can be specified");
console.log(" multiple times)");
console.log(" --trace enable tracing in generated parser");
console.log(" -v, --version print version information and exit");
}
function exitSuccess() {
process.exit(0);
}
function exitFailure() {
process.exit(1);
}
function abort(message) {
console.error(message);
exitFailure();
}
function addExtraOptions(options, json) {
var extraOptions;
try {
extraOptions = JSON.parse(json);
} catch (e) {
if (!(e instanceof SyntaxError)) { throw e; }
abort("Error parsing JSON: " + e.message);
}
if (typeof extraOptions !== "object") {
abort("The JSON with extra options has to represent an object.");
}
for (var key in extraOptions) {
if (extraOptions.hasOwnProperty(key)) {
options[key] = extraOptions[key];
}
}
}
/*
* Extracted into a function just to silence JSHint complaining about creating
* functions in a loop.
*/
function trim(s) {
return s.trim();
}
/* Arguments */
var args = process.argv.slice(2); // Trim "node" and the script path.
function isOption(arg) {
return (/^-.+/).test(arg);
}
function nextArg() {
args.shift();
}
/* Files */
function readStream(inputStream, callback) {
var input = "";
inputStream.on("data", function(data) { input += data; });
inputStream.on("end", function() { callback(input); });
}
/* Main */
var inputFile = null;
var outputFile = null;
var options = {
cache: false,
dependencies: {},
exportVar: null,
format: "commonjs",
optimize: "speed",
output: "source",
plugins: [],
trace: false
};
while (args.length > 0 && isOption(args[0])) {
switch (args[0]) {
case "--allowed-start-rules":
nextArg();
if (args.length === 0) {
abort("Missing parameter of the -e/--allowed-start-rules option.");
}
options.allowedStartRules = args[0]
.split(",")
.map(trim);
break;
case "--cache":
options.cache = true;
break;
case "-d":
case "--dependency":
nextArg();
if (args.length === 0) {
abort("Missing parameter of the -d/--dependency option.");
}
if (args[0].indexOf(":") !== -1) {
var parts = args[0].split(":");
options.dependencies[parts[0]] = parts[1];
} else {
options.dependencies[args[0]] = args[0];
}
break;
case "-e":
case "--export-var":
nextArg();
if (args.length === 0) {
abort("Missing parameter of the -e/--export-var option.");
}
options.exportVar = args[0];
break;
case "--extra-options":
nextArg();
if (args.length === 0) {
abort("Missing parameter of the --extra-options option.");
}
addExtraOptions(options, args[0]);
break;
case "--extra-options-file":
nextArg();
if (args.length === 0) {
abort("Missing parameter of the --extra-options-file option.");
}
try {
var json = fs.readFileSync(args[0]);
} catch(e) {
abort("Can't read from file \"" + args[0] + "\".");
}
addExtraOptions(options, json);
break;
case "--format":
nextArg();
if (args.length === 0) {
abort("Missing parameter of the --format option.");
}
if (args[0] !== "amd" && args[0] !== "commonjs" && args[0] !== "globals" && args[0] !== "umd") {
abort("Module format must be one of \"amd\", \"commonjs\", \"globals\", and \"umd\".");
}
options.format = args[0];
break;
case "-h":
case "--help":
printHelp();
exitSuccess();
break;
case "-O":
case "--optimize":
nextArg();
if (args.length === 0) {
abort("Missing parameter of the -O/--optimize option.");
}
if (args[0] !== "speed" && args[0] !== "size") {
abort("Optimization goal must be either \"speed\" or \"size\".");
}
options.optimize = args[0];
break;
case "-o":
case "--output":
nextArg();
if (args.length === 0) {
abort("Missing parameter of the -o/--output option.");
}
outputFile = args[0];
break;
case "--plugin":
nextArg();
if (args.length === 0) {
abort("Missing parameter of the --plugin option.");
}
var id = /^(\.\/|\.\.\/)/.test(args[0]) ? path.resolve(args[0]) : args[0];
var mod;
try {
mod = require(id);
} catch (e) {
if (e.code !== "MODULE_NOT_FOUND") { throw e; }
abort("Can't load module \"" + id + "\".");
}
options.plugins.push(mod);
break;
case "--trace":
options.trace = true;
break;
case "-v":
case "--version":
printVersion();
exitSuccess();
break;
case "--":
nextArg();
break;
default:
abort("Unknown option: " + args[0] + ".");
}
nextArg();
}
if (objects.keys(options.dependencies).length > 0) {
if (options.format !== "amd" && options.format !== "commonjs" && options.format !== "umd") {
abort("Can't use the -d/--dependency option with the \"" + options.format + "\" module format.");
}
}
if (options.exportVar !== null) {
if (options.format !== "globals" && options.format !== "umd") {
abort("Can't use the -e/--export-var option with the \"" + options.format + "\" module format.");
}
}
var inputStream;
var outputStream;
switch (args.length) {
case 0:
inputFile = "-";
break;
case 1:
inputFile = args[0];
break;
default:
abort("Too many arguments.");
}
if (outputFile === null) {
if (inputFile === "-") {
outputFile = "-";
} else {
outputFile = inputFile.substr(0, inputFile.length - path.extname(inputFile).length) + ".js";
}
}
if (inputFile === "-") {
process.stdin.resume();
inputStream = process.stdin;
inputStream.on("error", function() {
abort("Can't read from file \"" + inputFile + "\".");
});
} else {
inputStream = fs.createReadStream(inputFile);
}
if (outputFile === "-") {
outputStream = process.stdout;
} else {
outputStream = fs.createWriteStream(outputFile);
outputStream.on("error", function() {
abort("Can't write to file \"" + outputFile + "\".");
});
}
readStream(inputStream, function(input) {
var source;
try {
source = peg.generate(input, options);
} catch (e) {
if (e.location !== undefined) {
abort(e.location.start.line + ":" + e.location.start.column + ": " + e.message);
} else {
abort(e.message);
}
}
outputStream.write(source);
if (outputStream !== process.stdout) {
outputStream.end();
}
});

40
node_modules/pegjs/examples/arithmetics.pegjs generated vendored Normal file
View File

@@ -0,0 +1,40 @@
/*
* Simple Arithmetics Grammar
* ==========================
*
* Accepts expressions like "2 * (3 + 4)" and computes their value.
*/
Expression
= head:Term tail:(_ ("+" / "-") _ Term)* {
var result = head, i;
for (i = 0; i < tail.length; i++) {
if (tail[i][1] === "+") { result += tail[i][3]; }
if (tail[i][1] === "-") { result -= tail[i][3]; }
}
return result;
}
Term
= head:Factor tail:(_ ("*" / "/") _ Factor)* {
var result = head, i;
for (i = 0; i < tail.length; i++) {
if (tail[i][1] === "*") { result *= tail[i][3]; }
if (tail[i][1] === "/") { result /= tail[i][3]; }
}
return result;
}
Factor
= "(" _ expr:Expression _ ")" { return expr; }
/ Integer
Integer "integer"
= [0-9]+ { return parseInt(text(), 10); }
_ "whitespace"
= [ \t\n\r]*

431
node_modules/pegjs/examples/css.pegjs generated vendored Normal file
View File

@@ -0,0 +1,431 @@
/*
* CSS Grammar
* ===========
*
* Based on grammar from CSS 2.1 specification [1] (including the errata [2]).
* Generated parser builds a syntax tree composed of nested JavaScript objects,
* vaguely inspired by CSS DOM [3]. The CSS DOM itself wasn't used as it is not
* expressive enough (e.g. selectors are reflected as text, not structured
* objects) and somewhat cumbersome.
*
* Limitations:
*
* * Many errors which should be recovered from according to the specification
* (e.g. malformed declarations or unexpected end of stylesheet) are fatal.
* This is a result of straightforward rewrite of the CSS grammar to PEG.js.
*
* [1] http://www.w3.org/TR/2011/REC-CSS2-20110607
* [2] http://www.w3.org/Style/css2-updates/REC-CSS2-20110607-errata.html
* [3] http://www.w3.org/TR/DOM-Level-2-Style/css.html
*/
{
function extractOptional(optional, index) {
return optional ? optional[index] : null;
}
function extractList(list, index) {
var result = [], i;
for (i = 0; i < list.length; i++) {
if (list[i][index] !== null) {
result.push(list[i][index]);
}
}
return result;
}
function buildList(head, tail, index) {
return (head !== null ? [head] : []).concat(extractList(tail, index));
}
function buildExpression(head, tail) {
var result = head, i;
for (i = 0; i < tail.length; i++) {
result = {
type: "Expression",
operator: tail[i][0],
left: result,
right: tail[i][1]
};
}
return result;
}
}
start
= stylesheet:stylesheet comment* { return stylesheet; }
/* ----- G.1 Grammar ----- */
stylesheet
= charset:(CHARSET_SYM STRING ";")? (S / CDO / CDC)*
imports:(import (CDO S* / CDC S*)*)*
rules:((ruleset / media / page) (CDO S* / CDC S*)*)*
{
return {
type: "StyleSheet",
charset: extractOptional(charset, 1),
imports: extractList(imports, 0),
rules: extractList(rules, 0)
};
}
import
= IMPORT_SYM S* href:(STRING / URI) S* media:media_list? ";" S* {
return {
type: "ImportRule",
href: href,
media: media !== null ? media : []
};
}
media
= MEDIA_SYM S* media:media_list "{" S* rules:ruleset* "}" S* {
return {
type: "MediaRule",
media: media,
rules: rules
};
}
media_list
= head:medium tail:("," S* medium)* { return buildList(head, tail, 2); }
medium
= name:IDENT S* { return name; }
page
= PAGE_SYM S* selector:pseudo_page?
"{" S*
declarationsFirst:declaration?
declarationsRest:(";" S* declaration?)*
"}" S*
{
return {
type: "PageRule",
selector: selector,
declarations: buildList(declarationsFirst, declarationsRest, 2)
};
}
pseudo_page
= ":" value:IDENT S* { return { type: "PseudoSelector", value: value }; }
operator
= "/" S* { return "/"; }
/ "," S* { return ","; }
combinator
= "+" S* { return "+"; }
/ ">" S* { return ">"; }
property
= name:IDENT S* { return name; }
ruleset
= selectorsFirst:selector
selectorsRest:("," S* selector)*
"{" S*
declarationsFirst:declaration?
declarationsRest:(";" S* declaration?)*
"}" S*
{
return {
type: "RuleSet",
selectors: buildList(selectorsFirst, selectorsRest, 2),
declarations: buildList(declarationsFirst, declarationsRest, 2)
};
}
selector
= left:simple_selector S* combinator:combinator right:selector {
return {
type: "Selector",
combinator: combinator,
left: left,
right: right
};
}
/ left:simple_selector S+ right:selector {
return {
type: "Selector",
combinator: " ",
left: left,
right: right
};
}
/ selector:simple_selector S* { return selector; }
simple_selector
= element:element_name qualifiers:(id / class / attrib / pseudo)* {
return {
type: "SimpleSelector",
element: element,
qualifiers: qualifiers
};
}
/ qualifiers:(id / class / attrib / pseudo)+ {
return {
type: "SimpleSelector",
element: "*",
qualifiers: qualifiers
};
}
id
= id:HASH { return { type: "IDSelector", id: id }; }
class
= "." class_:IDENT { return { type: "ClassSelector", "class": class_ }; }
element_name
= IDENT
/ "*"
attrib
= "[" S*
attribute:IDENT S*
operatorAndValue:(("=" / INCLUDES / DASHMATCH) S* (IDENT / STRING) S*)?
"]"
{
return {
type: "AttributeSelector",
attribute: attribute,
operator: extractOptional(operatorAndValue, 0),
value: extractOptional(operatorAndValue, 2)
};
}
pseudo
= ":"
value:(
name:FUNCTION S* params:(IDENT S*)? ")" {
return {
type: "Function",
name: name,
params: params !== null ? [params[0]] : []
};
}
/ IDENT
)
{ return { type: "PseudoSelector", value: value }; }
declaration
= name:property ':' S* value:expr prio:prio? {
return {
type: "Declaration",
name: name,
value: value,
important: prio !== null
};
}
prio
= IMPORTANT_SYM S*
expr
= head:term tail:(operator? term)* { return buildExpression(head, tail); }
term
= quantity:(PERCENTAGE / LENGTH / EMS / EXS / ANGLE / TIME / FREQ / NUMBER)
S*
{
return {
type: "Quantity",
value: quantity.value,
unit: quantity.unit
};
}
/ value:STRING S* { return { type: "String", value: value }; }
/ value:URI S* { return { type: "URI", value: value }; }
/ function
/ hexcolor
/ value:IDENT S* { return { type: "Ident", value: value }; }
function
= name:FUNCTION S* params:expr ")" S* {
return { type: "Function", name: name, params: params };
}
hexcolor
= value:HASH S* { return { type: "Hexcolor", value: value }; }
/* ----- G.2 Lexical scanner ----- */
/* Macros */
h
= [0-9a-f]i
nonascii
= [\x80-\uFFFF]
unicode
= "\\" digits:$(h h? h? h? h? h?) ("\r\n" / [ \t\r\n\f])? {
return String.fromCharCode(parseInt(digits, 16));
}
escape
= unicode
/ "\\" ch:[^\r\n\f0-9a-f]i { return ch; }
nmstart
= [_a-z]i
/ nonascii
/ escape
nmchar
= [_a-z0-9-]i
/ nonascii
/ escape
string1
= '"' chars:([^\n\r\f\\"] / "\\" nl:nl { return ""; } / escape)* '"' {
return chars.join("");
}
string2
= "'" chars:([^\n\r\f\\'] / "\\" nl:nl { return ""; } / escape)* "'" {
return chars.join("");
}
comment
= "/*" [^*]* "*"+ ([^/*] [^*]* "*"+)* "/"
ident
= prefix:$"-"? start:nmstart chars:nmchar* {
return prefix + start + chars.join("");
}
name
= chars:nmchar+ { return chars.join(""); }
num
= [+-]? ([0-9]+ / [0-9]* "." [0-9]+) ("e" [+-]? [0-9]+)? {
return parseFloat(text());
}
string
= string1
/ string2
url
= chars:([!#$%&*-\[\]-~] / nonascii / escape)* { return chars.join(""); }
s
= [ \t\r\n\f]+
w
= s?
nl
= "\n"
/ "\r\n"
/ "\r"
/ "\f"
A = "a"i / "\\" "0"? "0"? "0"? "0"? [\x41\x61] ("\r\n" / [ \t\r\n\f])? { return "a"; }
C = "c"i / "\\" "0"? "0"? "0"? "0"? [\x43\x63] ("\r\n" / [ \t\r\n\f])? { return "c"; }
D = "d"i / "\\" "0"? "0"? "0"? "0"? [\x44\x64] ("\r\n" / [ \t\r\n\f])? { return "d"; }
E = "e"i / "\\" "0"? "0"? "0"? "0"? [\x45\x65] ("\r\n" / [ \t\r\n\f])? { return "e"; }
G = "g"i / "\\" "0"? "0"? "0"? "0"? [\x47\x67] ("\r\n" / [ \t\r\n\f])? / "\\g"i { return "g"; }
H = "h"i / "\\" "0"? "0"? "0"? "0"? [\x48\x68] ("\r\n" / [ \t\r\n\f])? / "\\h"i { return "h"; }
I = "i"i / "\\" "0"? "0"? "0"? "0"? [\x49\x69] ("\r\n" / [ \t\r\n\f])? / "\\i"i { return "i"; }
K = "k"i / "\\" "0"? "0"? "0"? "0"? [\x4b\x6b] ("\r\n" / [ \t\r\n\f])? / "\\k"i { return "k"; }
L = "l"i / "\\" "0"? "0"? "0"? "0"? [\x4c\x6c] ("\r\n" / [ \t\r\n\f])? / "\\l"i { return "l"; }
M = "m"i / "\\" "0"? "0"? "0"? "0"? [\x4d\x6d] ("\r\n" / [ \t\r\n\f])? / "\\m"i { return "m"; }
N = "n"i / "\\" "0"? "0"? "0"? "0"? [\x4e\x6e] ("\r\n" / [ \t\r\n\f])? / "\\n"i { return "n"; }
O = "o"i / "\\" "0"? "0"? "0"? "0"? [\x4f\x6f] ("\r\n" / [ \t\r\n\f])? / "\\o"i { return "o"; }
P = "p"i / "\\" "0"? "0"? "0"? "0"? [\x50\x70] ("\r\n" / [ \t\r\n\f])? / "\\p"i { return "p"; }
R = "r"i / "\\" "0"? "0"? "0"? "0"? [\x52\x72] ("\r\n" / [ \t\r\n\f])? / "\\r"i { return "r"; }
S_ = "s"i / "\\" "0"? "0"? "0"? "0"? [\x53\x73] ("\r\n" / [ \t\r\n\f])? / "\\s"i { return "s"; }
T = "t"i / "\\" "0"? "0"? "0"? "0"? [\x54\x74] ("\r\n" / [ \t\r\n\f])? / "\\t"i { return "t"; }
U = "u"i / "\\" "0"? "0"? "0"? "0"? [\x55\x75] ("\r\n" / [ \t\r\n\f])? / "\\u"i { return "u"; }
X = "x"i / "\\" "0"? "0"? "0"? "0"? [\x58\x78] ("\r\n" / [ \t\r\n\f])? / "\\x"i { return "x"; }
Z = "z"i / "\\" "0"? "0"? "0"? "0"? [\x5a\x7a] ("\r\n" / [ \t\r\n\f])? / "\\z"i { return "z"; }
/* Tokens */
S "whitespace"
= comment* s
CDO "<!--"
= comment* "<!--"
CDC "-->"
= comment* "-->"
INCLUDES "~="
= comment* "~="
DASHMATCH "|="
= comment* "|="
STRING "string"
= comment* string:string { return string; }
IDENT "identifier"
= comment* ident:ident { return ident; }
HASH "hash"
= comment* "#" name:name { return "#" + name; }
IMPORT_SYM "@import"
= comment* "@" I M P O R T
PAGE_SYM "@page"
= comment* "@" P A G E
MEDIA_SYM "@media"
= comment* "@" M E D I A
CHARSET_SYM "@charset"
= comment* "@charset "
/* We use |s| instead of |w| here to avoid infinite recursion. */
IMPORTANT_SYM "!important"
= comment* "!" (s / comment)* I M P O R T A N T
EMS "length"
= comment* value:num E M { return { value: value, unit: "em" }; }
EXS "length"
= comment* value:num E X { return { value: value, unit: "ex" }; }
LENGTH "length"
= comment* value:num P X { return { value: value, unit: "px" }; }
/ comment* value:num C M { return { value: value, unit: "cm" }; }
/ comment* value:num M M { return { value: value, unit: "mm" }; }
/ comment* value:num I N { return { value: value, unit: "in" }; }
/ comment* value:num P T { return { value: value, unit: "pt" }; }
/ comment* value:num P C { return { value: value, unit: "pc" }; }
ANGLE "angle"
= comment* value:num D E G { return { value: value, unit: "deg" }; }
/ comment* value:num R A D { return { value: value, unit: "rad" }; }
/ comment* value:num G R A D { return { value: value, unit: "grad" }; }
TIME "time"
= comment* value:num M S_ { return { value: value, unit: "ms" }; }
/ comment* value:num S_ { return { value: value, unit: "s" }; }
FREQ "frequency"
= comment* value:num H Z { return { value: value, unit: "hz" }; }
/ comment* value:num K H Z { return { value: value, unit: "kh" }; }
PERCENTAGE "percentage"
= comment* value:num "%" { return { value: value, unit: "%" }; }
NUMBER "number"
= comment* value:num { return { value: value, unit: null }; }
URI "uri"
= comment* U R L "("i w url:string w ")" { return url; }
/ comment* U R L "("i w url:url w ")" { return url; }
FUNCTION "function"
= comment* name:ident "(" { return name; }

1362
node_modules/pegjs/examples/javascript.pegjs generated vendored Normal file

File diff suppressed because it is too large Load Diff

132
node_modules/pegjs/examples/json.pegjs generated vendored Normal file
View File

@@ -0,0 +1,132 @@
/*
* JSON Grammar
* ============
*
* Based on the grammar from RFC 7159 [1].
*
* Note that JSON is also specified in ECMA-262 [2], ECMA-404 [3], and on the
* JSON website [4] (somewhat informally). The RFC seems the most authoritative
* source, which is confirmed e.g. by [5].
*
* [1] http://tools.ietf.org/html/rfc7159
* [2] http://www.ecma-international.org/publications/standards/Ecma-262.htm
* [3] http://www.ecma-international.org/publications/standards/Ecma-404.htm
* [4] http://json.org/
* [5] https://www.tbray.org/ongoing/When/201x/2014/03/05/RFC7159-JSON
*/
/* ----- 2. JSON Grammar ----- */
JSON_text
= ws value:value ws { return value; }
begin_array = ws "[" ws
begin_object = ws "{" ws
end_array = ws "]" ws
end_object = ws "}" ws
name_separator = ws ":" ws
value_separator = ws "," ws
ws "whitespace" = [ \t\n\r]*
/* ----- 3. Values ----- */
value
= false
/ null
/ true
/ object
/ array
/ number
/ string
false = "false" { return false; }
null = "null" { return null; }
true = "true" { return true; }
/* ----- 4. Objects ----- */
object
= begin_object
members:(
head:member
tail:(value_separator m:member { return m; })*
{
var result = {}, i;
result[head.name] = head.value;
for (i = 0; i < tail.length; i++) {
result[tail[i].name] = tail[i].value;
}
return result;
}
)?
end_object
{ return members !== null ? members: {}; }
member
= name:string name_separator value:value {
return { name: name, value: value };
}
/* ----- 5. Arrays ----- */
array
= begin_array
values:(
head:value
tail:(value_separator v:value { return v; })*
{ return [head].concat(tail); }
)?
end_array
{ return values !== null ? values : []; }
/* ----- 6. Numbers ----- */
number "number"
= minus? int frac? exp? { return parseFloat(text()); }
decimal_point = "."
digit1_9 = [1-9]
e = [eE]
exp = e (minus / plus)? DIGIT+
frac = decimal_point DIGIT+
int = zero / (digit1_9 DIGIT*)
minus = "-"
plus = "+"
zero = "0"
/* ----- 7. Strings ----- */
string "string"
= quotation_mark chars:char* quotation_mark { return chars.join(""); }
char
= unescaped
/ escape
sequence:(
'"'
/ "\\"
/ "/"
/ "b" { return "\b"; }
/ "f" { return "\f"; }
/ "n" { return "\n"; }
/ "r" { return "\r"; }
/ "t" { return "\t"; }
/ "u" digits:$(HEXDIG HEXDIG HEXDIG HEXDIG) {
return String.fromCharCode(parseInt(digits, 16));
}
)
{ return sequence; }
escape = "\\"
quotation_mark = '"'
unescaped = [^\0-\x1F\x22\x5C]
/* ----- Core ABNF Rules ----- */
/* See RFC 4234, Appendix B (http://tools.ietf.org/html/rfc4627). */
DIGIT = [0-9]
HEXDIG = [0-9a-f]i

65
node_modules/pegjs/lib/compiler/asts.js generated vendored Normal file
View File

@@ -0,0 +1,65 @@
"use strict";
var arrays = require("../utils/arrays"),
visitor = require("./visitor");
/* AST utilities. */
var asts = {
findRule: function(ast, name) {
return arrays.find(ast.rules, function(r) { return r.name === name; });
},
indexOfRule: function(ast, name) {
return arrays.indexOf(ast.rules, function(r) { return r.name === name; });
},
alwaysConsumesOnSuccess: function(ast, node) {
function consumesTrue() { return true; }
function consumesFalse() { return false; }
function consumesExpression(node) {
return consumes(node.expression);
}
var consumes = visitor.build({
rule: consumesExpression,
named: consumesExpression,
choice: function(node) {
return arrays.every(node.alternatives, consumes);
},
action: consumesExpression,
sequence: function(node) {
return arrays.some(node.elements, consumes);
},
labeled: consumesExpression,
text: consumesExpression,
simple_and: consumesFalse,
simple_not: consumesFalse,
optional: consumesFalse,
zero_or_more: consumesFalse,
one_or_more: consumesExpression,
group: consumesExpression,
semantic_and: consumesFalse,
semantic_not: consumesFalse,
rule_ref: function(node) {
return consumes(asts.findRule(ast, node.name));
},
literal: function(node) {
return node.value !== "";
},
"class": consumesTrue,
any: consumesTrue
});
return consumes(node);
}
};
module.exports = asts;

73
node_modules/pegjs/lib/compiler/index.js generated vendored Normal file
View File

@@ -0,0 +1,73 @@
"use strict";
var arrays = require("../utils/arrays"),
objects = require("../utils/objects");
var compiler = {
/*
* AST node visitor builder. Useful mainly for plugins which manipulate the
* AST.
*/
visitor: require("./visitor"),
/*
* Compiler passes.
*
* Each pass is a function that is passed the AST. It can perform checks on it
* or modify it as needed. If the pass encounters a semantic error, it throws
* |peg.GrammarError|.
*/
passes: {
check: {
reportUndefinedRules: require("./passes/report-undefined-rules"),
reportDuplicateRules: require("./passes/report-duplicate-rules"),
reportDuplicateLabels: require("./passes/report-duplicate-labels"),
reportInfiniteRecursion: require("./passes/report-infinite-recursion"),
reportInfiniteRepetition: require("./passes/report-infinite-repetition")
},
transform: {
removeProxyRules: require("./passes/remove-proxy-rules")
},
generate: {
generateBytecode: require("./passes/generate-bytecode"),
generateJS: require("./passes/generate-js")
}
},
/*
* Generates a parser from a specified grammar AST. Throws |peg.GrammarError|
* if the AST contains a semantic error. Note that not all errors are detected
* during the generation and some may protrude to the generated parser and
* cause its malfunction.
*/
compile: function(ast, passes, options) {
options = options !== void 0 ? options : {};
var stage;
options = objects.clone(options);
objects.defaults(options, {
allowedStartRules: [ast.rules[0].name],
cache: false,
dependencies: {},
exportVar: null,
format: "bare",
optimize: "speed",
output: "parser",
trace: false
});
for (stage in passes) {
if (passes.hasOwnProperty(stage)) {
arrays.each(passes[stage], function(p) { p(ast, options); });
}
}
switch (options.output) {
case "parser": return eval(ast.code);
case "source": return ast.code;
}
}
};
module.exports = compiler;

58
node_modules/pegjs/lib/compiler/js.js generated vendored Normal file
View File

@@ -0,0 +1,58 @@
"use strict";
function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }
/* JavaScript code generation helpers. */
var js = {
stringEscape: function(s) {
/*
* ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a string
* literal except for the closing quote character, backslash, carriage
* return, line separator, paragraph separator, and line feed. Any character
* may appear in the form of an escape sequence.
*
* For portability, we also escape all control and non-ASCII characters.
* Note that the "\v" escape sequence is not used because IE does not like
* it.
*/
return s
.replace(/\\/g, '\\\\') // backslash
.replace(/"/g, '\\"') // closing double quote
.replace(/\0/g, '\\0') // null
.replace(/\x08/g, '\\b') // backspace
.replace(/\t/g, '\\t') // horizontal tab
.replace(/\n/g, '\\n') // line feed
.replace(/\f/g, '\\f') // form feed
.replace(/\r/g, '\\r') // carriage return
.replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
.replace(/[\x10-\x1F\x7F-\xFF]/g, function(ch) { return '\\x' + hex(ch); })
.replace(/[\u0100-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); })
.replace(/[\u1000-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); });
},
regexpClassEscape: function(s) {
/*
* Based on ECMA-262, 5th ed., 7.8.5 & 15.10.1.
*
* For portability, we also escape all control and non-ASCII characters.
*/
return s
.replace(/\\/g, '\\\\') // backslash
.replace(/\//g, '\\/') // closing slash
.replace(/\]/g, '\\]') // closing bracket
.replace(/\^/g, '\\^') // caret
.replace(/-/g, '\\-') // dash
.replace(/\0/g, '\\0') // null
.replace(/\t/g, '\\t') // horizontal tab
.replace(/\n/g, '\\n') // line feed
.replace(/\v/g, '\\x0B') // vertical tab
.replace(/\f/g, '\\f') // form feed
.replace(/\r/g, '\\r') // carriage return
.replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
.replace(/[\x10-\x1F\x7F-\xFF]/g, function(ch) { return '\\x' + hex(ch); })
.replace(/[\u0100-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); })
.replace(/[\u1000-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); });
}
};
module.exports = js;

54
node_modules/pegjs/lib/compiler/opcodes.js generated vendored Normal file
View File

@@ -0,0 +1,54 @@
"use strict";
/* Bytecode instruction opcodes. */
var opcodes = {
/* Stack Manipulation */
PUSH: 0, // PUSH c
PUSH_UNDEFINED: 1, // PUSH_UNDEFINED
PUSH_NULL: 2, // PUSH_NULL
PUSH_FAILED: 3, // PUSH_FAILED
PUSH_EMPTY_ARRAY: 4, // PUSH_EMPTY_ARRAY
PUSH_CURR_POS: 5, // PUSH_CURR_POS
POP: 6, // POP
POP_CURR_POS: 7, // POP_CURR_POS
POP_N: 8, // POP_N n
NIP: 9, // NIP
APPEND: 10, // APPEND
WRAP: 11, // WRAP n
TEXT: 12, // TEXT
/* Conditions and Loops */
IF: 13, // IF t, f
IF_ERROR: 14, // IF_ERROR t, f
IF_NOT_ERROR: 15, // IF_NOT_ERROR t, f
WHILE_NOT_ERROR: 16, // WHILE_NOT_ERROR b
/* Matching */
MATCH_ANY: 17, // MATCH_ANY a, f, ...
MATCH_STRING: 18, // MATCH_STRING s, a, f, ...
MATCH_STRING_IC: 19, // MATCH_STRING_IC s, a, f, ...
MATCH_REGEXP: 20, // MATCH_REGEXP r, a, f, ...
ACCEPT_N: 21, // ACCEPT_N n
ACCEPT_STRING: 22, // ACCEPT_STRING s
FAIL: 23, // FAIL e
/* Calls */
LOAD_SAVED_POS: 24, // LOAD_SAVED_POS p
UPDATE_SAVED_POS: 25, // UPDATE_SAVED_POS
CALL: 26, // CALL f, n, pc, p1, p2, ..., pN
/* Rules */
RULE: 27, // RULE r
/* Failure Reporting */
SILENT_FAILS_ON: 28, // SILENT_FAILS_ON
SILENT_FAILS_OFF: 29 // SILENT_FAILS_OFF
};
module.exports = opcodes;

View File

@@ -0,0 +1,631 @@
"use strict";
var arrays = require("../../utils/arrays"),
objects = require("../../utils/objects"),
asts = require("../asts"),
visitor = require("../visitor"),
op = require("../opcodes"),
js = require("../js");
/* Generates bytecode.
*
* Instructions
* ============
*
* Stack Manipulation
* ------------------
*
* [0] PUSH c
*
* stack.push(consts[c]);
*
* [1] PUSH_UNDEFINED
*
* stack.push(undefined);
*
* [2] PUSH_NULL
*
* stack.push(null);
*
* [3] PUSH_FAILED
*
* stack.push(FAILED);
*
* [4] PUSH_EMPTY_ARRAY
*
* stack.push([]);
*
* [5] PUSH_CURR_POS
*
* stack.push(currPos);
*
* [6] POP
*
* stack.pop();
*
* [7] POP_CURR_POS
*
* currPos = stack.pop();
*
* [8] POP_N n
*
* stack.pop(n);
*
* [9] NIP
*
* value = stack.pop();
* stack.pop();
* stack.push(value);
*
* [10] APPEND
*
* value = stack.pop();
* array = stack.pop();
* array.push(value);
* stack.push(array);
*
* [11] WRAP n
*
* stack.push(stack.pop(n));
*
* [12] TEXT
*
* stack.push(input.substring(stack.pop(), currPos));
*
* Conditions and Loops
* --------------------
*
* [13] IF t, f
*
* if (stack.top()) {
* interpret(ip + 3, ip + 3 + t);
* } else {
* interpret(ip + 3 + t, ip + 3 + t + f);
* }
*
* [14] IF_ERROR t, f
*
* if (stack.top() === FAILED) {
* interpret(ip + 3, ip + 3 + t);
* } else {
* interpret(ip + 3 + t, ip + 3 + t + f);
* }
*
* [15] IF_NOT_ERROR t, f
*
* if (stack.top() !== FAILED) {
* interpret(ip + 3, ip + 3 + t);
* } else {
* interpret(ip + 3 + t, ip + 3 + t + f);
* }
*
* [16] WHILE_NOT_ERROR b
*
* while(stack.top() !== FAILED) {
* interpret(ip + 2, ip + 2 + b);
* }
*
* Matching
* --------
*
* [17] MATCH_ANY a, f, ...
*
* if (input.length > currPos) {
* interpret(ip + 3, ip + 3 + a);
* } else {
* interpret(ip + 3 + a, ip + 3 + a + f);
* }
*
* [18] MATCH_STRING s, a, f, ...
*
* if (input.substr(currPos, consts[s].length) === consts[s]) {
* interpret(ip + 4, ip + 4 + a);
* } else {
* interpret(ip + 4 + a, ip + 4 + a + f);
* }
*
* [19] MATCH_STRING_IC s, a, f, ...
*
* if (input.substr(currPos, consts[s].length).toLowerCase() === consts[s]) {
* interpret(ip + 4, ip + 4 + a);
* } else {
* interpret(ip + 4 + a, ip + 4 + a + f);
* }
*
* [20] MATCH_REGEXP r, a, f, ...
*
* if (consts[r].test(input.charAt(currPos))) {
* interpret(ip + 4, ip + 4 + a);
* } else {
* interpret(ip + 4 + a, ip + 4 + a + f);
* }
*
* [21] ACCEPT_N n
*
* stack.push(input.substring(currPos, n));
* currPos += n;
*
* [22] ACCEPT_STRING s
*
* stack.push(consts[s]);
* currPos += consts[s].length;
*
* [23] FAIL e
*
* stack.push(FAILED);
* fail(consts[e]);
*
* Calls
* -----
*
* [24] LOAD_SAVED_POS p
*
* savedPos = stack[p];
*
* [25] UPDATE_SAVED_POS
*
* savedPos = currPos;
*
* [26] CALL f, n, pc, p1, p2, ..., pN
*
* value = consts[f](stack[p1], ..., stack[pN]);
* stack.pop(n);
* stack.push(value);
*
* Rules
* -----
*
* [27] RULE r
*
* stack.push(parseRule(r));
*
* Failure Reporting
* -----------------
*
* [28] SILENT_FAILS_ON
*
* silentFails++;
*
* [29] SILENT_FAILS_OFF
*
* silentFails--;
*/
function generateBytecode(ast) {
var consts = [];
function addConst(value) {
var index = arrays.indexOf(consts, value);
return index === -1 ? consts.push(value) - 1 : index;
}
function addFunctionConst(params, code) {
return addConst(
"function(" + params.join(", ") + ") {" + code + "}"
);
}
function buildSequence() {
return Array.prototype.concat.apply([], arguments);
}
function buildCondition(condCode, thenCode, elseCode) {
return condCode.concat(
[thenCode.length, elseCode.length],
thenCode,
elseCode
);
}
function buildLoop(condCode, bodyCode) {
return condCode.concat([bodyCode.length], bodyCode);
}
function buildCall(functionIndex, delta, env, sp) {
var params = arrays.map(objects.values(env), function(p) { return sp - p; });
return [op.CALL, functionIndex, delta, params.length].concat(params);
}
function buildSimplePredicate(expression, negative, context) {
return buildSequence(
[op.PUSH_CURR_POS],
[op.SILENT_FAILS_ON],
generate(expression, {
sp: context.sp + 1,
env: objects.clone(context.env),
action: null
}),
[op.SILENT_FAILS_OFF],
buildCondition(
[negative ? op.IF_ERROR : op.IF_NOT_ERROR],
buildSequence(
[op.POP],
[negative ? op.POP : op.POP_CURR_POS],
[op.PUSH_UNDEFINED]
),
buildSequence(
[op.POP],
[negative ? op.POP_CURR_POS : op.POP],
[op.PUSH_FAILED]
)
)
);
}
function buildSemanticPredicate(code, negative, context) {
var functionIndex = addFunctionConst(objects.keys(context.env), code);
return buildSequence(
[op.UPDATE_SAVED_POS],
buildCall(functionIndex, 0, context.env, context.sp),
buildCondition(
[op.IF],
buildSequence(
[op.POP],
negative ? [op.PUSH_FAILED] : [op.PUSH_UNDEFINED]
),
buildSequence(
[op.POP],
negative ? [op.PUSH_UNDEFINED] : [op.PUSH_FAILED]
)
)
);
}
function buildAppendLoop(expressionCode) {
return buildLoop(
[op.WHILE_NOT_ERROR],
buildSequence([op.APPEND], expressionCode)
);
}
var generate = visitor.build({
grammar: function(node) {
arrays.each(node.rules, generate);
node.consts = consts;
},
rule: function(node) {
node.bytecode = generate(node.expression, {
sp: -1, // stack pointer
env: { }, // mapping of label names to stack positions
action: null // action nodes pass themselves to children here
});
},
named: function(node, context) {
var nameIndex = addConst(
'peg$otherExpectation("' + js.stringEscape(node.name) + '")'
);
/*
* The code generated below is slightly suboptimal because |FAIL| pushes
* to the stack, so we need to stick a |POP| in front of it. We lack a
* dedicated instruction that would just report the failure and not touch
* the stack.
*/
return buildSequence(
[op.SILENT_FAILS_ON],
generate(node.expression, context),
[op.SILENT_FAILS_OFF],
buildCondition([op.IF_ERROR], [op.FAIL, nameIndex], [])
);
},
choice: function(node, context) {
function buildAlternativesCode(alternatives, context) {
return buildSequence(
generate(alternatives[0], {
sp: context.sp,
env: objects.clone(context.env),
action: null
}),
alternatives.length > 1
? buildCondition(
[op.IF_ERROR],
buildSequence(
[op.POP],
buildAlternativesCode(alternatives.slice(1), context)
),
[]
)
: []
);
}
return buildAlternativesCode(node.alternatives, context);
},
action: function(node, context) {
var env = objects.clone(context.env),
emitCall = node.expression.type !== "sequence"
|| node.expression.elements.length === 0,
expressionCode = generate(node.expression, {
sp: context.sp + (emitCall ? 1 : 0),
env: env,
action: node
}),
functionIndex = addFunctionConst(objects.keys(env), node.code);
return emitCall
? buildSequence(
[op.PUSH_CURR_POS],
expressionCode,
buildCondition(
[op.IF_NOT_ERROR],
buildSequence(
[op.LOAD_SAVED_POS, 1],
buildCall(functionIndex, 1, env, context.sp + 2)
),
[]
),
[op.NIP]
)
: expressionCode;
},
sequence: function(node, context) {
function buildElementsCode(elements, context) {
var processedCount, functionIndex;
if (elements.length > 0) {
processedCount = node.elements.length - elements.slice(1).length;
return buildSequence(
generate(elements[0], {
sp: context.sp,
env: context.env,
action: null
}),
buildCondition(
[op.IF_NOT_ERROR],
buildElementsCode(elements.slice(1), {
sp: context.sp + 1,
env: context.env,
action: context.action
}),
buildSequence(
processedCount > 1 ? [op.POP_N, processedCount] : [op.POP],
[op.POP_CURR_POS],
[op.PUSH_FAILED]
)
)
);
} else {
if (context.action) {
functionIndex = addFunctionConst(
objects.keys(context.env),
context.action.code
);
return buildSequence(
[op.LOAD_SAVED_POS, node.elements.length],
buildCall(
functionIndex,
node.elements.length,
context.env,
context.sp
),
[op.NIP]
);
} else {
return buildSequence([op.WRAP, node.elements.length], [op.NIP]);
}
}
}
return buildSequence(
[op.PUSH_CURR_POS],
buildElementsCode(node.elements, {
sp: context.sp + 1,
env: context.env,
action: context.action
})
);
},
labeled: function(node, context) {
var env = objects.clone(context.env);
context.env[node.label] = context.sp + 1;
return generate(node.expression, {
sp: context.sp,
env: env,
action: null
});
},
text: function(node, context) {
return buildSequence(
[op.PUSH_CURR_POS],
generate(node.expression, {
sp: context.sp + 1,
env: objects.clone(context.env),
action: null
}),
buildCondition(
[op.IF_NOT_ERROR],
buildSequence([op.POP], [op.TEXT]),
[op.NIP]
)
);
},
simple_and: function(node, context) {
return buildSimplePredicate(node.expression, false, context);
},
simple_not: function(node, context) {
return buildSimplePredicate(node.expression, true, context);
},
optional: function(node, context) {
return buildSequence(
generate(node.expression, {
sp: context.sp,
env: objects.clone(context.env),
action: null
}),
buildCondition(
[op.IF_ERROR],
buildSequence([op.POP], [op.PUSH_NULL]),
[]
)
);
},
zero_or_more: function(node, context) {
var expressionCode = generate(node.expression, {
sp: context.sp + 1,
env: objects.clone(context.env),
action: null
});
return buildSequence(
[op.PUSH_EMPTY_ARRAY],
expressionCode,
buildAppendLoop(expressionCode),
[op.POP]
);
},
one_or_more: function(node, context) {
var expressionCode = generate(node.expression, {
sp: context.sp + 1,
env: objects.clone(context.env),
action: null
});
return buildSequence(
[op.PUSH_EMPTY_ARRAY],
expressionCode,
buildCondition(
[op.IF_NOT_ERROR],
buildSequence(buildAppendLoop(expressionCode), [op.POP]),
buildSequence([op.POP], [op.POP], [op.PUSH_FAILED])
)
);
},
group: function(node, context) {
return generate(node.expression, {
sp: context.sp,
env: objects.clone(context.env),
action: null
});
},
semantic_and: function(node, context) {
return buildSemanticPredicate(node.code, false, context);
},
semantic_not: function(node, context) {
return buildSemanticPredicate(node.code, true, context);
},
rule_ref: function(node) {
return [op.RULE, asts.indexOfRule(ast, node.name)];
},
literal: function(node) {
var stringIndex, expectedIndex;
if (node.value.length > 0) {
stringIndex = addConst('"'
+ js.stringEscape(
node.ignoreCase ? node.value.toLowerCase() : node.value
)
+ '"'
);
expectedIndex = addConst(
'peg$literalExpectation('
+ '"' + js.stringEscape(node.value) + '", '
+ node.ignoreCase
+ ')'
);
/*
* For case-sensitive strings the value must match the beginning of the
* remaining input exactly. As a result, we can use |ACCEPT_STRING| and
* save one |substr| call that would be needed if we used |ACCEPT_N|.
*/
return buildCondition(
node.ignoreCase
? [op.MATCH_STRING_IC, stringIndex]
: [op.MATCH_STRING, stringIndex],
node.ignoreCase
? [op.ACCEPT_N, node.value.length]
: [op.ACCEPT_STRING, stringIndex],
[op.FAIL, expectedIndex]
);
} else {
stringIndex = addConst('""');
return [op.PUSH, stringIndex];
}
},
"class": function(node) {
var regexp, parts, regexpIndex, expectedIndex;
if (node.parts.length > 0) {
regexp = '/^['
+ (node.inverted ? '^' : '')
+ arrays.map(node.parts, function(part) {
return part instanceof Array
? js.regexpClassEscape(part[0])
+ '-'
+ js.regexpClassEscape(part[1])
: js.regexpClassEscape(part);
}).join('')
+ ']/' + (node.ignoreCase ? 'i' : '');
} else {
/*
* IE considers regexps /[]/ and /[^]/ as syntactically invalid, so we
* translate them into equivalents it can handle.
*/
regexp = node.inverted ? '/^[\\S\\s]/' : '/^(?!)/';
}
parts = '['
+ arrays.map(node.parts, function(part) {
return part instanceof Array
? '["' + js.stringEscape(part[0]) + '", "' + js.stringEscape(part[1]) + '"]'
: '"' + js.stringEscape(part) + '"';
}).join(', ')
+ ']';
regexpIndex = addConst(regexp);
expectedIndex = addConst(
'peg$classExpectation('
+ parts + ', '
+ node.inverted + ', '
+ node.ignoreCase
+ ')'
);
return buildCondition(
[op.MATCH_REGEXP, regexpIndex],
[op.ACCEPT_N, 1],
[op.FAIL, expectedIndex]
);
},
any: function() {
var expectedIndex = addConst('peg$anyExpectation()');
return buildCondition(
[op.MATCH_ANY],
[op.ACCEPT_N, 1],
[op.FAIL, expectedIndex]
);
}
});
generate(ast);
}
module.exports = generateBytecode;

1394
node_modules/pegjs/lib/compiler/passes/generate-js.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,42 @@
"use strict";
var arrays = require("../../utils/arrays"),
visitor = require("../visitor");
/*
* Removes proxy rules -- that is, rules that only delegate to other rule.
*/
function removeProxyRules(ast, options) {
function isProxyRule(node) {
return node.type === "rule" && node.expression.type === "rule_ref";
}
function replaceRuleRefs(ast, from, to) {
var replace = visitor.build({
rule_ref: function(node) {
if (node.name === from) {
node.name = to;
}
}
});
replace(ast);
}
var indices = [];
arrays.each(ast.rules, function(rule, i) {
if (isProxyRule(rule)) {
replaceRuleRefs(ast, rule.name, rule.expression.name);
if (!arrays.contains(options.allowedStartRules, rule.name)) {
indices.push(i);
}
}
});
indices.reverse();
arrays.each(indices, function(i) { ast.rules.splice(i, 1); });
}
module.exports = removeProxyRules;

View File

@@ -0,0 +1,54 @@
"use strict";
var GrammarError = require("../../grammar-error"),
arrays = require("../../utils/arrays"),
objects = require("../../utils/objects"),
visitor = require("../visitor");
/* Checks that each label is defined only once within each scope. */
function reportDuplicateLabels(ast) {
function checkExpressionWithClonedEnv(node, env) {
check(node.expression, objects.clone(env));
}
var check = visitor.build({
rule: function(node) {
check(node.expression, { });
},
choice: function(node, env) {
arrays.each(node.alternatives, function(alternative) {
check(alternative, objects.clone(env));
});
},
action: checkExpressionWithClonedEnv,
labeled: function(node, env) {
if (env.hasOwnProperty(node.label)) {
throw new GrammarError(
"Label \"" + node.label + "\" is already defined "
+ "at line " + env[node.label].start.line + ", "
+ "column " + env[node.label].start.column + ".",
node.location
);
}
check(node.expression, env);
env[node.label] = node.location;
},
text: checkExpressionWithClonedEnv,
simple_and: checkExpressionWithClonedEnv,
simple_not: checkExpressionWithClonedEnv,
optional: checkExpressionWithClonedEnv,
zero_or_more: checkExpressionWithClonedEnv,
one_or_more: checkExpressionWithClonedEnv,
group: checkExpressionWithClonedEnv
});
check(ast);
}
module.exports = reportDuplicateLabels;

View File

@@ -0,0 +1,28 @@
"use strict";
var GrammarError = require("../../grammar-error"),
visitor = require("../visitor");
/* Checks that each rule is defined only once. */
function reportDuplicateRules(ast) {
var rules = {};
var check = visitor.build({
rule: function(node) {
if (rules.hasOwnProperty(node.name)) {
throw new GrammarError(
"Rule \"" + node.name + "\" is already defined "
+ "at line " + rules[node.name].start.line + ", "
+ "column " + rules[node.name].start.column + ".",
node.location
);
}
rules[node.name] = node.location;
}
});
check(ast);
}
module.exports = reportDuplicateRules;

View File

@@ -0,0 +1,57 @@
"use strict";
var arrays = require("../../utils/arrays"),
GrammarError = require("../../grammar-error"),
asts = require("../asts"),
visitor = require("../visitor");
/*
* Reports left recursion in the grammar, which prevents infinite recursion in
* the generated parser.
*
* Both direct and indirect recursion is detected. The pass also correctly
* reports cases like this:
*
* start = "a"? start
*
* In general, if a rule reference can be reached without consuming any input,
* it can lead to left recursion.
*/
function reportInfiniteRecursion(ast) {
var visitedRules = [];
var check = visitor.build({
rule: function(node) {
visitedRules.push(node.name);
check(node.expression);
visitedRules.pop(node.name);
},
sequence: function(node) {
arrays.every(node.elements, function(element) {
check(element);
return !asts.alwaysConsumesOnSuccess(ast, element);
});
},
rule_ref: function(node) {
if (arrays.contains(visitedRules, node.name)) {
visitedRules.push(node.name);
throw new GrammarError(
"Possible infinite loop when parsing (left recursion: "
+ visitedRules.join(" -> ")
+ ").",
node.location
);
}
check(asts.findRule(ast, node.name));
}
});
check(ast);
}
module.exports = reportInfiniteRecursion;

View File

@@ -0,0 +1,35 @@
"use strict";
var GrammarError = require("../../grammar-error"),
asts = require("../asts"),
visitor = require("../visitor");
/*
* Reports expressions that don't consume any input inside |*| or |+| in the
* grammar, which prevents infinite loops in the generated parser.
*/
function reportInfiniteRepetition(ast) {
var check = visitor.build({
zero_or_more: function(node) {
if (!asts.alwaysConsumesOnSuccess(ast, node.expression)) {
throw new GrammarError(
"Possible infinite loop when parsing (repetition used with an expression that may not consume any input).",
node.location
);
}
},
one_or_more: function(node) {
if (!asts.alwaysConsumesOnSuccess(ast, node.expression)) {
throw new GrammarError(
"Possible infinite loop when parsing (repetition used with an expression that may not consume any input).",
node.location
);
}
}
});
check(ast);
}
module.exports = reportInfiniteRepetition;

View File

@@ -0,0 +1,23 @@
"use strict";
var GrammarError = require("../../grammar-error"),
asts = require("../asts"),
visitor = require("../visitor");
/* Checks that all referenced rules exist. */
function reportUndefinedRules(ast) {
var check = visitor.build({
rule_ref: function(node) {
if (!asts.findRule(ast, node.name)) {
throw new GrammarError(
"Rule \"" + node.name + "\" is not defined.",
node.location
);
}
}
});
check(ast);
}
module.exports = reportUndefinedRules;

72
node_modules/pegjs/lib/compiler/visitor.js generated vendored Normal file
View File

@@ -0,0 +1,72 @@
"use strict";
var objects = require("../utils/objects"),
arrays = require("../utils/arrays");
/* Simple AST node visitor builder. */
var visitor = {
build: function(functions) {
function visit(node) {
return functions[node.type].apply(null, arguments);
}
function visitNop() { }
function visitExpression(node) {
var extraArgs = Array.prototype.slice.call(arguments, 1);
visit.apply(null, [node.expression].concat(extraArgs));
}
function visitChildren(property) {
return function(node) {
var extraArgs = Array.prototype.slice.call(arguments, 1);
arrays.each(node[property], function(child) {
visit.apply(null, [child].concat(extraArgs));
});
};
}
var DEFAULT_FUNCTIONS = {
grammar: function(node) {
var extraArgs = Array.prototype.slice.call(arguments, 1);
if (node.initializer) {
visit.apply(null, [node.initializer].concat(extraArgs));
}
arrays.each(node.rules, function(rule) {
visit.apply(null, [rule].concat(extraArgs));
});
},
initializer: visitNop,
rule: visitExpression,
named: visitExpression,
choice: visitChildren("alternatives"),
action: visitExpression,
sequence: visitChildren("elements"),
labeled: visitExpression,
text: visitExpression,
simple_and: visitExpression,
simple_not: visitExpression,
optional: visitExpression,
zero_or_more: visitExpression,
one_or_more: visitExpression,
group: visitExpression,
semantic_and: visitNop,
semantic_not: visitNop,
rule_ref: visitNop,
literal: visitNop,
"class": visitNop,
any: visitNop
};
objects.defaults(functions, DEFAULT_FUNCTIONS);
return visit;
}
};
module.exports = visitor;

18
node_modules/pegjs/lib/grammar-error.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
"use strict";
var classes = require("./utils/classes");
/* Thrown when the grammar contains an error. */
function GrammarError(message, location) {
this.name = "GrammarError";
this.message = message;
this.location = location;
if (typeof Error.captureStackTrace === "function") {
Error.captureStackTrace(this, GrammarError);
}
}
classes.subclass(GrammarError, Error);
module.exports = GrammarError;

5040
node_modules/pegjs/lib/parser.js generated vendored Normal file

File diff suppressed because one or more lines are too long

58
node_modules/pegjs/lib/peg.js generated vendored Normal file
View File

@@ -0,0 +1,58 @@
"use strict";
var arrays = require("./utils/arrays"),
objects = require("./utils/objects");
var peg = {
/* PEG.js version (uses semantic versioning). */
VERSION: "0.10.0",
GrammarError: require("./grammar-error"),
parser: require("./parser"),
compiler: require("./compiler"),
/*
* Generates a parser from a specified grammar and returns it.
*
* The grammar must be a string in the format described by the metagramar in
* the parser.pegjs file.
*
* Throws |peg.parser.SyntaxError| if the grammar contains a syntax error or
* |peg.GrammarError| if it contains a semantic error. Note that not all
* errors are detected during the generation and some may protrude to the
* generated parser and cause its malfunction.
*/
generate: function(grammar, options) {
options = options !== void 0 ? options : {};
function convertPasses(passes) {
var converted = {}, stage;
for (stage in passes) {
if (passes.hasOwnProperty(stage)) {
converted[stage] = objects.values(passes[stage]);
}
}
return converted;
}
options = objects.clone(options);
var plugins = "plugins" in options ? options.plugins : [],
config = {
parser: peg.parser,
passes: convertPasses(peg.compiler.passes)
};
arrays.each(plugins, function(p) { p.use(config, options); });
return peg.compiler.compile(
config.parser.parse(grammar),
config.passes,
options
);
}
};
module.exports = peg;

108
node_modules/pegjs/lib/utils/arrays.js generated vendored Normal file
View File

@@ -0,0 +1,108 @@
"use strict";
/* Array utilities. */
var arrays = {
range: function(start, stop) {
var length = stop - start,
result = new Array(length),
i, j;
for (i = 0, j = start; i < length; i++, j++) {
result[i] = j;
}
return result;
},
find: function(array, valueOrPredicate) {
var length = array.length, i;
if (typeof valueOrPredicate === "function") {
for (i = 0; i < length; i++) {
if (valueOrPredicate(array[i])) {
return array[i];
}
}
} else {
for (i = 0; i < length; i++) {
if (array[i] === valueOrPredicate) {
return array[i];
}
}
}
},
indexOf: function(array, valueOrPredicate) {
var length = array.length, i;
if (typeof valueOrPredicate === "function") {
for (i = 0; i < length; i++) {
if (valueOrPredicate(array[i])) {
return i;
}
}
} else {
for (i = 0; i < length; i++) {
if (array[i] === valueOrPredicate) {
return i;
}
}
}
return -1;
},
contains: function(array, valueOrPredicate) {
return arrays.indexOf(array, valueOrPredicate) !== -1;
},
each: function(array, iterator) {
var length = array.length, i;
for (i = 0; i < length; i++) {
iterator(array[i], i);
}
},
map: function(array, iterator) {
var length = array.length,
result = new Array(length),
i;
for (i = 0; i < length; i++) {
result[i] = iterator(array[i], i);
}
return result;
},
pluck: function(array, key) {
return arrays.map(array, function (e) { return e[key]; });
},
every: function(array, predicate) {
var length = array.length, i;
for (i = 0; i < length; i++) {
if (!predicate(array[i])) {
return false;
}
}
return true;
},
some: function(array, predicate) {
var length = array.length, i;
for (i = 0; i < length; i++) {
if (predicate(array[i])) {
return true;
}
}
return false;
}
};
module.exports = arrays;

12
node_modules/pegjs/lib/utils/classes.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
"use strict";
/* Class utilities */
var classes = {
subclass: function(child, parent) {
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor();
}
};
module.exports = classes;

54
node_modules/pegjs/lib/utils/objects.js generated vendored Normal file
View File

@@ -0,0 +1,54 @@
"use strict";
/* Object utilities. */
var objects = {
keys: function(object) {
var result = [], key;
for (key in object) {
if (object.hasOwnProperty(key)) {
result.push(key);
}
}
return result;
},
values: function(object) {
var result = [], key;
for (key in object) {
if (object.hasOwnProperty(key)) {
result.push(object[key]);
}
}
return result;
},
clone: function(object) {
var result = {}, key;
for (key in object) {
if (object.hasOwnProperty(key)) {
result[key] = object[key];
}
}
return result;
},
defaults: function(object, defaults) {
var key;
for (key in defaults) {
if (defaults.hasOwnProperty(key)) {
if (!(key in object)) {
object[key] = defaults[key];
}
}
}
}
};
module.exports = objects;

124
node_modules/pegjs/package.json generated vendored Normal file
View File

@@ -0,0 +1,124 @@
{
"_args": [
[
"pegjs@^0.10.0",
"/home/bernhard/freifunk-app/node_modules/xcode"
]
],
"_from": "pegjs@>=0.10.0 <0.11.0",
"_id": "pegjs@0.10.0",
"_inCache": true,
"_installable": true,
"_location": "/pegjs",
"_nodeVersion": "6.0.0",
"_npmOperationalInternal": {
"host": "packages-16-east.internal.npmjs.com",
"tmp": "tmp/pegjs-0.10.0.tgz_1471590993207_0.5759401724208146"
},
"_npmUser": {
"email": "david@majda.cz",
"name": "dmajda"
},
"_npmVersion": "3.8.6",
"_phantomChildren": {},
"_requested": {
"name": "pegjs",
"raw": "pegjs@^0.10.0",
"rawSpec": "^0.10.0",
"scope": null,
"spec": ">=0.10.0 <0.11.0",
"type": "range"
},
"_requiredBy": [
"/xcode"
],
"_resolved": "https://registry.npmjs.org/pegjs/-/pegjs-0.10.0.tgz",
"_shasum": "cf8bafae6eddff4b5a7efb185269eaaf4610ddbd",
"_shrinkwrap": null,
"_spec": "pegjs@^0.10.0",
"_where": "/home/bernhard/freifunk-app/node_modules/xcode",
"author": {
"email": "david@majda.cz",
"name": "David Majda",
"url": "http://majda.cz/"
},
"bin": {
"pegjs": "bin/pegjs"
},
"bugs": {
"url": "https://github.com/pegjs/pegjs/issues"
},
"dependencies": {},
"description": "Parser generator for JavaScript",
"devDependencies": {
"browserify": "13.1.0",
"eslint": "2.13.1",
"http-server": "0.9.0",
"jasmine-node": "1.14.5",
"uglify-js": "2.7.0"
},
"directories": {},
"dist": {
"shasum": "cf8bafae6eddff4b5a7efb185269eaaf4610ddbd",
"tarball": "https://registry.npmjs.org/pegjs/-/pegjs-0.10.0.tgz"
},
"engines": {
"node": ">=0.10"
},
"files": [
"CHANGELOG.md",
"LICENSE",
"README.md",
"VERSION",
"bin/pegjs",
"examples/arithmetics.pegjs",
"examples/css.pegjs",
"examples/javascript.pegjs",
"examples/json.pegjs",
"lib/compiler/asts.js",
"lib/compiler/index.js",
"lib/compiler/js.js",
"lib/compiler/opcodes.js",
"lib/compiler/passes/generate-bytecode.js",
"lib/compiler/passes/generate-js.js",
"lib/compiler/passes/remove-proxy-rules.js",
"lib/compiler/passes/report-duplicate-labels.js",
"lib/compiler/passes/report-duplicate-rules.js",
"lib/compiler/passes/report-infinite-recursion.js",
"lib/compiler/passes/report-infinite-repetition.js",
"lib/compiler/passes/report-undefined-rules.js",
"lib/compiler/visitor.js",
"lib/grammar-error.js",
"lib/parser.js",
"lib/peg.js",
"lib/utils/arrays.js",
"lib/utils/classes.js",
"lib/utils/objects.js",
"package.json"
],
"gitHead": "671166bbe82150042b71d5756405c0ee067df961",
"homepage": "http://pegjs.org/",
"keywords": [
"PEG",
"parser generator"
],
"license": "MIT",
"main": "lib/peg",
"maintainers": [
{
"name": "dmajda",
"email": "david@majda.cz"
}
],
"name": "pegjs",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/pegjs/pegjs.git"
},
"scripts": {
"test": "make lint && make spec"
},
"version": "0.10.0"
}