cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject [10/15] ios commit: Update bundled ios-sim to 6.0.0
Date Mon, 19 Jun 2017 00:27:56 GMT
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/4490abf2/node_modules/pegjs/lib/compiler/passes/report-infinite-recursion.js
----------------------------------------------------------------------
diff --git a/node_modules/pegjs/lib/compiler/passes/report-infinite-recursion.js b/node_modules/pegjs/lib/compiler/passes/report-infinite-recursion.js
new file mode 100644
index 0000000..1230a2f
--- /dev/null
+++ b/node_modules/pegjs/lib/compiler/passes/report-infinite-recursion.js
@@ -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;

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/4490abf2/node_modules/pegjs/lib/compiler/passes/report-infinite-repetition.js
----------------------------------------------------------------------
diff --git a/node_modules/pegjs/lib/compiler/passes/report-infinite-repetition.js b/node_modules/pegjs/lib/compiler/passes/report-infinite-repetition.js
new file mode 100644
index 0000000..e6f12c0
--- /dev/null
+++ b/node_modules/pegjs/lib/compiler/passes/report-infinite-repetition.js
@@ -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;

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/4490abf2/node_modules/pegjs/lib/compiler/passes/report-left-recursion.js
----------------------------------------------------------------------
diff --git a/node_modules/pegjs/lib/compiler/passes/report-left-recursion.js b/node_modules/pegjs/lib/compiler/passes/report-left-recursion.js
deleted file mode 100644
index 9745fce..0000000
--- a/node_modules/pegjs/lib/compiler/passes/report-left-recursion.js
+++ /dev/null
@@ -1,53 +0,0 @@
-"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 reportLeftRecursion(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.alwaysAdvancesOnSuccess(ast, element);
-      });
-    },
-
-    rule_ref: function(node) {
-      if (arrays.contains(visitedRules, node.name)) {
-        throw new GrammarError(
-          "Left recursion detected for rule \"" + node.name + "\".",
-          node.location
-        );
-      }
-
-      check(asts.findRule(ast, node.name));
-    }
-  });
-
-  check(ast);
-}
-
-module.exports = reportLeftRecursion;

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/4490abf2/node_modules/pegjs/lib/compiler/passes/report-missing-rules.js
----------------------------------------------------------------------
diff --git a/node_modules/pegjs/lib/compiler/passes/report-missing-rules.js b/node_modules/pegjs/lib/compiler/passes/report-missing-rules.js
deleted file mode 100644
index 476d84e..0000000
--- a/node_modules/pegjs/lib/compiler/passes/report-missing-rules.js
+++ /dev/null
@@ -1,23 +0,0 @@
-"use strict";
-
-var GrammarError = require("../../grammar-error"),
-    asts         = require("../asts"),
-    visitor      = require("../visitor");
-
-/* Checks that all referenced rules exist. */
-function reportMissingRules(ast) {
-  var check = visitor.build({
-    rule_ref: function(node) {
-      if (!asts.findRule(ast, node.name)) {
-        throw new GrammarError(
-          "Referenced rule \"" + node.name + "\" does not exist.",
-          node.location
-        );
-      }
-    }
-  });
-
-  check(ast);
-}
-
-module.exports = reportMissingRules;

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/4490abf2/node_modules/pegjs/lib/compiler/passes/report-undefined-rules.js
----------------------------------------------------------------------
diff --git a/node_modules/pegjs/lib/compiler/passes/report-undefined-rules.js b/node_modules/pegjs/lib/compiler/passes/report-undefined-rules.js
new file mode 100644
index 0000000..c71b03f
--- /dev/null
+++ b/node_modules/pegjs/lib/compiler/passes/report-undefined-rules.js
@@ -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;

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/4490abf2/node_modules/pegjs/lib/compiler/visitor.js
----------------------------------------------------------------------
diff --git a/node_modules/pegjs/lib/compiler/visitor.js b/node_modules/pegjs/lib/compiler/visitor.js
index 70e6f12..0a447bc 100644
--- a/node_modules/pegjs/lib/compiler/visitor.js
+++ b/node_modules/pegjs/lib/compiler/visitor.js
@@ -54,6 +54,7 @@ var visitor = {
           optional:     visitExpression,
           zero_or_more: visitExpression,
           one_or_more:  visitExpression,
+          group:        visitExpression,
           semantic_and: visitNop,
           semantic_not: visitNop,
           rule_ref:     visitNop,


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message