aboutsummaryrefslogtreecommitdiff
path: root/src/fsm.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/fsm.h')
-rw-r--r--src/fsm.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/fsm.h b/src/fsm.h
new file mode 100644
index 0000000..d712d0b
--- /dev/null
+++ b/src/fsm.h
@@ -0,0 +1,25 @@
1#ifndef INCLUDED_FSM_H
2#define INCLUDED_FSM_H
3
4#include <stdint.h>
5#include <stdbool.h>
6
7#define C2A(C) ((C) - '!') // char to alphabet
8#define A2C(A) ((A) + '!') // alphabet to char
9
10#define INITIAL_STATE 1
11#define STATE_COUNT 77
12#define FINAL_STATE_COUNT 5
13#define ALPHABET_SYMBOL_COUNT (C2A ('~') + 1)
14
15typedef uint8_t state;
16typedef uint8_t symbol;
17
18extern state state_transition_table[STATE_COUNT][ALPHABET_SYMBOL_COUNT];
19extern state set_of_final_states[FINAL_STATE_COUNT];
20extern uint8_t bitarray_of_final_states[(STATE_COUNT + 7)/8];
21
22bool fsm_match (const char *input);
23const char *fsm_generate (void);
24
25#endif // INCLUDED_FSM_H