reglibcpp
2.0.0
A C++ implementation of models for regular languages
|
Represents generalized nondeterministic finite automata. More...
#include <gnfa.h>
Classes | |
struct | impl |
Private implementation details of GNFAs. More... | |
Public Types | |
typedef std::vector< std::reference_wrapper< std::string const > > | state_vector |
Nicer name for arrays of names of states. Should store references to existing state names. More... | |
typedef std::vector< std::pair< std::reference_wrapper< std::string const >, std::reference_wrapper< std::string const > > > | state_pair_vector |
Nicer name for arrays of pairs names of states. Should store pairs of references to existing state names. More... | |
Public Member Functions | |
gnfa (dfa const &d) | |
Constructs a GNFA with the same states and transitions as a given DFA. More... | |
gnfa (nfa const &n) | |
Constructs a GNFA with the same states and transitions as a given NFA. More... | |
gnfa (expression::exptr r) | |
Constructs a GNFA with only one transition. More... | |
gnfa (gnfa const &n) | |
Copy-constructs a GNFA by copying another one's private implementation object. More... | |
gnfa (gnfa &&n) | |
Move-constructs a GNFA by stealing another one's private implementation object. More... | |
gnfa & | operator= (gnfa const &n) |
Copy-assigns this GNFA by copying another one's private implementation object. More... | |
gnfa & | operator= (gnfa &&n) |
Move-assigns this GNFA by stealing another one's private implementation object. More... | |
operator nfa const & () const | |
Returns an NFA accepting the same language as this GNFA. More... | |
bool | operator== (nfa const &n) const |
Checks whether this RE describes the same regular language as another object. More... | |
bool | operator!= (nfa const &n) const |
Checks whether this RE describes a different regular language than another object. More... | |
std::string const & | getInitialState () const |
Reveals the name of this GNFA's initial state. More... | |
std::string const & | getAcceptingState () const |
Reveals the name of this GNFA's accept state. More... | |
state_vector | getActiveStates () const |
Reveals the names of this GNFA's non-initial, non-accepting states. More... | |
expression::exptr | getTransition (std::string const &q, std::string const &p) const |
Extracts the RE labelling the transition between two states. More... | |
state_pair_vector | getSplittableTransitions () const |
Reveals this GNFA's splittable transitions. More... | |
state_vector | splitTransition (std::string const &q, std::string const &p) |
Splits a transition between two states, adding new states if needed. More... | |
nfa | splitAllTransitions () |
Splits all transitions until only ∅, ε, and symbol REs remain and builds the resulting NFA. More... | |
void | bypassTransition (std::string const &q, std::string const &p) |
Removes a transition between two states and replaces it with equivalent ones, bypassing its beginning state. More... | |
void | ripState (std::string const &q) |
Removes a state, bypassing all its outgoing transitions. More... | |
expression::exptr | ripAllStates () |
Removes all active states, constructing an RE semantically equivalent to this GNFA. More... | |
Represents generalized nondeterministic finite automata.
typedef std::vector<std::pair<std::reference_wrapper<std::string const>, std::reference_wrapper<std::string const> > > reg::gnfa::state_pair_vector |
typedef std::vector<std::reference_wrapper<std::string const> > reg::gnfa::state_vector |
reg::gnfa::gnfa | ( | dfa const & | d | ) |
Constructs a GNFA with the same states and transitions as a given DFA.
The following changes are applied upon conversion:
d | the DFA to base the GNFA on |
reg::gnfa::gnfa | ( | nfa const & | n | ) |
Constructs a GNFA with the same states and transitions as a given NFA.
The following changes are applied upon conversion:
n | the NFA to base the GNFA on |
reg::gnfa::gnfa | ( | expression::exptr | r | ) |
reg::gnfa::gnfa | ( | gnfa const & | n | ) |
Copy-constructs a GNFA by copying another one's private implementation object.
reg::gnfa::gnfa | ( | gnfa && | n | ) |
Move-constructs a GNFA by stealing another one's private implementation object.
The other GNFA will be semantically equivalent to the ∅ RE afterwards.
void reg::gnfa::bypassTransition | ( | std::string const & | q, |
std::string const & | p | ||
) |
string const & reg::gnfa::getAcceptingState | ( | ) | const |
gnfa::state_vector reg::gnfa::getActiveStates | ( | ) | const |
string const & reg::gnfa::getInitialState | ( | ) | const |
gnfa::state_pair_vector reg::gnfa::getSplittableTransitions | ( | ) | const |
Reveals this GNFA's splittable transitions.
expression::exptr reg::gnfa::getTransition | ( | std::string const & | q, |
std::string const & | p | ||
) | const |
reg::gnfa::operator nfa const & | ( | ) | const |
Returns an NFA accepting the same language as this GNFA.
bool reg::gnfa::operator!= | ( | nfa const & | other | ) | const |
Copy-assigns this GNFA by copying another one's private implementation object.
Move-assigns this GNFA by stealing another one's private implementation object.
The other GNFA will be semantically equivalent to the ∅ RE afterwards.
bool reg::gnfa::operator== | ( | nfa const & | other | ) | const |
expression::exptr reg::gnfa::ripAllStates | ( | ) |
Removes all active states, constructing an RE semantically equivalent to this GNFA.
exptr
to the RE labelling the remaining transition between initial state and accept state void reg::gnfa::ripState | ( | std::string const & | q | ) |
nfa reg::gnfa::splitAllTransitions | ( | ) |
Splits all transitions until only ∅, ε, and symbol REs remain and builds the resulting NFA.
When building the NFA, transitions with symbol and ε REs are replaced with corresponding symbol transitions and transitions with ∅ REs will be ignored.
gnfa::state_vector reg::gnfa::splitTransition | ( | std::string const & | q, |
std::string const & | p | ||
) |
Splits a transition between two states, adding new states if needed.
The transition will be broken up into pieces, according to the semantics of its label.
q | the beginning state of the transition |
p | the end state of the transition |