40 size_t delta(
size_t q, char32_t symbol)
const;
41 size_t delta(
size_t q, std::string
const& utf8Symbol)
const;
42 size_t deltaHat(
size_t q, std::u32string
const& word)
const;
43 size_t deltaHat(
size_t q, std::string
const& utf8Word)
const;
87 std::unique_ptr<pImpl> p;
91 std::unique_ptr<pImpl> p;
93 std::vector<char32_t>& alphabet,
94 std::vector<std::vector<size_t>>& transitions,
95 std::vector<std::string>& labels,
96 std::valarray<bool>& acceptingStates
100 template<
class T>
size_t index_of(std::vector<T>
const& vec, T
const& element);
101 extern template size_t index_of(std::vector<char32_t>
const& vec, char32_t
const& element);
103 extern std::wstring_convert<std::codecvt_utf8<char32_t>,char32_t>
converter;
bool isAccepting(size_t q) const
Tests whether a state is an accept state within this DFA.
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.
builder & setAccepting(std::string const &state, bool accept)
Sets whether or not a state will be accepting within the prospective DFA.
builder & unite(dfa const &other)
Makes the prospective DFA also accept every word of another DFA's language.
size_t delta(size_t q, char32_t symbol) const
Computes this DFA's transition function for a state and a symbol.
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.
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.
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.
Private implementation details of DFA builders.
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.
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...
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 deltaHat(size_t q, std::u32string const &word) const
Computes this DFA's transition function recursively for a string of symbols, starting in a specified ...
size_t getNumberOfStates() const
Counts this DFA's states.
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.
size_t index_of(vector< T > const &vec, T const &element)
Basically Java's List interface's indexOf, but as a non-member function and returning the container's...
std::u32string getShortestWord() const
Searches the shortest UTF-32-encoded word accepted by this DFA.
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.
std::string getShortestUtf8Word() const
Same as above for a UTF-8-encoded word, INCLUDING POTENTIAL INFINITE LOOP.
std::string const & getLabelOf(size_t q) const
Puts a name to an index.
dfa build()
Builds the DFA, as defined by previous operations, including completion.
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.
std::wstring_convert< std::codecvt_utf8< char32_t >, char32_t > converter
Converts between UTF-8-encoded and UTF-32-encoded strings.
builder & addSymbol(char32_t symbol)
Adds a symbol to the prospective DFA's alphabet.