36 std::valarray<bool>
const&
delta(
size_t q, char32_t symbol)
const;
37 std::valarray<bool>
const&
delta(
size_t q, std::string
const& utf8Symbol)
const;
38 std::valarray<bool>
deltaHat(
size_t q, std::u32string
const& word)
const;
39 std::valarray<bool>
deltaHat(
size_t q, std::string
const& utf8Word)
const;
40 std::valarray<bool>
deltaHat(std::valarray<bool>
const& qs, std::u32string
const& word)
const;
41 std::valarray<bool>
deltaHat(std::valarray<bool>
const& qs, std::string
const& utf8Word)
const;
43 std::valarray<bool>
epsilonClosure(std::valarray<bool>
const& qs)
const;
47 std::string
getLabelOf(std::valarray<bool>
const& qs)
const;
78 builder&
addTransition(std::string
const& from, std::string
const& to, std::string
const& utf8Symbol);
85 std::unique_ptr<pImpl> p;
89 std::unique_ptr<pImpl> p;
91 std::vector<char32_t>& alphabet,
92 std::vector<std::vector<std::valarray<bool>>>& transitions,
93 std::vector<std::string>& labels,
94 std::valarray<bool>& acceptingStates
nfa build()
Builds the NFA, as defined by previous operations.
static nfa::builder complement(nfa const &n)
Creates a builder for an NFA accepting the complement of the language of an NFA.
std::string getShortestUtf8Word() const
Same as above for a UTF-8-encoded word, INCLUDING POTENTIAL INFINITE LOOP.
Represents nondeterministic finite automata with ε-moves.
std::vector< char32_t > const & getAlphabet() const
Fetches this NFA's set of processable symbols.
std::string const & getLabelOf(size_t q) const
Puts a name to an index.
Represents deterministic finite automata.
std::vector< std::string > const & getUtf8Alphabet() const
Fetches this NFA's set of processable symbols as UTF-8-encoded strings.
std::valarray< bool > deltaHat(size_t q, std::u32string const &word) const
Computes this NFA's transition function recursively for a string of symbols, starting in a specified ...
Constructs NFAs step by step.
bool operator==(nfa const &n) const
Tests whether this NFA accepts exactly the same language as another one.
bool isAccepting(size_t q) const
Tests whether a state is an accept state within this NFA.
static nfa::builder intersect(nfa const &n1, nfa const &n2)
Creates a builder for an NFA accepting the intersection of the languages of two NFAs.
builder & unite(nfa const &other)
Makes the prospective NFA also accept every word of another NFA's language.
nfa & operator=(nfa const &n)
Copy-assigns this NFA by copying another one's private implementation object.
bool operator!=(nfa const &n) const
Tests whether this NFA doesn't accept the same language as another one.
builder & addSymbol(char32_t symbol)
Adds a symbol to the prospective NFA's alphabet.
builder & setAccepting(std::string const &state, bool accept)
Sets whether or not a state will be accepting within the prospective NFA.
builder & normalizeStateNames(std::string const &prefix)
Reduces the prospective NFA's state names to consecutive numbers, prefixed with a given string...
std::u32string getShortestWord() const
Searches the shortest UTF-32-encoded word accepted by this NFA.
static nfa::builder unite(nfa const &n1, nfa const &n2)
Creates a builder for an NFA accepting the union of the languages of two NFAs.
Private implementation details of NFAs.
builder & makeInitial(std::string const &state)
Resets the initial state for the prospective NFA.
builder & intersect(nfa const &other)
Makes the prospective NFA accept only words accepted also by another NFA.
Private implementation details of NFA builders.
size_t getNumberOfStates() const
Counts this NFA's states.
static nfa::builder subtract(nfa const &n1, nfa const &n2)
Creates a builder for an NFA accepting the set difference of the languages of two NFAs...
bool hasAccepting(std::valarray< bool > const &qs) const
Tests whether a set of states contains an accept state within this NFA.
nfa()
Constructs an NFA accepting the empty language ∅.
builder & operator=(builder const &b)
Copy-assigns a builder by copying another one's private implementation object.
builder & addTransition(std::string const &from, std::string const &to, char32_t symbol)
Adds a transition for the prospective NFA.
std::valarray< bool > const & delta(size_t q, char32_t symbol) const
Computes this NFA's transition function for a state and a symbol.
std::valarray< bool > const & epsilonClosure(size_t q) const
Computes a state's ε-closure.
builder()
Constructs a blank builder object.