You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
536 B
JavaScript
24 lines
536 B
JavaScript
10 years ago
|
"use strict";
|
||
|
|
||
11 years ago
|
var GrammarError = require("../../grammar-error"),
|
||
11 years ago
|
asts = require("../asts"),
|
||
|
visitor = require("../visitor");
|
||
12 years ago
|
|
||
13 years ago
|
/* Checks that all referenced rules exist. */
|
||
8 years ago
|
function reportUndefinedRules(ast) {
|
||
11 years ago
|
var check = visitor.build({
|
||
11 years ago
|
rule_ref: function(node) {
|
||
|
if (!asts.findRule(ast, node.name)) {
|
||
|
throw new GrammarError(
|
||
8 years ago
|
"Rule \"" + node.name + "\" is not defined.",
|
||
10 years ago
|
node.location
|
||
11 years ago
|
);
|
||
|
}
|
||
|
}
|
||
13 years ago
|
});
|
||
|
|
||
|
check(ast);
|
||
11 years ago
|
}
|
||
|
|
||
8 years ago
|
module.exports = reportUndefinedRules;
|