How ashqqy/formal works
formal is a C++23 regular-expression parsing and presentation library. Its main workflow takes a pattern through lexing and recursive-descent parsing into an expression tree, then exposes canonical text and Graphviz DOT output. The README also documents an example CLI that prints these representations. The graph focuses on runtime library behavior; automata files exist, but no documented or excerpted workflow connects them to the public regex API. Edges are limited to calls or references visible in excerpts, the source index, or README.
Main entry points: lexer.hpp Lexer · regex.hpp Regex API · parser.hpp Parser · node.hpp Regex tree nodes
Components 19
Public API
- Regex API
src/regex.hpp
Regex Syntax
- Lexer
src/regex/lexer.hpp - Parser
src/regex/parser.hpp - Syntax errors
src/regex/error.hpp - Tokens
src/regex/token.hpp - Source positions
src/regex/position.hpp
Expression Tree
- Regex tree nodes
src/regex/node.hpp - Tree visitor
src/regex/visitor.hpp - NFA state model
src/automata/nfa.hpp - Automaton state
src/automata/state.hpp
Output Formatting
- Canonical printer
src/regex/printer.hpp - DOT printer
src/regex/dot.hpp - DOT helpers
src/util/dot.hpp
Symbol Utilities
- Allowed alphabet
src/util/alphabet.hpp - ASCII utilities
src/util/ascii.hpp - Symbol type
src/util/symbol.hpp - Symbol escaping
src/util/symbol_print.hpp
Other components
- Library user
- formal_print CLI
examples/print.cpp
Connections 22
- Library user → Regex API: constructs regex
README.md - Regex API → Parser: parses pattern
src/regex.hpp - Parser → Lexer: requests tokens
src/regex/parser.hpp - Parser → Regex tree nodes: builds tree
src/regex/parser.hpp - Lexer → Tokens: emits tokens
src/regex/lexer.hpp - Lexer → Syntax errors: throws errors
src/regex/lexer.hpp - Parser → Syntax errors: throws errors
src/regex/parser.hpp - Lexer → Allowed alphabet: checks symbols
src/regex/lexer.hpp - Lexer → Source positions: tracks offsets
src/regex/lexer.hpp - Tokens → Source positions: stores position
src/regex/token.hpp - Regex API → Canonical printer: formats text
src/regex.hpp - Regex API → DOT printer: formats DOT
src/regex.hpp - Canonical printer → Regex tree nodes: visits tree
src/regex/printer.hpp - DOT printer → Regex tree nodes: visits tree
src/regex/dot.hpp - DOT printer → DOT helpers: uses helpers
src/regex/dot.hpp - Regex tree nodes → Tree visitor: dispatches visits
src/regex/node.hpp - Lexer → ASCII utilities: skips whitespace
src/regex/lexer.hpp - Lexer → Symbol escaping: escapes errors
src/regex/lexer.hpp - Symbol escaping → ASCII utilities: checks printability
src/util/symbol_print.hpp - Allowed alphabet → Symbol type: stores symbols
src/util/alphabet.hpp - formal_print CLI → Regex API: prints representations
README.md - NFA state model → Automaton state: uses states
src/automata/nfa.hpp