aboutsummaryrefslogtreecommitdiff
path: root/cordova/node_modules/pegjs/lib/compiler/index.js
diff options
context:
space:
mode:
authorKumar Priyansh <[email protected]>2019-01-19 12:37:14 +0530
committerKumar Priyansh <[email protected]>2019-01-19 12:37:14 +0530
commitdcdfc94cb39dfe2c39925a0145ffa45e2d061c30 (patch)
tree4f6379d955555b298c0e7b83a67e264240ee5614 /cordova/node_modules/pegjs/lib/compiler/index.js
parent76f7b3678d3f1ff99c3935a774d420453b0c3cb9 (diff)
downloadWeatherApp-dcdfc94cb39dfe2c39925a0145ffa45e2d061c30.tar.xz
WeatherApp-dcdfc94cb39dfe2c39925a0145ffa45e2d061c30.zip
Initial Upload via GIT
Diffstat (limited to 'cordova/node_modules/pegjs/lib/compiler/index.js')
-rw-r--r--cordova/node_modules/pegjs/lib/compiler/index.js73
1 files changed, 73 insertions, 0 deletions
diff --git a/cordova/node_modules/pegjs/lib/compiler/index.js b/cordova/node_modules/pegjs/lib/compiler/index.js
new file mode 100644
index 0000000..1248598
--- /dev/null
+++ b/cordova/node_modules/pegjs/lib/compiler/index.js
@@ -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;