reglibcpp
1.0.0
(Naïve) C++ implementation of models for regular languages
|
Constructs NFAs step by step. More...
#include <nfa.h>
Classes | |
struct | pImpl |
Private implementation details of NFA builders. More... | |
Public Member Functions | |
builder () | |
Constructs a blank builder object. More... | |
builder (nfa const &nfa) | |
Constructs a builder object with exactly the same states, symbols, transitions, initial state and accept states as a given NFA. More... | |
builder (dfa const &dfa) | |
Constructs a builder object with exactly the same states, symbols, transitions, initial state and accept states as a given DFA. More... | |
builder (builder &b) | |
Copy-constructs a builder by copying another one's private implementation object. More... | |
builder (builder &&b) | |
Move-constructs a builder by stealing another one's private implementation object. More... | |
builder & | operator= (builder const &b) |
Copy-assigns a builder by copying another one's private implementation object. More... | |
builder & | operator= (builder &&b) |
Move-assigns a builder by stealing another one's private implementation object. More... | |
builder & | addSymbol (char32_t symbol) |
Adds a symbol to the prospective NFA's alphabet. More... | |
builder & | addSymbol (std::string const &utf8Symbol) |
Same as above for a UTF-8-encoded symbol. More... | |
builder & | setAccepting (std::string const &state, bool accept) |
Sets whether or not a state will be accepting within the prospective NFA. More... | |
builder & | makeInitial (std::string const &state) |
Resets the initial state for the prospective NFA. More... | |
builder & | addTransition (std::string const &from, std::string const &to, char32_t symbol) |
Adds a transition for the prospective NFA. More... | |
builder & | addTransition (std::string const &from, std::string const &to, std::string const &utf8Symbol) |
Same as above for a UTF-8-encoded symbol. More... | |
nfa | build () |
Builds the NFA, as defined by previous operations. More... | |
Constructs NFAs step by step.
Any mention of a symbol or state will add them to the alphabet/set of states. The first state mentioned will be designated initial state.
reg::nfa::builder::builder | ( | ) |
reg::nfa::builder::builder | ( | nfa const & | nfa | ) |
Constructs a builder object with exactly the same states, symbols, transitions, initial state and accept states as a given NFA.
Definition at line 356 of file nfa.cpp.
reg::nfa::builder::builder | ( | dfa const & | dfa | ) |
reg::nfa::builder::builder | ( | builder & | b | ) |
Copy-constructs a builder by copying another one's private implementation object.
reg::nfa::builder::builder | ( | builder && | b | ) |
Move-constructs a builder by stealing another one's private implementation object.
The other builder will be blank afterwards.
nfa::builder & reg::nfa::builder::addSymbol | ( | char32_t | symbol | ) |
nfa::builder & reg::nfa::builder::addSymbol | ( | std::string const & | utf8Symbol | ) |
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 431 of file nfa.cpp.
nfa::builder & reg::nfa::builder::addTransition | ( | std::string const & | from, |
std::string const & | to, | ||
char32_t | symbol | ||
) |
Adds a transition for the prospective NFA.
from | the starting state for the transition |
to | the destination state for the transition |
symbol | the symbol triggering the transition or \0 for an ε-transition |
Definition at line 475 of file nfa.cpp.
nfa::builder & reg::nfa::builder::addTransition | ( | std::string const & | from, |
std::string const & | to, | ||
std::string const & | utf8Symbol | ||
) |
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 486 of file nfa.cpp.
nfa reg::nfa::builder::build | ( | ) |
nfa::builder & reg::nfa::builder::makeInitial | ( | std::string const & | state | ) |
nfa::builder & reg::nfa::builder::operator= | ( | builder const & | b | ) |
Copy-assigns a builder by copying another one's private implementation object.
nfa::builder & reg::nfa::builder::operator= | ( | nfa::builder && | b | ) |
Move-assigns a builder by stealing another one's private implementation object.
The other builder will be blank afterwards.
nfa::builder & reg::nfa::builder::setAccepting | ( | std::string const & | state, |
bool | accept | ||
) |
Sets whether or not a state will be accepting within the prospective NFA.
state | the state's name |
accept | true if the state should be an accept state afterwards, false else |