-
Notifications
You must be signed in to change notification settings - Fork 0
/
state.cpp
41 lines (35 loc) · 810 Bytes
/
state.cpp
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
#include "state.h"
state::state(char state, char input, char stack, bool isInitial)
{
internal_state = state;
current_input = input;
top_of_stack = stack;
initial_state = isInitial;
}
// compare two states for equality
bool state::statecmp(char state, char input, char stack)
{
if (internal_state == state && current_input == input && top_of_stack == stack)
return true;
else
return false;
}
vector<transition> state::getTransitions()
{
return state_transitions;
}
void state::addTransition(char next_state, char stack_operator, char stack_input)
{
state_transitions.push_back(transition(next_state, stack_operator, stack_input));
}
char state::getState()
{
return internal_state;
}
bool state::isInitial()
{
if (initial_state)
return true;
else
return false;
}