This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
FSA_FiniteStateAutomaton.hpp
75 lines (68 loc) · 2.68 KB
/
FSA_FiniteStateAutomaton.hpp
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
/**
* @file FSA_FiniteStateAutomaton.hpp
* Contains the definition of the FiniteStateAutomaton class.
*/
#ifndef FSA_FiniteStateAutomaton_HPP_
#define FSA_FiniteStateAutomaton_HPP_
#include <iostream>
#include "FSA_State.hpp"
#include "FSA_Transition.hpp"
#include "FSA_StateConverter.hpp"
#include <vector>
#include <sstream>
#include <map>
#include <list>
using namespace std;
class Group;
class Grammar;
//class RegularExpression;
/**
* @brief Finite State Automaton data structure.
**/
class FiniteStateAutomaton {
private:
vector<State*> vecStateList;
vector<Transition*> vecTransitionList;
vector<State*> vecFinalStates;
bool isInFinalStatesVector(string p_szStateName);
void removeFinalStates();
bool isInStateConverterList(StateConverter* p_scStateConverter, vector<StateConverter*>* p_vecStateConverterList);
StateConverter* getEqualStateConverterFromConverterList(StateConverter* p_scStateConverter, vector<StateConverter*>* p_vecStateConverterList);
void setTargetStatesForEdge(string p_szEdge, State* p_stStateToCheck, vector<State*>* p_vecTargetStates);
void setStateListFromStateConverterList(vector<State*>* p_vecStateList, vector<StateConverter*>* p_vecStateConverterList);
string getTargetGroupName(State* p_stState, vector<Group*>* p_vecGroups);
void setTargetGroups(vector<Group*>* p_vecGroups);
int findGroupByGroupName(string p_szGroupName, vector<Group*>* p_vecGroups);
bool isInTransitionList(Transition* p_tNewTransition);
public:
FiniteStateAutomaton();
~ FiniteStateAutomaton();
void addState(string p_szStateName);
void addState(State *p_stNewState);
void removeState(string p_szStateName);
void outputStateList();
void printStartState();
void printFinalState();
bool bStateExists(string p_szName);
State* getState(string p_szName);
State* getStartState();
vector<State*>* getFinalStates();
vector<State*>* getStateList();
void addTransition(string p_szBeginningState, string p_szEdge, string p_szFinalState);
void addTransition(State *p_stBeginningState, string p_szEdge, State *p_stFinalState);
void addTransition(string p_szInput);
void removeTransition(string p_szBeginningState, string p_szEdge, string p_szFinalState);
void removeTransition(Transition* p_transition);
void outputTransitionList();
vector<string> getEdgesFromTransitionList();
vector<Transition*>* getTransitions();
void read(string p_szFileName);
void write(string p_szFileName);
void testEdge(string p_szTestEdge);
FiniteStateAutomaton* fsaConvertNEAtoDEA();
FiniteStateAutomaton* minimize();
void removeEmptyEdges();
bool isTotal();
Grammar* convertToGrammar();
};
#endif /* FSA_FiniteStateAutomaton_HPP_ */