This commit is contained in:
IlyaShurupov 2024-02-06 09:27:49 +03:00 committed by Ilusha
parent d2bb8cdd6a
commit 312419936e
6 changed files with 128 additions and 71 deletions

View file

@ -1,10 +1,33 @@
#pragma once
#include "Automata.hpp"
#include "Grammar.hpp"
namespace tp {
template <typename tAlphabetType, typename tStateType, tStateType tNoStateVal, tStateType tFailedStateVal>
class RegularCompiler {};
class ContextFreeCompiler {
typedef ContextFreeGrammar Grammar;
public:
// Terminals or non terminals
struct Alphabet {
String mId;
bool mIsTerminal = false;
};
struct Item {
Grammar::Rule mRule;
ualni mAdvanceIdx;
};
typedef NFA<Alphabet, Item> NFA;
typedef typename NFA::Vertex State;
public:
void compile(const Grammar& in, NFA& out) { nfa = &out; }
private:
NFA* nfa = nullptr;
};
}