'use strict';

var resolver = require('../resolver.js');
var checks = require('../checks.js');
var errors_public = require('../../errors_public.js');
var defaults = require('../../../../../../../../lodash-es@4.17.21/node_modules/lodash-es/defaults.js');
var forEach = require('../../../../../../../../lodash-es@4.17.21/node_modules/lodash-es/forEach.js');

function resolveGrammar(options) {
    const actualOptions = defaults.default(options, {
        errMsgProvider: errors_public.defaultGrammarResolverErrorProvider,
    });
    const topRulesTable = {};
    forEach.default(options.rules, (rule) => {
        topRulesTable[rule.name] = rule;
    });
    return resolver.resolveGrammar(topRulesTable, actualOptions.errMsgProvider);
}
function validateGrammar(options) {
    options = defaults.default(options, {
        errMsgProvider: errors_public.defaultGrammarValidatorErrorProvider,
    });
    return checks.validateGrammar(options.rules, options.tokenTypes, options.errMsgProvider, options.grammarName);
}

exports.resolveGrammar = resolveGrammar;
exports.validateGrammar = validateGrammar;
