reglibcpp  1.3.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 {
16 class nfa;
18 class gnfa {
19 public:
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  std::string const& getInitialState() const;
28  std::string const& getAcceptingState() const;
29  std::vector<std::reference_wrapper<std::string const>> getActiveStates() const;
30  expression::exptr getTransition(std::string const& qLabel, std::string const& pLabel) const;
31  std::vector<std::pair<std::reference_wrapper<std::string const>, std::reference_wrapper<std::string const>>> getSplittableTransitions() const;
32  std::vector<std::reference_wrapper<std::string const>> splitTransition(std::string const& qLabel, std::string const& pLabel);
34  void bypassTransition(std::string const& qLabel, std::string const& pLabel);
35  void ripState(std::string const& qLabel);
37 private:
38  friend class expression;
39  gnfa(expression const& r);
40  struct pImpl;
41  std::unique_ptr<pImpl> p;
42 };
43 }
44 #endif
void ripState(std::string const &qLabel)
Removes a state, bypassing all its outgoing transitions.
Definition: gnfa.cpp:336
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:183
expression::exptr getTransition(std::string const &qLabel, std::string const &pLabel) const
Extracts the RE labelling the transition between two states.
Definition: gnfa.cpp:194
Represents nondeterministic finite automata with ε-moves.
Definition: nfa.h:22
gnfa(nfa const &n)
Constructs a GNFA with the same states and transitions as a given NFA.
Definition: gnfa.cpp:116
nfa splitAllTransitions()
Splits all transitions until only ∅, ε, and symbol REs remain and builds the resulting NFA...
Definition: gnfa.cpp:287
expression::exptr ripAllStates()
Removes all active states, constructing an RE semantically equivalent to this GNFA.
Definition: gnfa.cpp:356
std::string const & getAcceptingState() const
Reveals the name of this GNFA's accept state.
Definition: gnfa.cpp:178
Represents formal regular expressions.
Definition: expression.h:27
std::string const & getInitialState() const
Reveals the name of this GNFA's initial state.
Definition: gnfa.cpp:173
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:202
gnfa & operator=(gnfa const &n)
Copy-assigns this GNFA by copying another one's private implementation object.
Definition: gnfa.cpp:371
Contains the reg::expression class defintion.
Represents generalized nondeterministic finite automata.
Definition: gnfa.h:18
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:224
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:308
Definition: dfa.cpp:29
std::shared_ptr< expression const > exptr
This is the type used to handle regular expressions.
Definition: expression.h:39
Private implementation details of GNFAs.
Definition: gnfa.cpp:21