diff options
| author | 2026-11-08 05:23:31 +0000 | |
|---|---|---|
| committer | 2026-11-08 05:24:55 +0000 | |
| commit | 3f36aca66e1ac6c872300059e8db691a473614d4 (patch) | |
| tree | 48c65f463c487d281c7c4091c7ba01dd4a2ff8f1 /src/fsm.h | |
| download | lab-02-3f36aca66e1ac6c872300059e8db691a473614d4.tar.gz | |
Diffstat (limited to 'src/fsm.h')
| -rw-r--r-- | src/fsm.h | 25 |
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 | |||
| 15 | typedef uint8_t state; | ||
| 16 | typedef uint8_t symbol; | ||
| 17 | |||
| 18 | extern state state_transition_table[STATE_COUNT][ALPHABET_SYMBOL_COUNT]; | ||
| 19 | extern state set_of_final_states[FINAL_STATE_COUNT]; | ||
| 20 | extern uint8_t bitarray_of_final_states[(STATE_COUNT + 7)/8]; | ||
| 21 | |||
| 22 | bool fsm_match (const char *input); | ||
| 23 | const char *fsm_generate (void); | ||
| 24 | |||
| 25 | #endif // INCLUDED_FSM_H | ||
