#pragma once
#ifndef LEXESIS_BACKEND_H
#define LEXESIS_BACKEND_H

#include "Lexesis/automata.h"
#include "Lexesis/template.h"

#include "mstch/mstch.hpp"

#include <functional>
#include <memory>
#include <string>

namespace lxs {
    class Backend {
        public:
            Backend();
            virtual ~Backend();

            virtual std::string getName() = 0;
            virtual bool canProcessLang(std::string lang);

            virtual void generateLexer(std::function<std::unique_ptr<std::ostream>(std::string)> getOstreamForFileName, std::string lexerName, const DFA& dfa) = 0;

        protected:
            void doTemplate(std::ostream& out, std::string templateName, templ::TemplateContext context);

        private:
            std::string findTemplate(std::string templateName);
    };
}

#endif //LEXESIS_BACKEND_H

