# jayagarsi/regex-parser architecture

> Architecture diagram of the GitHub repository jayagarsi/regex-parser, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jayagarsi/regex-parser
- Repository: https://github.com/jayagarsi/regex-parser

## Overview

regex-parser is a C++ regular-expression parser and NFA-based matcher, exposed through both an interactive executable and WebAssembly bindings. The main workflow accepts a pattern, parses it into an AST, builds an NFA, and tests input strings against that automaton. The README also describes AST/NFA printing and a WebAssembly version; the sampled bindings additionally expose diagram generation. Web UI implementation and deployment wiring are not present in the sampled source, so those connections are not inferred.

Main entry points: [`src/wasm_bindings.cpp`](https://github.com/jayagarsi/regex-parser/blob/main/src/wasm_bindings.cpp) (WASM bindings), [`src/RegExParser.cpp`](https://github.com/jayagarsi/regex-parser/blob/main/src/RegExParser.cpp) (Regex facade), [`src/AutomataManager.cpp`](https://github.com/jayagarsi/regex-parser/blob/main/src/AutomataManager.cpp) (NFA builder), [`src/Parser.cpp`](https://github.com/jayagarsi/regex-parser/blob/main/src/Parser.cpp) (Recursive parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_cli["Interactive CLI<br/>[main.cpp]"]
  node_api["Regex facade<br/>[RegExParser.cpp]"]
end

subgraph group_parse["Parsing"]
  node_parser["Recursive parser<br/>[Parser.cpp]"]
  node_ast["Regex AST<br/>[Parser.hh]"]
end

subgraph group_engine["Automata Engine"]
  node_automata["NFA builder"]
  node_nfa["NFA states<br/>[AutomataManager.hh]"]
  node_matcher["NFA simulator"]
end

subgraph group_wasm["WebAssembly API"]
  node_wasm["WASM bindings<br/>[wasm_bindings.cpp]"]
end

node_user(("CLI user"))
node_js(("JavaScript caller"))

node_user -->|"enters pattern"| node_cli
node_cli -->|"calls"| node_api
node_api -->|"parses pattern"| node_parser
node_parser -->|"builds"| node_ast
node_api -->|"builds NFA"| node_automata
node_automata -->|"traverses"| node_ast
node_automata -->|"creates states"| node_nfa
node_api -->|"checks input"| node_matcher
node_matcher -->|"simulates"| node_nfa
node_js -->|"calls exports"| node_wasm
node_wasm -->|"parses pattern"| node_parser
node_wasm -->|"builds NFA"| node_automata
node_wasm -->|"checks input"| node_matcher
node_wasm -->|"renders AST diagram"| node_ast
node_wasm -->|"renders NFA diagram"| node_nfa

click node_cli "https://github.com/jayagarsi/regex-parser/blob/main/src/main.cpp"
click node_api "https://github.com/jayagarsi/regex-parser/blob/main/src/RegExParser.cpp"
click node_parser "https://github.com/jayagarsi/regex-parser/blob/main/src/Parser.cpp"
click node_ast "https://github.com/jayagarsi/regex-parser/blob/main/src/Parser.hh"
click node_automata "https://github.com/jayagarsi/regex-parser/blob/main/src/AutomataManager.cpp"
click node_nfa "https://github.com/jayagarsi/regex-parser/blob/main/src/AutomataManager.hh"
click node_matcher "https://github.com/jayagarsi/regex-parser/blob/main/src/AutomataManager.cpp"
click node_wasm "https://github.com/jayagarsi/regex-parser/blob/main/src/wasm_bindings.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_api,node_user toneBlue
class node_parser,node_ast toneAmber
class node_automata,node_nfa,node_matcher toneMint
class node_wasm toneRose
class node_js toneIndigo
```

## Components

### User Interfaces

- [Interactive CLI](https://github.com/jayagarsi/regex-parser/blob/main/src/main.cpp): `src/main.cpp`
- [Regex facade](https://github.com/jayagarsi/regex-parser/blob/main/src/RegExParser.cpp): `src/RegExParser.cpp`

### Parsing

- [Recursive parser](https://github.com/jayagarsi/regex-parser/blob/main/src/Parser.cpp): `src/Parser.cpp`
- [Regex AST](https://github.com/jayagarsi/regex-parser/blob/main/src/Parser.hh): `src/Parser.hh`

### Automata Engine

- [NFA builder](https://github.com/jayagarsi/regex-parser/blob/main/src/AutomataManager.cpp): `src/AutomataManager.cpp`
- [NFA states](https://github.com/jayagarsi/regex-parser/blob/main/src/AutomataManager.hh): `src/AutomataManager.hh`
- [NFA simulator](https://github.com/jayagarsi/regex-parser/blob/main/src/AutomataManager.cpp): `src/AutomataManager.cpp`

### WebAssembly API

- [WASM bindings](https://github.com/jayagarsi/regex-parser/blob/main/src/wasm_bindings.cpp): `src/wasm_bindings.cpp`

### Other components

- **CLI user**
- **JavaScript caller**

## Connections

- CLI user → Interactive CLI: enters pattern
- Interactive CLI → Regex facade: calls
- Regex facade → Recursive parser: parses pattern
- Recursive parser → Regex AST: builds
- Regex facade → NFA builder: builds NFA
- NFA builder → Regex AST: traverses
- NFA builder → NFA states: creates states
- Regex facade → NFA simulator: checks input
- NFA simulator → NFA states: simulates
- JavaScript caller → WASM bindings: calls exports
- WASM bindings → Recursive parser: parses pattern
- WASM bindings → NFA builder: builds NFA
- WASM bindings → NFA simulator: checks input
- WASM bindings → Regex AST: renders AST diagram
- WASM bindings → NFA states: renders NFA diagram
