reglibcpp  1.3.0
(Naïve) C++ implementation of models for regular languages
Public Member Functions | Public Attributes | List of all members
reg::nfa::pImpl Struct Reference

Private implementation details of NFAs. More...

Public Member Functions

 pImpl ()
 Constructs private implementation object for an NFA accepting the empty language ∅. More...
 
 pImpl (vector< char32_t > &alphabet, vector< vector< valarray< bool >>> &transitions, vector< string > &labels, valarray< bool > &acceptingStates)
 Constructs private implementation object with provided members and empty ε-closure cache. More...
 
dfa const & getEquivalentDfa (nfa const *owner)
 Returns the equivalent DFA safely, constructing it if it wasn't already. More...
 

Public Attributes

std::shared_ptr< dfa const > equivalent
 Stores a minimal DFA accepting the same language as this object's NFA. More...
 
valarray< bool > accepting
 A true value marks an index as belonging to an accept state. More...
 
vector< char32_t > alphabet
 Represents the set of processable symbols. More...
 
vector< string > utf8Alphabet
 Represents the set of processable symbols as UTF-8-encoded strings. More...
 
vector< valarray< bool > > epsClosures
 Cache for every state's ε-closures. More...
 
vector< string > labels
 Stores the names of states. More...
 
vector< vector< valarray< bool > > > transitions
 Stores the transition function as a table viz state index × symbol index → list of bools with true at reached state indices. More...
 

Detailed Description

Private implementation details of NFAs.

Definition at line 29 of file nfa.cpp.

Constructor & Destructor Documentation

◆ pImpl() [1/2]

reg::nfa::pImpl::pImpl ( )
inline

Constructs private implementation object for an NFA accepting the empty language ∅.

Definition at line 39 of file nfa.cpp.

39  :
40  equivalent(),
41  accepting(),
42  alphabet(1, U'\0'),
43  utf8Alphabet(1, ""),
44  epsClosures(),
45  labels(),
46  transitions() {}
vector< vector< valarray< bool > > > transitions
Stores the transition function as a table viz state index × symbol index → list of bools with true a...
Definition: nfa.cpp:36
vector< string > labels
Stores the names of states.
Definition: nfa.cpp:35
valarray< bool > accepting
A true value marks an index as belonging to an accept state.
Definition: nfa.cpp:31
vector< char32_t > alphabet
Represents the set of processable symbols.
Definition: nfa.cpp:32
vector< valarray< bool > > epsClosures
Cache for every state&#39;s ε-closures.
Definition: nfa.cpp:34
vector< string > utf8Alphabet
Represents the set of processable symbols as UTF-8-encoded strings.
Definition: nfa.cpp:33
std::shared_ptr< dfa const > equivalent
Stores a minimal DFA accepting the same language as this object&#39;s NFA.
Definition: nfa.cpp:30

◆ pImpl() [2/2]

reg::nfa::pImpl::pImpl ( vector< char32_t > &  alphabet,
vector< vector< valarray< bool >>> &  transitions,
vector< string > &  labels,
valarray< bool > &  acceptingStates 
)
inline

Constructs private implementation object with provided members and empty ε-closure cache.

Definition at line 49 of file nfa.cpp.

50  :
51  accepting(move(acceptingStates)),
52  alphabet(move(alphabet)),
53  labels(move(labels)),
54  transitions(move(transitions)) {
55  utf8Alphabet.reserve(this->alphabet.size());
56  for (char32_t symbol : this->alphabet) {
57  if (symbol == U'\0') {
58  utf8Alphabet.push_back("");
59  } else {
60  utf8Alphabet.push_back(converter.to_bytes(symbol));
61  }
62  }
63  epsClosures = vector<valarray<bool>>(pImpl::labels.size());
64  }
vector< vector< valarray< bool > > > transitions
Stores the transition function as a table viz state index × symbol index → list of bools with true a...
Definition: nfa.cpp:36
vector< string > labels
Stores the names of states.
Definition: nfa.cpp:35
valarray< bool > accepting
A true value marks an index as belonging to an accept state.
Definition: nfa.cpp:31
vector< char32_t > alphabet
Represents the set of processable symbols.
Definition: nfa.cpp:32
vector< valarray< bool > > epsClosures
Cache for every state&#39;s ε-closures.
Definition: nfa.cpp:34
vector< string > utf8Alphabet
Represents the set of processable symbols as UTF-8-encoded strings.
Definition: nfa.cpp:33
std::wstring_convert< std::codecvt_utf8< char32_t >, char32_t > converter
Converts between UTF-8-encoded and UTF-32-encoded strings.
Definition: dfa.cpp:1001

Member Function Documentation

◆ getEquivalentDfa()

dfa const& reg::nfa::pImpl::getEquivalentDfa ( nfa const *  owner)
inline

Returns the equivalent DFA safely, constructing it if it wasn't already.

Parameters
ownerpointer to the NFA calling the method

Definition at line 70 of file nfa.cpp.

70  {
71  if (!equivalent) {
72  equivalent.reset(new dfa(dfa::builder(*owner).minimize()));
73  }
74  return *equivalent;
75  }
std::shared_ptr< dfa const > equivalent
Stores a minimal DFA accepting the same language as this object&#39;s NFA.
Definition: nfa.cpp:30

Member Data Documentation

◆ accepting

valarray<bool> reg::nfa::pImpl::accepting

A true value marks an index as belonging to an accept state.

Definition at line 31 of file nfa.cpp.

◆ alphabet

vector<char32_t> reg::nfa::pImpl::alphabet

Represents the set of processable symbols.

Definition at line 32 of file nfa.cpp.

◆ epsClosures

vector<valarray<bool> > reg::nfa::pImpl::epsClosures
mutable

Cache for every state's ε-closures.

Definition at line 34 of file nfa.cpp.

◆ equivalent

std::shared_ptr<dfa const> reg::nfa::pImpl::equivalent

Stores a minimal DFA accepting the same language as this object's NFA.

Definition at line 30 of file nfa.cpp.

◆ labels

vector<string> reg::nfa::pImpl::labels

Stores the names of states.

Definition at line 35 of file nfa.cpp.

◆ transitions

vector<vector<valarray<bool> > > reg::nfa::pImpl::transitions

Stores the transition function as a table viz state index × symbol index → list of bools with true at reached state indices.

Definition at line 36 of file nfa.cpp.

◆ utf8Alphabet

vector<string> reg::nfa::pImpl::utf8Alphabet

Represents the set of processable symbols as UTF-8-encoded strings.

Definition at line 33 of file nfa.cpp.


The documentation for this struct was generated from the following file: