2015-06-08 20:21:19 +02:00
|
|
|
"use strict";
|
|
|
|
|
2014-06-04 07:23:34 +02:00
|
|
|
var GrammarError = require("../../grammar-error"),
|
2014-05-08 11:48:56 +02:00
|
|
|
asts = require("../asts"),
|
|
|
|
visitor = require("../visitor");
|
2012-11-10 09:47:22 +01:00
|
|
|
|
2012-04-19 14:23:21 +02:00
|
|
|
/* Checks that all referenced rules exist. */
|
2016-07-29 15:16:56 +02:00
|
|
|
function reportUndefinedRules(ast) {
|
2014-05-08 14:51:17 +02:00
|
|
|
var check = visitor.build({
|
2014-06-04 07:23:34 +02:00
|
|
|
rule_ref: function(node) {
|
|
|
|
if (!asts.findRule(ast, node.name)) {
|
|
|
|
throw new GrammarError(
|
2016-07-03 17:43:56 +02:00
|
|
|
"Rule \"" + node.name + "\" is not defined.",
|
2015-04-06 10:34:07 +02:00
|
|
|
node.location
|
2014-06-04 07:23:34 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2012-04-19 14:23:21 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
check(ast);
|
2014-05-04 14:11:44 +02:00
|
|
|
}
|
|
|
|
|
2016-07-29 15:16:56 +02:00
|
|
|
module.exports = reportUndefinedRules;
|