'use strict';

var cstUtils = require('../utils/cst-utils.js');
var grammarUtils = require('../utils/grammar-utils.js');
var regexpUtils = require('../utils/regexp-utils.js');
var ast = require('./generated/ast.js');

/******************************************************************************
 * Copyright 2021 TypeFox GmbH
 * This program and the accompanying materials are made available under the
 * terms of the MIT License, which is available in the project root.
 ******************************************************************************/
/**
 * Create the default grammar configuration (used by `createDefaultModule`). This can be overridden in a
 * language-specific module.
 */
function createGrammarConfig(services) {
    const rules = [];
    const grammar = services.Grammar;
    for (const rule of grammar.rules) {
        if (ast.isTerminalRule(rule) && grammarUtils.isCommentTerminal(rule) && regexpUtils.isMultilineComment(grammarUtils.terminalRegex(rule))) {
            rules.push(rule.name);
        }
    }
    return {
        multilineCommentRules: rules,
        nameRegexp: cstUtils.DefaultNameRegexp
    };
}

exports.createGrammarConfig = createGrammarConfig;
