packages/pegjs/lib/compiler/passes/report-undefined-rules.js
function reportUndefinedRules( ast, session, options ) {

    const check = session.buildVisitor( {
        rule_ref( node ) {

            if ( ! ast.findRule( node.name ) ) {

                session.error(
                    `Rule "${ node.name }" is not defined.`,
                    node.location
                );

            }

        }
    } );

    check( ast );

    options.allowedStartRules.forEach( rule => {

        if ( ! ast.findRule( rule ) ) {

            session.error( `Start rule "${ rule }" is not defined.` );

        }

    } );

}
function reportUndefinedRules( ast, session, options ) {

    const check = session.buildVisitor( {
        rule_ref( node ) {

            if ( ! ast.findRule( node.name ) ) {

                session.error(
                    `Rule "${ node.name }" is not defined.`,
                    node.location
                );

            }

        }
    } );

    check( ast );

    options.allowedStartRules.forEach( rule => {

        if ( ! ast.findRule( rule ) ) {

            session.error( `Start rule "${ rule }" is not defined.` );

        }

    } );

}
function reportUndefinedRules ( ast , session , options ) { const check = session . buildVisitor ( { rule_ref ( node ) { if ( ! ast . findRule ( node . name ) ) { session . error ( ` ${ node . name } ` , node . location ) ; } } } ) ; check ( ast ) ; options . allowedStartRules . forEach ( rule => { if ( ! ast . findRule ( rule ) ) { session . error ( ` ${ rule } ` ) ; } } ) ; }
Checks that all referenced rules exist.
Checks that all referenced rules exist .