898a7b5a2d
The |visitor.build| function now supplies default visit functions for visitors it builds. These functions don't do anything beside traversing the tree and passing arguments around to child visit functions. Having the default visit functions allowed to simplify several visitors.
21 lines
503 B
JavaScript
21 lines
503 B
JavaScript
var GrammarError = require("../../grammar-error"),
|
|
asts = require("../asts"),
|
|
visitor = require("../visitor");
|
|
|
|
/* Checks that all referenced rules exist. */
|
|
function reportMissingRules(ast) {
|
|
var check = visitor.build({
|
|
rule_ref: function(node) {
|
|
if (!asts.findRule(ast, node.name)) {
|
|
throw new GrammarError(
|
|
"Referenced rule \"" + node.name + "\" does not exist."
|
|
);
|
|
}
|
|
}
|
|
});
|
|
|
|
check(ast);
|
|
}
|
|
|
|
module.exports = reportMissingRules;
|