"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.test_grammar = void 0;
const grammar_engine_1 = require("./grammar_engine");
exports.test_grammar = {
    Main: {
        scopeName: "source.systemverilog",
        patterns: [
            { include: "AllAllow" }
        ]
    },
    AllAllow: {
        patterns: [
            { include: "BeginEndBlock" },
            { include: "ElseBlock" },
            { include: "GeneralParanthesesBlock" },
            { include: "IfBlock" }
        ]
    },
    BeginEndBlock: {
        patterns: [
            {
                match: grammar_engine_1.r `\b(begin)\b`,
                tokens: ["keyword.begin.systemverilog"],
                push: {
                    scopeName: "begin.body.systemverilog",
                    patterns: [
                        {
                            match: grammar_engine_1.r `\b(end)\b`,
                            tokens: ["keyword.end.systemverilog"],
                            pop: ""
                        },
                        { include: "AllAllow" }
                    ]
                }
            }
        ]
    },
    ElseBlock: {
        patterns: [
            {
                match: grammar_engine_1.r `\b(else)\b`,
                tokens: ["keyword.else.systemverilog"],
                applyState: "if_conditional",
                bank: {
                    scopeName: "else.body.systemverilog",
                    patterns: [
                        {
                            match: grammar_engine_1.r `(;)`,
                            tokens: ["operator.semicolon.systemverilog"],
                            pop: ""
                        },
                        { include: "AllAllow" }
                    ]
                }
            }
        ]
    },
    GeneralParanthesesBlock: {
        patterns: [
            {
                match: grammar_engine_1.r `(\()`,
                tokens: ["operator.open_parantheses.systemverilog"],
                stack: {
                    scopeName: "parantheses.body.systemverilog",
                    patterns: [
                        {
                            match: grammar_engine_1.r `(\))`,
                            tokens: ["operator.close_parantheses.systemverilog"],
                            pop: ""
                        },
                        { include: "AllAllow" }
                    ]
                }
            }
        ]
    },
    IfBlock: {
        patterns: [
            {
                match: grammar_engine_1.r `\b(if)\b`,
                tokens: ["keyword.if.sytemverilog"],
                saveState: "if_conditional",
                bank: {
                    scopeName: "if.body.systemverilog",
                    stashOnPop: "if_conditional",
                    patterns: [
                        {
                            match: grammar_engine_1.r `(;)`,
                            tokens: ["operator.semicolon.systemverilog"],
                            pop: ""
                        },
                        { include: "AllAllow" }
                    ]
                }
            }
        ]
    }
};
let testCode = grammar_engine_1.r `
begin
    if (something)
        if (anotherthing)
        begin
            finish;
        end
        else
            does this work;
end
`;
let testGrammarEngine = new grammar_engine_1.GrammarEngine(exports.test_grammar, "meta.invalid.systemverilog");
let tokens = testGrammarEngine.tokenize(testCode);
tokens.forEach((token, i) => {
    console.log(`token ${i} at ${token.index} (${token.text}) with scopes ${token.scopes.join(', ')}`);
});
