-
Notifications
You must be signed in to change notification settings - Fork 0
/
GNFA.h
78 lines (60 loc) · 2.67 KB
/
GNFA.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* GNFA.h
*
*/
#include "regex.h"
#include <vector>
#include "multiset.h"
using namespace std;
/*
* This is the GNFA class. There is a regular expression on the transitions between the states
* The set of states is taken in the integer noOfStates. It is assumed that set of states is represented by numbers 1 to noOfStates
* As per the design, the Initial state is always state 0, and when there are n states, the states are named state 0 to state n-1
*/
class GNFA {
public:
int noOfStates; // The total finite set of states, as a human would count in a Finite State Machine
alphabet sigma; //Variable to store the alphabet
//bitset <20> states; // Everything that is one is a final state.
//bitset* states; // everythign that is one is a final state. how do you include a bit set that you do not know the lenght to?
typedef vector <regexNode*> transVector; //creates a new type of column vectors that hold the regular expression pointers called transVector; This will represent the receiveing states?. there will be one transvector for each state. it iwll store regular expresions going to other states.
vector <transVector> transFunction; // this is a vector of vectors used to store the transition function.
vector<bool> acceptStates;//holds in pointers 0 to n-1 states 0 to n-
//Constructor
GNFA(int );
//Transition Functions
bool setTransition (int , int , regexNode* );
bool clearTransition (int , int );
//Functions for States
bool setAcceptState(int );// remember states are numbered 0 to n-1
bool isAcceptState(int );
bool resetAcceptState(int );
//Functions for the Alphabet
bool setAlphabet(char* );
bool setAlphabet(alphabet);
alphabet getAlphabet();
bool setNoOfStates(int);
//The following are the functions ued for display purposes
void displayStates();
void displayStartState();
void displayAcceptStates();
void displayAlphabet();
void displayTransitionFunction();
void forceDisplayTransitionFunction();
void display();
//Operations
bool isNonDeterministic();
bool isDeterministic();
regexNode * toRegexp();
//Friend void operator << (ostream&, GNFA& );
friend ostream& operator << (ostream&, GNFA& );
friend istream& operator >> (istream& , GNFA& );
private:
bool deleteTransition(int i, int j);
bool setTransitionPtr(int , int , regexNode* );
typedef vector <transVector> transMatrix;
vector <transMatrix> transCube; // this is a vector of vectors used to store the transition function.
};
//void operator << (ostream&, GNFA& );
ostream& operator << (ostream&, GNFA& );
istream& operator >> (istream&, GNFA& );