reglibcpp  2.1.0
A C++ implementation of models for regular languages
Public Member Functions | Public Attributes | List of all members
reg::gnfa::impl Struct Reference

Private implementation details of GNFAs. More...

Public Member Functions

 impl ()
 Constructs private implementation object for a GNFA accepting the empty language ∅. More...
 
 impl (unordered_map< string, unordered_map< string, expression::exptr >> &transitionMap, string const &initialState, forward_list< reference_wrapper< string const >> &acceptingStates, nfa const *eq)
 Constructs private implementation object with provided members. More...
 
expression::exptr const & getTransition (string const &qLabel, string const &pLabel) const
 Safely fetches a transition RE between two states. More...
 
void addTransition (string const &qLabel, string const &pLabel, expression::exptr re, bool optimized=true, bool aggressive=false)
 Safely adds a transition RE between two states. More...
 
string const & generateState (char prefix='q', char suffix='\0')
 Generates a unique new state name with given prefix (and suffix). More...
 

Public Attributes

std::shared_ptr< nfa const > equivalent
 Points to a DFA accepting the same language as the owning GNFA. More...
 
unordered_map< string, unordered_map< string, expression::exptr > > transitions
 Holds the transition table viz state × state → regular expression. More...
 
string initial
 Holds the name of the initial state. More...
 
string accepting
 Holds the name of the accept state. More...
 

Detailed Description

Private implementation details of GNFAs.

Definition at line 40 of file gnfa.cpp.

Constructor & Destructor Documentation

◆ impl() [1/2]

reg::gnfa::impl::impl ( )
inline

Constructs private implementation object for a GNFA accepting the empty language ∅.

Definition at line 53 of file gnfa.cpp.

◆ impl() [2/2]

reg::gnfa::impl::impl ( unordered_map< string, unordered_map< string, expression::exptr >> &  transitionMap,
string const &  initialState,
forward_list< reference_wrapper< string const >> &  acceptingStates,
nfa const *  eq 
)
inline

Constructs private implementation object with provided members.

Definition at line 59 of file gnfa.cpp.

Member Function Documentation

◆ addTransition()

void reg::gnfa::impl::addTransition ( string const &  qLabel,
string const &  pLabel,
expression::exptr  re,
bool  optimized = true,
bool  aggressive = false 
)
inline

Safely adds a transition RE between two states.

The resulting transition will be labelled with the alternation of the provided RE and the former RE labelling the transition.

Parameters
qLabelbeginning of the transition
pLabelend of the transition
rethe RE that should be added to the transition
optimizedpass-through to expression::spawnAlternation
aggressivepass-through to expression::spawnAlternation

Definition at line 102 of file gnfa.cpp.

◆ generateState()

string const& reg::gnfa::impl::generateState ( char  prefix = 'q',
char  suffix = '\0' 
)
inline

Generates a unique new state name with given prefix (and suffix).

State name generation has two modes:

  1. If suffix == \0: The name begins with prefix and ends with an ever-increasing number.
  2. Else: The name begins with prefix and ends with an ever-expanding repetition of suffix.
    Parameters
    prefixprintable char the new state's name should begin with or \0 for empty prefix
    suffixprintable char the new state's name should end with or \0 for a number
    Returns
    the first state name generated by the above method that is not present in the table of transitions

Definition at line 124 of file gnfa.cpp.

◆ getTransition()

expression::exptr const& reg::gnfa::impl::getTransition ( string const &  qLabel,
string const &  pLabel 
) const
inline

Safely fetches a transition RE between two states.

Parameters
qLabelbegin state of the transition
pLabelend state of the transition
Returns
the RE corresponding to the transition between the states, if undefined

Definition at line 81 of file gnfa.cpp.

Member Data Documentation

◆ accepting

string reg::gnfa::impl::accepting

Holds the name of the accept state.

Definition at line 48 of file gnfa.cpp.

◆ equivalent

std::shared_ptr<nfa const> reg::gnfa::impl::equivalent
mutable

Points to a DFA accepting the same language as the owning GNFA.

Definition at line 41 of file gnfa.cpp.

◆ initial

string reg::gnfa::impl::initial

Holds the name of the initial state.

Definition at line 46 of file gnfa.cpp.

◆ transitions

unordered_map<string, unordered_map<string, expression::exptr> > reg::gnfa::impl::transitions

Holds the transition table viz state × state → regular expression.

Definition at line 43 of file gnfa.cpp.


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