# verihogg/verihogg-format architecture

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

- Interactive diagram: https://gitdiagram.com/verihogg/verihogg-format
- Repository: https://github.com/verihogg/verihogg-format

## Overview

verihogg-format is a SystemVerilog source formatter. Users provide source through stdin or file paths and receive formatted text on stdout or, with `--inplace`, updated files. The CLI binds run options; source is lexed, normalized, unwrapped into logical lines, annotated, assigned layout policies, joined/aligned, and printed. The README documents indentation and tabular alignment; line wrapping is described as not yet implemented, although a wrap-search stage is present in the source pipeline. Runner internals were not sampled, so file-processing links reflect the documented workflow rather than inspected implementation details.

Main entry points: [`formatter/src/formatter.cpp`](https://github.com/verihogg/verihogg-format/blob/main/formatter/src/formatter.cpp) (Format orchestrator), [`formatter/src/main.cpp`](https://github.com/verihogg/verihogg-format/blob/main/formatter/src/main.cpp) (CLI entry), [`formatter/src/pipeline/runner.cpp`](https://github.com/verihogg/verihogg-format/blob/main/formatter/src/pipeline/runner.cpp) (File runner), [`formatter/src/data/lex_context.cpp`](https://github.com/verihogg/verihogg-format/blob/main/formatter/src/data/lex_context.cpp) (Source lexer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli_io["CLI and input"]
  node_cli["CLI entry<br/>[main.cpp]"]
  node_args["Argument binding<br/>[format_args.cpp]"]
  node_input["Source files or stdin"]
end

subgraph group_lexical["Lexical preparation"]
  node_lex_context["Source lexer<br/>[lex_context.cpp]"]
  node_slang["slang lexer"]
  node_normalizer["Token normalizer"]
end

subgraph group_formatting["Formatting pipeline"]
  node_formatter["Format orchestrator<br/>[formatter.cpp]"]
  node_unwrapper["Tree unwrapper<br/>[tree_unwrapper.cpp]"]
  node_annotator["Token annotator"]
  node_policies["Policy assignment"]
  node_joiner["Line joiner<br/>[line_joiner.cpp]"]
  node_aligner["Tabular aligner"]
  node_wrap_search["Wrap search"]
  node_printer["Text printer<br/>[printer.cpp]"]
end

subgraph group_delivery["Output delivery"]
  node_runner["File runner<br/>[runner.cpp]"]
  node_output["Formatted output"]
end

node_user(("Formatter user"))
node_filesystem[("File system")]
node_console(("Console"))

node_user -->|"invokes"| node_cli
node_input -->|"provides source"| node_cli
node_cli -->|"binds options"| node_args
node_cli -->|"lexes stdin"| node_lex_context
node_lex_context -->|"uses lexer"| node_slang
node_cli -->|"formats stdin"| node_formatter
node_cli -->|"dispatches files"| node_runner
node_runner -->|"formats files"| node_formatter
node_runner -->|"reads or overwrites"| node_filesystem
node_formatter -->|"normalizes tokens"| node_normalizer
node_formatter -->|"unwraps tokens"| node_unwrapper
node_formatter -->|"annotates lines"| node_annotator
node_formatter -->|"assigns policies"| node_policies
node_formatter -->|"joins lines"| node_joiner
node_formatter -->|"aligns columns"| node_aligner
node_formatter -->|"searches wraps"| node_wrap_search
node_formatter -->|"prints lines"| node_printer
node_formatter -->|"produces text"| node_output
node_runner -->|"writes output"| node_console
node_cli -->|"writes stdin output"| node_console

click node_cli "https://github.com/verihogg/verihogg-format/blob/main/formatter/src/main.cpp"
click node_args "https://github.com/verihogg/verihogg-format/blob/main/formatter/src/pipeline/format_args.cpp"
click node_runner "https://github.com/verihogg/verihogg-format/blob/main/formatter/src/pipeline/runner.cpp"
click node_lex_context "https://github.com/verihogg/verihogg-format/blob/main/formatter/src/data/lex_context.cpp"
click node_normalizer "https://github.com/verihogg/verihogg-format/blob/main/formatter/src/pipeline/token_normalizer.cpp"
click node_formatter "https://github.com/verihogg/verihogg-format/blob/main/formatter/src/formatter.cpp"
click node_unwrapper "https://github.com/verihogg/verihogg-format/blob/main/formatter/src/pipeline/tree_unwrapper.cpp"
click node_annotator "https://github.com/verihogg/verihogg-format/blob/main/formatter/src/pipeline/token_annotator.cpp"
click node_policies "https://github.com/verihogg/verihogg-format/blob/main/formatter/src/pipeline/policy_assigner.cpp"
click node_joiner "https://github.com/verihogg/verihogg-format/blob/main/formatter/src/pipeline/line_joiner.cpp"
click node_aligner "https://github.com/verihogg/verihogg-format/blob/main/formatter/src/pipeline/tabular_aligner.cpp"
click node_wrap_search "https://github.com/verihogg/verihogg-format/blob/main/formatter/src/pipeline/line_wrap_searcher.cpp"
click node_printer "https://github.com/verihogg/verihogg-format/blob/main/formatter/src/pipeline/printer.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_args,node_input,node_user toneBlue
class node_lex_context,node_slang,node_normalizer,node_filesystem toneAmber
class node_formatter,node_unwrapper,node_annotator,node_policies,node_joiner,node_aligner,node_wrap_search,node_printer toneMint
class node_runner,node_output toneRose
class node_console toneIndigo
```

## Components

### CLI and input

- [CLI entry](https://github.com/verihogg/verihogg-format/blob/main/formatter/src/main.cpp): `formatter/src/main.cpp`
- [Argument binding](https://github.com/verihogg/verihogg-format/blob/main/formatter/src/pipeline/format_args.cpp): `formatter/src/pipeline/format_args.cpp`
- **Source files or stdin**

### Lexical preparation

- [Source lexer](https://github.com/verihogg/verihogg-format/blob/main/formatter/src/data/lex_context.cpp): `formatter/src/data/lex_context.cpp`
- **slang lexer**
- [Token normalizer](https://github.com/verihogg/verihogg-format/blob/main/formatter/src/pipeline/token_normalizer.cpp): `formatter/src/pipeline/token_normalizer.cpp`

### Formatting pipeline

- [Format orchestrator](https://github.com/verihogg/verihogg-format/blob/main/formatter/src/formatter.cpp): `formatter/src/formatter.cpp`
- [Tree unwrapper](https://github.com/verihogg/verihogg-format/blob/main/formatter/src/pipeline/tree_unwrapper.cpp): `formatter/src/pipeline/tree_unwrapper.cpp`
- [Token annotator](https://github.com/verihogg/verihogg-format/blob/main/formatter/src/pipeline/token_annotator.cpp): `formatter/src/pipeline/token_annotator.cpp`
- [Policy assignment](https://github.com/verihogg/verihogg-format/blob/main/formatter/src/pipeline/policy_assigner.cpp): `formatter/src/pipeline/policy_assigner.cpp`
- [Line joiner](https://github.com/verihogg/verihogg-format/blob/main/formatter/src/pipeline/line_joiner.cpp): `formatter/src/pipeline/line_joiner.cpp`
- [Tabular aligner](https://github.com/verihogg/verihogg-format/blob/main/formatter/src/pipeline/tabular_aligner.cpp): `formatter/src/pipeline/tabular_aligner.cpp`
- [Wrap search](https://github.com/verihogg/verihogg-format/blob/main/formatter/src/pipeline/line_wrap_searcher.cpp): `formatter/src/pipeline/line_wrap_searcher.cpp`
- [Text printer](https://github.com/verihogg/verihogg-format/blob/main/formatter/src/pipeline/printer.cpp): `formatter/src/pipeline/printer.cpp`

### Output delivery

- [File runner](https://github.com/verihogg/verihogg-format/blob/main/formatter/src/pipeline/runner.cpp): `formatter/src/pipeline/runner.cpp`
- **Formatted output**

### Other components

- **Formatter user**
- **File system**
- **Console**

## Connections

- Formatter user → CLI entry: invokes
- Source files or stdin → CLI entry: provides source
- CLI entry → Argument binding: binds options
- CLI entry → Source lexer: lexes stdin
- Source lexer → slang lexer: uses lexer
- CLI entry → Format orchestrator: formats stdin
- CLI entry → File runner: dispatches files
- File runner → Format orchestrator: formats files
- File runner → File system: reads or overwrites
- Format orchestrator → Token normalizer: normalizes tokens
- Format orchestrator → Tree unwrapper: unwraps tokens
- Format orchestrator → Token annotator: annotates lines
- Format orchestrator → Policy assignment: assigns policies
- Format orchestrator → Line joiner: joins lines
- Format orchestrator → Tabular aligner: aligns columns
- Format orchestrator → Wrap search: searches wraps
- Format orchestrator → Text printer: prints lines
- Format orchestrator → Formatted output: produces text
- File runner → Console: writes output
- CLI entry → Console: writes stdin output
