Reuse Regular Automata functionality
This commit is contained in:
parent
656da1fd76
commit
7112002e30
17 changed files with 1033 additions and 1058 deletions
|
|
@ -6,16 +6,34 @@
|
|||
|
||||
namespace tp {
|
||||
|
||||
template <typename tAlphabetType>
|
||||
template <typename tAlphabetType, typename TokenType>
|
||||
class Parser {
|
||||
|
||||
typedef TransitionMatrix<tAlphabetType, TokenType, TokenType::InTransition, TokenType::Failed> RegularTable;
|
||||
typedef DFA<tAlphabetType, TokenType, TokenType::InTransition, TokenType::Failed> RegularGraph;
|
||||
typedef RegularCompiler<tAlphabetType, TokenType, TokenType::InTransition, TokenType::Failed> RegularCompiler;
|
||||
typedef NFA<tAlphabetType, TokenType, TokenType::InTransition, TokenType::Failed> RegularNonDetGraph;
|
||||
|
||||
public:
|
||||
Parser() = default;
|
||||
|
||||
public:
|
||||
void compileTables(const ContextFreeGrammar& cfGrammar, const RegularGrammar<tAlphabetType, ualni>& reGrammar) {}
|
||||
void compileTables(const ContextFreeGrammar& cfGrammar, const RegularGrammar<tAlphabetType, TokenType>& reGrammar) {
|
||||
// Compile Regular Grammar
|
||||
{
|
||||
RegularNonDetGraph nfa;
|
||||
RegularCompiler compiler;
|
||||
compiler.compile(nfa, reGrammar);
|
||||
|
||||
RegularGraph dfa(nfa);
|
||||
mRegularTable.construct(dfa);
|
||||
}
|
||||
}
|
||||
|
||||
void parse(const tAlphabetType* sentence, ualni sentenceLength, AST& out) {}
|
||||
|
||||
public:
|
||||
// save load compiled tables
|
||||
RegularTable mRegularTable;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue