Align names of compiler passes that detect infinite loops

Rename compiler passes as follows:

  reportLeftRecursion -> reportInfiniteRecursion
  reportInfiniteLoops -> reportInfiniteRepetition

This reflects the fact that both passes detect different ways of causing
the same problem (possible infinite loop when parsing).
redux
David Majda 8 years ago
parent 9717dc3417
commit 67d85f2de8

@ -19,18 +19,18 @@ var compiler = {
*/
passes: {
check: {
reportUndefinedRules: require("./passes/report-undefined-rules"),
reportDuplicateRules: require("./passes/report-duplicate-rules"),
reportDuplicateLabels: require("./passes/report-duplicate-labels"),
reportLeftRecursion: require("./passes/report-left-recursion"),
reportInfiniteLoops: require("./passes/report-infinite-loops")
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")
removeProxyRules: require("./passes/remove-proxy-rules")
},
generate: {
generateBytecode: require("./passes/generate-bytecode"),
generateJS: require("./passes/generate-js")
generateBytecode: require("./passes/generate-bytecode"),
generateJS: require("./passes/generate-js")
}
},

@ -17,7 +17,7 @@ var arrays = require("../../utils/arrays"),
* In general, if a rule reference can be reached without consuming any input,
* it can lead to left recursion.
*/
function reportLeftRecursion(ast) {
function reportInfiniteRecursion(ast) {
var visitedRules = [];
var check = visitor.build({
@ -54,4 +54,4 @@ function reportLeftRecursion(ast) {
check(ast);
}
module.exports = reportLeftRecursion;
module.exports = reportInfiniteRecursion;

@ -8,7 +8,7 @@ var GrammarError = require("../../grammar-error"),
* Reports expressions that don't consume any input inside |*| or |+| in the
* grammar, which prevents infinite loops in the generated parser.
*/
function reportInfiniteLoops(ast) {
function reportInfiniteRepetition(ast) {
var check = visitor.build({
zero_or_more: function(node) {
if (!asts.alwaysConsumesOnSuccess(ast, node.expression)) {
@ -32,4 +32,4 @@ function reportInfiniteLoops(ast) {
check(ast);
}
module.exports = reportInfiniteLoops;
module.exports = reportInfiniteRepetition;

@ -29,8 +29,8 @@
"lib/compiler/passes/remove-proxy-rules.js",
"lib/compiler/passes/report-duplicate-rules.js",
"lib/compiler/passes/report-duplicate-labels.js",
"lib/compiler/passes/report-infinite-loops.js",
"lib/compiler/passes/report-left-recursion.js",
"lib/compiler/passes/report-infinite-repetition.js",
"lib/compiler/passes/report-infinite-recursion.js",
"lib/compiler/passes/report-undefined-rules.js",
"lib/compiler/visitor.js",
"lib/grammar-error.js",

@ -12,8 +12,8 @@
<script src="unit/compiler/passes/report-undefined-rules.spec.js"></script>
<script src="unit/compiler/passes/report-duplicate-rules.spec.js"></script>
<script src="unit/compiler/passes/report-duplicate-labels.spec.js"></script>
<script src="unit/compiler/passes/report-left-recursion.spec.js"></script>
<script src="unit/compiler/passes/report-infinite-loops.spec.js"></script>
<script src="unit/compiler/passes/report-infinite-recursion.spec.js"></script>
<script src="unit/compiler/passes/report-infinite-repetition.spec.js"></script>
<script src="unit/compiler/passes/remove-proxy-rules.spec.js"></script>
<script src="unit/compiler/passes/generate-bytecode.spec.js"></script>
<script src="api/pegjs-api.spec.js"></script>

@ -2,8 +2,8 @@
"use strict";
describe("compiler pass |reportLeftRecursion|", function() {
var pass = peg.compiler.passes.check.reportLeftRecursion;
describe("compiler pass |reportInfiniteRecursion|", function() {
var pass = peg.compiler.passes.check.reportInfiniteRecursion;
it("reports direct left recursion", function() {
expect(pass).toReportError('start = start', {

@ -2,8 +2,8 @@
"use strict";
describe("compiler pass |reportInfiniteLoops|", function() {
var pass = peg.compiler.passes.check.reportInfiniteLoops;
describe("compiler pass |reportInfiniteRepetition|", function() {
var pass = peg.compiler.passes.check.reportInfiniteRepetition;
it("reports infinite loops for zero_or_more", function() {
expect(pass).toReportError('start = ("")*', {
Loading…
Cancel
Save