bdf91b5941
This is purely a mechanical change, not taking advantage of block scope of "let" and "const". Minimizing variable scope will come in the next commit. In general, "var" is converted into "let" and "const" is used only for immutable variables of permanent character (generally spelled in ALL_CAPS). Using it for any immutable variable regardless on its permanence would feel confusing. Any code which is not transpiled and needs to run in ES6 environment (examples, code in grammars embedded in specs, ...) is kept unchanged. This is also true for code generated by PEG.js. See #442.
24 lines
536 B
JavaScript
24 lines
536 B
JavaScript
"use strict";
|
|
|
|
let GrammarError = require("../../grammar-error"),
|
|
asts = require("../asts"),
|
|
visitor = require("../visitor");
|
|
|
|
/* Checks that all referenced rules exist. */
|
|
function reportUndefinedRules(ast) {
|
|
let check = visitor.build({
|
|
rule_ref: function(node) {
|
|
if (!asts.findRule(ast, node.name)) {
|
|
throw new GrammarError(
|
|
"Rule \"" + node.name + "\" is not defined.",
|
|
node.location
|
|
);
|
|
}
|
|
}
|
|
});
|
|
|
|
check(ast);
|
|
}
|
|
|
|
module.exports = reportUndefinedRules;
|