-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDFA.cpp
More file actions
43 lines (36 loc) · 707 Bytes
/
DFA.cpp
File metadata and controls
43 lines (36 loc) · 707 Bytes
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
#include "DFA.h"
DFA::DFA()
{
startState = nullptr;
}
bool DFA::addState(CombinedState *state)
{
this->allStates.push_back(state);
if (state->isAccepting)
{
this->acceptingStates.push_back(state);
}
return true;
}
bool DFA::setStartState(CombinedState *state)
{
this->startState = state;
return true;
}
bool DFA::addTransition(CombinedState *from, char c, CombinedState *to)
{
from->transitions[c] = to;
return true;
}
vector<CombinedState *> DFA::getAllStates()
{
return this->allStates;
}
vector<CombinedState *> DFA::getAcceptingStates()
{
return this->acceptingStates;
}
CombinedState *DFA::getStartState()
{
return this->startState;
}