41 size_t delta(
size_t qi,
size_t si)
const;
42 size_t delta(
size_t qi, char32_t symbol)
const;
120 template<
class C,
class T>
size_t index_of(C
const& container, T
const& element) {
122 return static_cast<size_t>(std::distance(container.begin(), std::find(container.begin(), container.end(), element)));
bool operator!=(const dfa &d) const
Tests whether this DFA doesn't accept the same language as another one.
static dfa::builder complement(dfa const &d)
Creates a builder for a DFA accepting the complement of the language of a DFA.
std::string const & getInitialState() const
Names this DFA's initial state.
builder & setAccepting(std::string const &state, bool accept)
Sets whether or not a state will be accepting within the prospective DFA.
bool isAccepting(size_t qi) const
Tests whether a state is an accept state within this DFA.
builder & unite(dfa const &other)
Makes the prospective DFA also accept every word of another DFA's language.
dfa()
Constructs a DFA accepting the empty language ∅.
Represents nondeterministic finite automata with ε-moves.
static dfa::builder unite(dfa const &d1, dfa const &d2)
Creates a builder for a DFA accepting the union of the languages of two DFAs.
Represents deterministic finite automata.
Private implementation details of DFAs.
std::wstring_convert< std::codecvt_utf8< char32_t >, char32_t > converter
Converts between UTF-8-encoded and UTF-32-encoded strings.
builder & minimize()
Convenience method for chaining purge and merge to achieve proper minimization.
builder & purge()
Purges the prospective DFA of unreachable and non-producing states, allowing for minimization.
friend std::string findShortestUtf8Word(dfa const &d)
Same as above for a UTF-8-encoded word.
size_t delta(size_t qi, size_t si) const
Computes this DFA's transition function for a state index and a symbol index.
std::vector< char32_t > const & getAlphabet() const
Fetches this DFA's set of processable symbols.
dfa & operator=(const dfa &d)
Copy-assigns this DFA by copying another one's private implementation object.
size_t getNumberOfSymbols() const
Private implementation details of DFA builders.
size_t index_of(C const &container, T const &element)
Basically Java's List interface's indexOf, but as a non-member function and returning the container's...
size_t deltaHat(size_t qi, std::u32string const &word) const
Computes this DFA's transition function recursively for a string of symbols, starting in a state spec...
static dfa::builder subtract(dfa const &d1, dfa const &d2)
Creates a builder for a DFA accepting the set difference of the languages of two DFAs.
friend std::u32string findShortestWord(dfa const &d)
Searches the shortest UTF-32-encoded word accepted by a given DFA.
bool operator==(const dfa &d) const
Tests whether this DFA accepts exactly the same language as another one.
builder & complement()
Inverts the prospective DFA's language with respect to all possible strings over its alphabet...
std::vector< std::string > const & getStates() const
Fetches this DFA's set of states.
builder & makeInitial(std::string const &state)
Resets the initial state for the prospective DFA.
builder & merge()
Merges the prospective DFA's indistinguishable states, allowing for minimization. ...
Constructs DFAs step by step.
size_t getNumberOfStates() const
builder & normalizeStateNames(std::string const &prefix)
Reduces the prospective NFA's state names to consecutive numbers, prefixed with a given string...
builder()
Constructs a blank builder object.
static dfa::builder intersect(dfa const &d1, dfa const &d2)
Creates a builder for a DFA accepting the intersection of the languages of two DFAs.
Where this library lives.
std::u32string getShortestWord() const
builder & intersect(dfa const &other)
Makes the prospective DFA accept only words accepted also by another DFA.
builder & operator=(const builder &b)
Copy-assigns a builder by copying another one's private implementation object.
string findShortestUtf8Word(dfa const &d)
Same as above for a UTF-8-encoded word.
std::string getShortestUtf8Word() const
u32string findShortestWord(dfa const &d)
Searches the shortest UTF-32-encoded word accepted by a given DFA.
dfa build()
Builds the DFA, as defined by previous operations, including completion.
std::string const & getLabelOf(size_t qi) const
std::vector< std::string > const & getUtf8Alphabet() const
Fetches this DFA's set of processable symbols as UTF-8-encoded strings.
builder & defineTransition(std::string const &from, std::string const &to, char32_t symbol)
(Re-)Defines a transition for the prospective DFA.
builder & addSymbol(char32_t symbol)
Adds a symbol to the prospective DFA's alphabet.