From ec8ede5bbec04be8bcb2a9b87daf3d29c3804a2a Mon Sep 17 00:00:00 2001 From: David Majda Date: Sun, 3 Jul 2016 18:01:39 +0200 Subject: [PATCH] Grammar error messages 3/3: Improve the left recursion message New wording is more explanatory. Part of #371. --- lib/compiler/passes/report-left-recursion.js | 2 +- spec/unit/compiler/passes/report-left-recursion.spec.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/compiler/passes/report-left-recursion.js b/lib/compiler/passes/report-left-recursion.js index de5b849..a3d153b 100644 --- a/lib/compiler/passes/report-left-recursion.js +++ b/lib/compiler/passes/report-left-recursion.js @@ -40,7 +40,7 @@ function reportLeftRecursion(ast) { visitedRules.push(node.name); throw new GrammarError( - "Possible left recursion detected (" + "Possible infinite loop when parsing (left recursion: " + visitedRules.join(" -> ") + ").", node.location diff --git a/spec/unit/compiler/passes/report-left-recursion.spec.js b/spec/unit/compiler/passes/report-left-recursion.spec.js index 9af0b3c..4087903 100644 --- a/spec/unit/compiler/passes/report-left-recursion.spec.js +++ b/spec/unit/compiler/passes/report-left-recursion.spec.js @@ -7,7 +7,7 @@ describe("compiler pass |reportLeftRecursion|", function() { it("reports direct left recursion", function() { expect(pass).toReportError('start = start', { - message: 'Possible left recursion detected (start -> start).', + message: 'Possible infinite loop when parsing (left recursion: start -> start).', location: { start: { offset: 8, line: 1, column: 9 }, end: { offset: 13, line: 1, column: 14 } @@ -20,7 +20,7 @@ describe("compiler pass |reportLeftRecursion|", function() { 'start = stop', 'stop = start' ].join("\n"), { - message: 'Possible left recursion detected (start -> stop -> start).', + message: 'Possible infinite loop when parsing (left recursion: start -> stop -> start).', location: { start: { offset: 21, line: 2, column: 9 }, end: { offset: 26, line: 2, column: 14 }