#pragma once #include "compilers/RegularCompiler.hpp" #include "automatas/DetFinateStateAutomata.hpp" #include "compilers/ContextFreeCompiler.hpp" #include "automatas/DetPushDownAutomata.hpp" namespace tp { template class Parser { using ParserRegularGrammar = RegularGrammar; using ParserRegularCompiler = RegularCompiler; using RegularGraph = FiniteStateAutomation; using ParserRegularAutomata = DetFinateStateAutomata; using ContextFreeGraph = FiniteStateAutomation; using ParserContextFreeAutomata = DetPushDownAutomata; public: struct ParseResult { bool accepted = false; const ParserContextFreeAutomata::StackItem* ast = nullptr; }; public: Parser() = default; void setIgnoreToken(tTokenType token); public: bool compileTables( const ContextFreeGrammar& cfGrammar, const ParserRegularGrammar& reGrammar, const Map& contextFreeToRegular ); ParseResult parse(const tAlphabetType* sentence, ualni sentenceLength); public: // save load compiled tables ParserRegularAutomata mRegularAutomata; ParserContextFreeAutomata mContextFreeAutomata; Map mGrammarGlue; Map mAstNames; tTokenType mIgnoreToken = tTokenType(); }; } #include "Parser.ipp"