#pragma once #include "AST.hpp" #include "RegularCompiler.hpp" #include "ContextFreeCompiler.hpp" namespace tp { template class Parser { typedef TransitionMatrix RegularTable; typedef FiniteStateAutomation RegularGraph; typedef RegularCompiler RegularCompiler; typedef FiniteStateAutomation RegularNonDetGraph; // ContextFreeCompiler::Alphabet PushDownTable; typedef FiniteStateAutomation ContextFreeDFA; typedef ContextFreeCompiler::NFA ContextFreeNFA; public: Parser() = default; public: void compileTables(const ContextFreeGrammar& cfGrammar, const RegularGrammar& reGrammar) { // Compile Regular Grammar { RegularNonDetGraph nfa; RegularCompiler compiler; compiler.compile(nfa, reGrammar); RegularGraph dfa(nfa); mRegularTable.construct(dfa); } // compile context free grammar { ContextFreeNFA nfa; ContextFreeCompiler compiler; compiler.compile(cfGrammar, nfa); ContextFreeDFA dfa(nfa); } } void parse(const tAlphabetType* sentence, ualni sentenceLength, AST& out) {} public: // save load compiled tables RegularTable mRegularTable; }; }