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:
David Majda 2016-07-29 15:16:56 +02:00
parent e9cb23608d
commit 9717dc3417
7 changed files with 23 additions and 23 deletions

View file

@ -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"),

View file

@ -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;

View file

@ -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",

View file

@ -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() {

View file

@ -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>

View file

@ -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 }
}
});
});
});

View 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 }
}
});
});
});