Grammar error messages 3/3: Improve the left recursion message

New wording is more explanatory.

Part of #371.
redux
David Majda 8 years ago
parent f5e43f842c
commit ec8ede5bbe

@ -40,7 +40,7 @@ function reportLeftRecursion(ast) {
visitedRules.push(node.name); visitedRules.push(node.name);
throw new GrammarError( throw new GrammarError(
"Possible left recursion detected (" "Possible infinite loop when parsing (left recursion: "
+ visitedRules.join(" -> ") + visitedRules.join(" -> ")
+ ").", + ").",
node.location node.location

@ -7,7 +7,7 @@ describe("compiler pass |reportLeftRecursion|", function() {
it("reports direct left recursion", function() { it("reports direct left recursion", function() {
expect(pass).toReportError('start = start', { expect(pass).toReportError('start = start', {
message: 'Possible left recursion detected (start -> start).', message: 'Possible infinite loop when parsing (left recursion: start -> start).',
location: { location: {
start: { offset: 8, line: 1, column: 9 }, start: { offset: 8, line: 1, column: 9 },
end: { offset: 13, line: 1, column: 14 } end: { offset: 13, line: 1, column: 14 }
@ -20,7 +20,7 @@ describe("compiler pass |reportLeftRecursion|", function() {
'start = stop', 'start = stop',
'stop = start' 'stop = start'
].join("\n"), { ].join("\n"), {
message: 'Possible left recursion detected (start -> stop -> start).', message: 'Possible infinite loop when parsing (left recursion: start -> stop -> start).',
location: { location: {
start: { offset: 21, line: 2, column: 9 }, start: { offset: 21, line: 2, column: 9 },
end: { offset: 26, line: 2, column: 14 } end: { offset: 26, line: 2, column: 14 }

Loading…
Cancel
Save