reglibcpp
1.0.0
(Naïve) C++ implementation of models for regular languages
|
Represents deterministic finite automata. More...
#include <dfa.h>
Classes | |
class | builder |
Constructs DFAs step by step. More... | |
struct | pImpl |
Private implementation details of DFAs. More... | |
Public Member Functions | |
dfa () | |
Constructs a DFA accepting the empty language ∅. More... | |
dfa (dfa &d) | |
Copy-constructs a DFA by copying another one's private implementation object. More... | |
dfa (dfa &&d) | |
Move-constructs a DFA by stealing another one's private implementation object. More... | |
dfa (builder &b) | |
Constructs a DFA from a builder. More... | |
dfa & | operator= (const dfa &d) |
Copy-assigns this DFA by copying another one's private implementation object. More... | |
dfa & | operator= (dfa &&d) |
Move-assigns this DFA by stealing another one's private implementation object. More... | |
bool | operator== (const dfa &d) const |
Tests whether this DFA accepts exactly the same language as another one. More... | |
bool | operator!= (const dfa &d) const |
Tests whether this DFA doesn't accept the same language as another one. More... | |
size_t | delta (size_t q, char32_t symbol) const |
Computes this DFA's transition function for a state and a symbol. More... | |
size_t | delta (size_t q, std::string const &utf8Symbol) const |
Same as above for a UTF-8-encoded symbol. More... | |
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 state. More... | |
size_t | deltaHat (size_t q, std::string const &utf8Word) const |
Same as above for a string of UTF-8-encoded symbols. More... | |
std::string const & | getLabelOf (size_t q) const |
Puts a name to an index. More... | |
std::vector< char32_t > const & | getAlphabet () const |
Fetches this DFA's set of processable symbols. More... | |
std::vector< std::string > const & | getUtf8Alphabet () const |
Fetches this DFA's set of processable symbols as UTF-8-encoded strings. More... | |
size_t | getNumberOfStates () const |
Counts this DFA's states. More... | |
bool | isAccepting (size_t q) const |
Tests whether a state is an accept state within this DFA. More... | |
Represents deterministic finite automata.
Instances of this class are completely immutable. The builder class is the preferred way of constructing DFAs.
By convention, the state with index 0 is the initial state.
reg::dfa::dfa | ( | ) |
reg::dfa::dfa | ( | dfa & | d | ) |
Copy-constructs a DFA by copying another one's private implementation object.
reg::dfa::dfa | ( | dfa && | d | ) |
Move-constructs a DFA by stealing another one's private implementation object.
The other DFA will be accepting the empty language ∅ afterwards.
reg::dfa::dfa | ( | dfa::builder & | b | ) |
size_t reg::dfa::delta | ( | size_t | q, |
char32_t | symbol | ||
) | const |
Computes this DFA's transition function for a state and a symbol.
q | the state's index (< getNumberOfStates) |
symbol | the symbol to process (∈ getAlphabet) |
Definition at line 223 of file dfa.cpp.
size_t reg::dfa::delta | ( | size_t | q, |
std::string const & | utf8Symbol | ||
) | const |
Same as above for a UTF-8-encoded symbol.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 250 of file dfa.cpp.
size_t reg::dfa::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 state.
q | the starting state's index (< getNumberOfStates) |
word | the string of symbols to process (all of which ∈ getAlphabet) |
Definition at line 261 of file dfa.cpp.
size_t reg::dfa::deltaHat | ( | size_t | q, |
std::string const & | utf8Word | ||
) | const |
Same as above for a string of UTF-8-encoded symbols.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 269 of file dfa.cpp.
vector< char32_t > const & reg::dfa::getAlphabet | ( | ) | const |
string const & reg::dfa::getLabelOf | ( | size_t | q | ) | const |
Puts a name to an index.
q | the state's index (< getNumberOfStates) |
size_t reg::dfa::getNumberOfStates | ( | ) | const |
vector< string > const & reg::dfa::getUtf8Alphabet | ( | ) | const |
bool reg::dfa::isAccepting | ( | size_t | q | ) | const |
Tests whether a state is an accept state within this DFA.
q | the state's index (< getNumberOfStates) |
true
if the state is in the set of accept states, false
else bool reg::dfa::operator!= | ( | const dfa & | d | ) | const |
Tests whether this DFA doesn't accept the same language as another one.
Definition at line 214 of file dfa.cpp.
Copy-assigns this DFA by copying another one's private implementation object.
Move-assigns this DFA by stealing another one's private implementation object.
The other DFA will be accepting the empty language ∅ afterwards.
bool reg::dfa::operator== | ( | const dfa & | d | ) | const |
Tests whether this DFA accepts exactly the same language as another one.
More specifically, checks whether this DFA's initial state is indistinguishable from the other one's.
Definition at line 152 of file dfa.cpp.