reglibcpp
1.3.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 const &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... | |
builder & | unite (nfa const &other) |
Makes the prospective NFA also accept every word of another NFA's language. More... | |
builder & | intersect (nfa const &other) |
Makes the prospective NFA accept only words accepted also by another NFA. More... | |
builder & | normalizeStateNames (std::string const &prefix) |
Reduces the prospective NFA's state names to consecutive numbers, prefixed with a given string. 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 458 of file nfa.cpp.
reg::nfa::builder::builder | ( | dfa const & | dfa | ) |
reg::nfa::builder::builder | ( | builder const & | 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 535 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 576 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 587 of file nfa.cpp.
nfa reg::nfa::builder::build | ( | ) |
nfa::builder & reg::nfa::builder::intersect | ( | nfa const & | other | ) |
Makes the prospective NFA accept only words accepted also by another NFA.
Concatenates the names of states defined so far with the other NFA's state names and resolves conflicts by appending _
.
other | the NFA whose language should also be accepted |
Definition at line 694 of file nfa.cpp.
nfa::builder & reg::nfa::builder::makeInitial | ( | std::string const & | state | ) |
nfa::builder & reg::nfa::builder::normalizeStateNames | ( | std::string const & | prefix | ) |
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 |
nfa::builder & reg::nfa::builder::unite | ( | nfa const & | other | ) |
Makes the prospective NFA also accept every word of another NFA's language.
Prepends the names of states defined so far with a single 1
and the other NFA's state names with a single 2
and adds a new initial state with an ε transition to each of the other initial states.
other | the NFA whose language should also be accepted |
Definition at line 636 of file nfa.cpp.