reglibcpp  1.7.0
(Naïve) C++ implementation of models for regular languages
gnfa.h
Go to the documentation of this file.
1 #ifndef REG_GNFA_H
2 #define REG_GNFA_H
3 
5 #include <memory>
6 
7 #include <string>
8 
9 #include <vector>
10 
11 #include <functional>
12 
13 #include "expression.h"
14 
15 namespace reg {
17 class gnfa {
18 public:
19  gnfa(dfa const& d);
20  gnfa(nfa const& n);
22  gnfa(gnfa const& n);
23  gnfa(gnfa&& n);
24  gnfa& operator=(gnfa const& n);
25  gnfa& operator=(gnfa&& n);
26  virtual ~gnfa ();
27 
28  operator nfa const&() const;
29  bool operator==(nfa const& n) const;
30  bool operator!=(nfa const& n) const;
31  std::string const& getInitialState() const;
32  std::string const& getAcceptingState() const;
34  expression::exptr getTransition(std::string const& qLabel, std::string const& pLabel) const;
38  void bypassTransition(std::string const& qLabel, std::string const& pLabel);
39  void ripState(std::string const& qLabel);
41 private:
42  friend expression::operator nfa const&() const;
43  gnfa(expression const& r);
44  struct pImpl;
46 };
47 }
48 #endif
void ripState(std::string const &qLabel)
Removes a state, bypassing all its outgoing transitions.
Definition: gnfa.cpp:373
std::vector< std::reference_wrapper< std::string const > > getActiveStates() const
Reveals the names of this GNFA's non-initial, non-accepting states.
Definition: gnfa.cpp:220
expression::exptr getTransition(std::string const &qLabel, std::string const &pLabel) const
Extracts the RE labelling the transition between two states.
Definition: gnfa.cpp:231
Represents nondeterministic finite automata with ε-moves.
Definition: nfa.h:23
bool operator!=(nfa const &n) const
Checks whether this RE describes a different regular language than another object.
Definition: gnfa.cpp:428
Represents deterministic finite automata.
Definition: dfa.h:21
nfa splitAllTransitions()
Splits all transitions until only ∅, ε, and symbol REs remain and builds the resulting NFA...
Definition: gnfa.cpp:324
expression::exptr ripAllStates()
Removes all active states, constructing an RE semantically equivalent to this GNFA.
Definition: gnfa.cpp:393
std::string const & getAcceptingState() const
Reveals the name of this GNFA's accept state.
Definition: gnfa.cpp:215
Represents formal regular expressions.
Definition: expression.h:28
std::string const & getInitialState() const
Reveals the name of this GNFA's initial state.
Definition: gnfa.cpp:210
bool operator==(nfa const &n) const
Checks whether this RE describes the same regular language as another object.
Definition: gnfa.cpp:420
std::vector< std::pair< std::reference_wrapper< std::string const >, std::reference_wrapper< std::string const > > > getSplittableTransitions() const
Reveals this GNFA's splittable transitions.
Definition: gnfa.cpp:239
gnfa & operator=(gnfa const &n)
Copy-assigns this GNFA by copying another one's private implementation object.
Definition: gnfa.cpp:433
Contains the reg::expression class defintion.
Represents generalized nondeterministic finite automata.
Definition: gnfa.h:17
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.
Definition: gnfa.cpp:261
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...
Definition: gnfa.cpp:345
Where this library lives.
Definition: dfa.cpp:51
gnfa(dfa const &d)
Constructs a GNFA with the same states and transitions as a given DFA.
Definition: gnfa.cpp:120
Private implementation details of GNFAs.
Definition: gnfa.cpp:22