Talk about "undefined rules" instead of "missing rules" internally
The new terminology is more precise and in line with commonly used programming languages. The change involves mainly renaming related compiler pass and files associated with it.
This commit is contained in:
parent
e9cb23608d
commit
9717dc3417
|
@ -19,7 +19,7 @@ var compiler = {
|
|||
*/
|
||||
passes: {
|
||||
check: {
|
||||
reportMissingRules: require("./passes/report-missing-rules"),
|
||||
reportUndefinedRules: require("./passes/report-undefined-rules"),
|
||||
reportDuplicateRules: require("./passes/report-duplicate-rules"),
|
||||
reportDuplicateLabels: require("./passes/report-duplicate-labels"),
|
||||
reportLeftRecursion: require("./passes/report-left-recursion"),
|
||||
|
|
|
@ -5,7 +5,7 @@ var GrammarError = require("../../grammar-error"),
|
|||
visitor = require("../visitor");
|
||||
|
||||
/* Checks that all referenced rules exist. */
|
||||
function reportMissingRules(ast) {
|
||||
function reportUndefinedRules(ast) {
|
||||
var check = visitor.build({
|
||||
rule_ref: function(node) {
|
||||
if (!asts.findRule(ast, node.name)) {
|
||||
|
@ -20,4 +20,4 @@ function reportMissingRules(ast) {
|
|||
check(ast);
|
||||
}
|
||||
|
||||
module.exports = reportMissingRules;
|
||||
module.exports = reportUndefinedRules;
|
|
@ -31,7 +31,7 @@
|
|||
"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-missing-rules.js",
|
||||
"lib/compiler/passes/report-undefined-rules.js",
|
||||
"lib/compiler/visitor.js",
|
||||
"lib/grammar-error.js",
|
||||
"lib/parser.js",
|
||||
|
|
|
@ -16,7 +16,7 @@ describe("PEG.js API", function() {
|
|||
});
|
||||
|
||||
it("throws an exception on semantic error", function() {
|
||||
expect(function() { peg.generate('start = missing'); }).toThrow();
|
||||
expect(function() { peg.generate('start = undefined'); }).toThrow();
|
||||
});
|
||||
|
||||
describe("allowed start rules", function() {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<script src="helpers.js"></script>
|
||||
<script src="unit/parser.spec.js"></script>
|
||||
<script src="unit/compiler/passes/helpers.js"></script>
|
||||
<script src="unit/compiler/passes/report-missing-rules.spec.js"></script>
|
||||
<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>
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
/* global peg */
|
||||
|
||||
"use strict";
|
||||
|
||||
describe("compiler pass |reportMissingRules|", function() {
|
||||
var pass = peg.compiler.passes.check.reportMissingRules;
|
||||
|
||||
it("reports missing rules", function() {
|
||||
expect(pass).toReportError('start = missing', {
|
||||
message: 'Rule "missing" is not defined.',
|
||||
location: {
|
||||
start: { offset: 8, line: 1, column: 9 },
|
||||
end: { offset: 15, line: 1, column: 16 }
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
17
spec/unit/compiler/passes/report-undefined-rules.spec.js
Normal file
17
spec/unit/compiler/passes/report-undefined-rules.spec.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
/* global peg */
|
||||
|
||||
"use strict";
|
||||
|
||||
describe("compiler pass |reportUndefinedRules|", function() {
|
||||
var pass = peg.compiler.passes.check.reportUndefinedRules;
|
||||
|
||||
it("reports undefined rules", function() {
|
||||
expect(pass).toReportError('start = undefined', {
|
||||
message: 'Rule "undefined" is not defined.',
|
||||
location: {
|
||||
start: { offset: 8, line: 1, column: 9 },
|
||||
end: { offset: 17, line: 1, column: 18 }
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue