How labhansh2/models-of-computation works
Project type and purpose
• This is a C++ “Models of Computation” library and demo application.
• It simulates theoretical automata (DFA, NFA, PDA, etc.) according to their formal definitions.
• The primary consumer is main.cpp, which exercises the library, and the library itself is structured under include/ (interfaces) and moc/ (implementations).
File structure
• Top‑level:
• Makefile – build instructions for compiling the code
• main.cpp – CLI or demo harness that drives the automata simulations
• / – public headers (dfa.h, nfa.h, pda.h) defining each automaton’s interface
• moc/ – source files (dfa.cpp, nfa.cpp, pda.cpp) implementing each automaton
• public/ – static assets (e.g., Automaton.png) for documentation/visuals
• Tooling/config: .clang-format, .gitignore, .vscode settings
README for additional insights
• Confirms the goal: faithful implementations of theoretical models
• Shows a dependency graph of automata types (via the Automaton.png)
• Lists future MOCs to add, implying the library is extensible
Main components
a. Library Layer (“Core MOC Modules”):
• DFA Module
• NFA Module
• PDA Module
• (Future: DPDA, NTM, etc.)
b. Interface Layer (Headers):
• Expose API to construct, configure, and run each automaton
c. Application Layer:
• main.cpp – user entry point; parses input, invokes library, displays results
d. Build & Configuration:
• Makefile orchestrates compilation of moc/*.cpp + main.cpp
• .clang-format/.vscode control formatting and editor behavior
e. Documentation Assets:
• public/Automaton.png used in README
Relationships and data flow
• main.cpp → includes header → invokes methods on MOC classes → MOC classes hold state/transitions → produce acceptance/rejection results → main.cpp prints output
• Makefile → compiles sources → links object files → produces executable
Important architectural patterns & design principles
• Separation of interface (headers) and implementation (source)
• Modular design: each MOC lives in its own namespace/file pair
• Extensibility: new automaton modules drop in under include/ + moc/ and get built automatically
• Single‑responsibility: main.cpp only drives the library; library does not handle I/O