DFA and NFA simulator
Clone the repo and initialize the submodules
git clone --recurse-submodules https://github.com/kshku/StateFlow.git
cd StateFlowor
git clone https://github.com/kshku/StateFlow.git
cd StateFlow
git submodule update --init --recursiveBuild using CMake
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j 8To run
./build/stateflowFrom the main menu, choose DFA or NFA, or load a previously saved state machine.
Two example files are provided in the project root:
end_ab.fsm– DFA example that accepts strings ending withabend_ab_nfa.fsm– NFA example that accepts strings ending withba
- Alphabet: you can specify the alphabet. Each character (including space) is treated as one letter.
- Modes:
- Node Mode (default) – create and edit nodes.
- Transition Mode – create and edit transition lines.
- Left-click or Middle-click + drag → pan around the canvas
- Scroll → zoom in/out
- Keys:
WASD, arrow keys, orHJKL→ pan around the canvas
- Right-click → add new node
- Select a node to:
- Rename it
- Mark it as start or accepting
- Drag to reposition it
- Press Delete → delete selected node
- Click From box → select starting node
- Enter input (each character is one symbol; multiple characters allowed per transition)
- Click To box → select target node
- Click Add button → add transition
- Press Delete → delete selected transition line
- Click Simulate to validate the FSM.
- If errors exist, they will be reported.
- If valid, the app switches to the animation screen.
- Backspace → return to editor (from animation) or to main menu (from editor).
- Click Save to save the current FSM (file must end with
.fsm). - Use Load to open an existing
.fsmfile.
- Enter input string in the text box.
- Click Start Animation to animate the FSM step-by-step.
- Backspace → go back
- Delete → delete selected node/transition
- Right-click → add new node
- Middle/Left-drag → move around canvas
- Scroll → zoom in/out