reglibcpp
1.3.0
(Naïve) C++ implementation of models for regular languages
|
Represents generalized nondeterministic finite automata. More...
#include <gnfa.h>
Classes | |
struct | pImpl |
Private implementation details of GNFAs. More... | |
Public Member Functions | |
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... | |
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... | |
std::vector< std::reference_wrapper< std::string const > > | getActiveStates () const |
Reveals the names of this GNFA's non-initial, non-accepting states. More... | |
expression::exptr | getTransition (std::string const &qLabel, std::string const &pLabel) const |
Extracts the RE labelling the transition between two states. More... | |
std::vector< std::pair< std::reference_wrapper< std::string const >, std::reference_wrapper< std::string const > > > | getSplittableTransitions () const |
Reveals this GNFA's splittable transitions. More... | |
std::vector< std::reference_wrapper< std::string const > > | splitTransition (std::string const &qLabel, std::string const &pLabel) |
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 &qLabel, std::string const &pLabel) |
Removes a transition between two states and replaces it with equivalent ones, bypassing its beginning state. More... | |
void | ripState (std::string const &qLabel) |
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... | |
Friends | |
class | expression |
Represents generalized nondeterministic finite automata.
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 |
Definition at line 116 of file gnfa.cpp.
reg::gnfa::gnfa | ( | expression::exptr | r | ) |
Constructs a GNFA with only one transition.
The GNFA will have only two states: the initial and the accept state and a transition with the given label leading from the former to the latter.
r | the transition's RE |
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 & | qLabel, |
std::string const & | pLabel | ||
) |
Removes a transition between two states and replaces it with equivalent ones, bypassing its beginning state.
Definition at line 308 of file gnfa.cpp.
string const & reg::gnfa::getAcceptingState | ( | ) | const |
vector< reference_wrapper< string const > > reg::gnfa::getActiveStates | ( | ) | const |
Reveals the names of this GNFA's non-initial, non-accepting states.
string const & reg::gnfa::getInitialState | ( | ) | const |
vector< pair< reference_wrapper< string const >, reference_wrapper< string const > > > reg::gnfa::getSplittableTransitions | ( | ) | const |
Reveals this GNFA's splittable transitions.
expression::exptr reg::gnfa::getTransition | ( | std::string const & | qLabel, |
std::string const & | pLabel | ||
) | 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.
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 Definition at line 356 of file gnfa.cpp.
void reg::gnfa::ripState | ( | std::string const & | qLabel | ) |
Removes a state, bypassing all its outgoing transitions.
Definition at line 336 of file gnfa.cpp.
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.
Definition at line 287 of file gnfa.cpp.
vector< reference_wrapper< string const > > reg::gnfa::splitTransition | ( | std::string const & | qLabel, |
std::string const & | pLabel | ||
) |
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.
qLabel | the beginning state of the transition |
pLabel | the end state of the transition |
Definition at line 224 of file gnfa.cpp.