Skip to content
kshkuPublic

About

DFA and NFA simulator

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

30 Commits

Folders and files

Repository files navigation

StateFlow

DFA and NFA simulator

Building

Clone the repo and initialize the submodules

git clone --recurse-submodules https://github.com/kshku/StateFlow.git
cd StateFlow

or

git clone https://github.com/kshku/StateFlow.git
cd StateFlow
git submodule update --init --recursive

Build using CMake

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j 8

To run

./build/stateflow

How to Use

From 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 with ab
  • end_ab_nfa.fsm – NFA example that accepts strings ending with ba

Editor

  • 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.

Navigation

  • Left-click or Middle-click + drag → pan around the canvas
  • Scroll → zoom in/out
  • Keys: WASD, arrow keys, or HJKL → pan around the canvas

Node Mode

  • 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

Transition Mode

  1. Click From box → select starting node
  2. Enter input (each character is one symbol; multiple characters allowed per transition)
  3. Click To box → select target node
  4. Click Add button → add transition
  • Press Delete → delete selected transition line

Simulation

  • 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).

Saving & Loading

  • Click Save to save the current FSM (file must end with .fsm).
  • Use Load to open an existing .fsm file.

Animation

  • Enter input string in the text box.
  • Click Start Animation to animate the FSM step-by-step.

Quick Reference

  • Backspace → go back
  • Delete → delete selected node/transition
  • Right-click → add new node
  • Middle/Left-drag → move around canvas
  • Scroll → zoom in/out

About

DFA and NFA simulator

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages