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.
36 lines
662 B
JavaScript
36 lines
662 B
JavaScript
9 years ago
|
"use strict";
|
||
|
|
||
8 years ago
|
// Checks that all referenced rules exist.
|
||
6 years ago
|
function reportUndefinedRules( ast, session, options ) {
|
||
7 years ago
|
|
||
6 years ago
|
const check = session.buildVisitor( {
|
||
7 years ago
|
rule_ref( node ) {
|
||
|
|
||
6 years ago
|
if ( ! ast.findRule( node.name ) ) {
|
||
7 years ago
|
|
||
6 years ago
|
session.error(
|
||
7 years ago
|
`Rule "${ node.name }" is not defined.`,
|
||
|
node.location
|
||
|
);
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
} );
|
||
|
|
||
|
check( ast );
|
||
|
|
||
7 years ago
|
options.allowedStartRules.forEach( rule => {
|
||
7 years ago
|
|
||
6 years ago
|
if ( ! ast.findRule( rule ) ) {
|
||
7 years ago
|
|
||
6 years ago
|
session.error( `Start rule "${ rule }" is not defined.` );
|
||
7 years ago
|
|
||
7 years ago
|
}
|
||
7 years ago
|
|
||
7 years ago
|
} );
|
||
7 years ago
|
|
||
10 years ago
|
}
|
||
|
|
||
8 years ago
|
module.exports = reportUndefinedRules;
|