# antonbergaker/interpolatedparser architecture

> Architecture diagram of the GitHub repository antonbergaker/interpolatedparser, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/antonbergaker/interpolatedparser
- Repository: https://github.com/antonbergaker/interpolatedparser

## Overview

Key Components to Include:

##### Compile-Time Components
- A "Parser Call Analyzer" component that collects information about Parse method calls
- "Code Generation" component that produces the runtime parser implementation

##### Runtime Components
- Custom Interpolated String Handler
- Parser Implementation
- Type Parsing System

##### Main Sections
Create two main sections separated by a horizontal line:
- Top: Compile Time
- Bottom: Runtime

##### Compile-Time Flow (Top Section)
- [User Code] -> [Source Generator]

- v
- [Parser Call Analyzer] -> [Code Generation]

- v
- [Generated Parser Implementation]

##### Runtime Flow (Bottom Section)
- [Input String] -> [Custom String Handler] -> [Parser Implementation]

- v
- [Type Parsing System] <- [Reference Manipulation]

- Use blue for compile-time components
- Use green for runtime components
- Use red for critical security/unsafe operations
- Use yellow for data flow paths

Important Elements to Highlight:

##### Compile-Time Features
- CallerFilePath and CallerLineNumber attribute usage
- Parse method call analysis
- Generated code placement

##### Runtime Features
- Custom interpolated string handler implementation
- Unsafe.AsRef operations
- IParseable<T> and ISpanParseable<T> support

Special Notes:
- Unsafe.AsRef operation with a warning symbol
- Line number limitation with an information symbol
- Relationship between generated code and runtime parser

Technical Details to Include:
- How the parser matches compile-time information with runtime calls
- Where type parsing occurs
- Points where reference manipulation happens

Level of Detail:
- Keep the high-level flow clear while showing technical implementation details
- Enough detail to understand the unique approach of using string interpolation in reverse
- Both the compile-time preparation and runtime execution phases

##### The type system integration

- All symbols used
- Line style meanings
- Warning and information symbols

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef compileTime fill:#b3d1ff,stroke:#4d88ff
    classDef runtime fill:#b3ffb3,stroke:#4d994d
    classDef security fill:#ffb3b3,stroke:#ff4d4d
    classDef dataFlow fill:#fff2b3,stroke:#ffcc00
    classDef warning fill:#ffe6cc,stroke:#ff9933

    %% Legend
    subgraph Legend
        L1[Compile-Time Component]:::compileTime
        L2[Runtime Component]:::runtime
        L3[Security Critical]:::security
        L4[Data Flow]:::dataFlow
        L5[Warning Zone]:::warning
    end

    %% Compile Time Section
    subgraph CompileTime[Compile Time Processing]
        UserCode[User Source Code]:::compileTime
        SourceGen[Source Generator]:::compileTime
        ParserAnalyzer[Parser Call Analyzer]:::compileTime
        CodeGen[Code Generation System]:::compileTime
        GenImpl[Generated Parser Implementation]:::compileTime
    end

    %% Runtime Section
    subgraph Runtime[Runtime Execution]
        InputString[Input String]:::runtime
        StringHandler[Custom String Handler]:::runtime
        ParserImpl[Parser Implementation]:::runtime
        TypeParsing[Type Parsing System]:::runtime
        RefManip[Reference Manipulation]:::security
    end

    %% Relationships
    UserCode --> SourceGen
    SourceGen --> ParserAnalyzer
    ParserAnalyzer --> CodeGen
    CodeGen --> GenImpl
    InputString --> StringHandler
    StringHandler --> ParserImpl
    ParserImpl --> TypeParsing
    ParserImpl --> RefManip
    RefManip --> TypeParsing

    %% Click events for component mapping
    click SourceGen "https://github.com/AntonBergaker/InterpolatedParser/blob/main/InterpolatedParser/InterpolatedParser.Generator.cs"
    click CodeGen "https://github.com/AntonBergaker/InterpolatedParser/blob/main/InterpolatedParser/CodeBuilder.cs"
    click ParserAnalyzer "https://github.com/AntonBergaker/InterpolatedParser/blob/main/InterpolatedParser/ParserCall.cs"
    click TypeParsing "https://github.com/AntonBergaker/InterpolatedParser/blob/main/InterpolatedParser/TypeData.cs"
    click ParserImpl "https://github.com/AntonBergaker/InterpolatedParser/blob/main/InterpolatedParser/InitializationContent.cs"

    %% Notes
    note["⚠️ Warning: Uses unsafe code for reference manipulation"]
    note2["ℹ️ Compile-time line number tracking enabled"]
```
