#pragma once #include "AST.hpp" #include "RegularCompiler.hpp" #include "RegularAutomata.hpp" #include "ContextFreeCompiler.hpp" #include "ContextFreeAutomata.hpp" namespace tp { template class Parser { typedef RegularGrammar RegularGrammar; typedef RegularCompiler RegularCompiler; typedef FiniteStateAutomation RegularGraph; typedef RegularAutomata RegularAutomata; // ContextFreeGrammar; // ContextFreeCompiler; typedef FiniteStateAutomation ContextFreeGraph; typedef ContextFreeAutomata ContextFreeAutomata; public: Parser() = default; public: void compileTables(const ContextFreeGrammar& cfGrammar, const RegularGrammar& reGrammar) { // Compile Regular Grammar { RegularGraph graph; RegularCompiler compiler; compiler.compile(graph, reGrammar); graph.makeDeterministic(); mRegularAutomata.construct(graph); } // compile context free grammar { ContextFreeGraph graph; ContextFreeCompiler compiler; compiler.compile(cfGrammar, graph); graph.makeDeterministic(); mContextFreeAutomata.construct(graph); } } void parse(const tAlphabetType* sentence, ualni sentenceLength, AST& out) {} public: // save load compiled tables RegularAutomata mRegularAutomata; ContextFreeAutomata mContextFreeAutomata; }; }