# swiftlang/swift-experimental-string-processing architecture

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

- Interactive diagram: https://gitdiagram.com/swiftlang/swift-experimental-string-processing
- Repository: https://github.com/swiftlang/swift-experimental-string-processing

## Overview

Key Components to Include in the System Design:

##### Core Processing Components
a. _RegexParser (Top Level)
b. _StringProcessing (Middle Level)
c. _CUnicode (Bottom Level)

##### Compiler Integration Layer
- How _RegexParser is integrated into both:
a. Swift Compiler (SwiftCompilerSources)
b. Core Library (stdlib)

##### Main Processing Pipeline
- Input String/Regex → Parser → AST → Compiler → Bytecode → Execution Engine

##### Component Details

- AST Components
- Parser Components
- Semantic Analysis
- Diagnostics

- Algorithms
- Engine
- Unicode Support
- Regex Implementation
- Matching Components

- Unicode Data
- Character Properties
- Script Data

- RegexBuilder (DSL Interface)
- RegexBenchmark
- Test Infrastructure
- Documentation System

Design Guidelines:

##### Specific Elements
- Version compatibility indicators
- ABI stability boundaries
- Public API surfaces
- Internal module dependencies

##### Technical Details
- Module boundaries
- API access levels
- Build configuration requirements
- Integration points with Swift toolchain

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Compiler Integration"
        SwiftCompiler["Swift Compiler (SwiftCompilerSources)"]
        Stdlib["Core Library (stdlib)"]
    end

    subgraph "Core Processing Pipeline"
        Input["Input String/Regex"]
        Parser["Parser"]:::parser
        AST["AST"]
        Compiler["Compiler"]:::compiler
        Bytecode["Bytecode"]
        ExecEngine["Execution Engine"]:::engine
    end

    subgraph "Core Modules"
        subgraph "RegexParser"
            ASTComp["AST Components"]:::ast
            ParserComp["Parser Components"]:::parser
            SemanticAnalysis["Semantic Analysis"]
            Diagnostics["Diagnostics"]:::diag
        end

        subgraph "StringProcessing"
            Algorithms["Algorithms"]:::algo
            Engine["Engine"]:::engine
            Unicode["Unicode Support"]:::unicode
            RegexImpl["Regex Implementation"]:::regex
            Matching["Matching Components"]:::matching
        end

        subgraph "CUnicode"
            UnicodeData["Unicode Data"]:::unicode
            CharProps["Character Properties"]:::unicode
            ScriptData["Script Data"]:::unicode
        end
    end

    subgraph "Supporting Components"
        RegexBuilder["RegexBuilder DSL"]:::support
        RegexBenchmark["RegexBenchmark"]:::support
        TestInfra["Test Infrastructure"]:::support
        Docs["Documentation System"]:::support
    end

    %% Relationships
    SwiftCompiler <--> RegexParser
    Stdlib <--> RegexParser
    Input --> Parser --> AST --> Compiler --> Bytecode --> ExecEngine
    RegexParser --> StringProcessing --> CUnicode

    %% Click Events
    click ASTComp "https://github.com/swiftlang/swift-experimental-string-processing/tree/main/Sources/_RegexParser/Regex/AST/"
    click ParserComp "https://github.com/swiftlang/swift-experimental-string-processing/tree/main/Sources/_RegexParser/Regex/Parse/"
    click Diagnostics "https://github.com/swiftlang/swift-experimental-string-processing/blob/main/Sources/_RegexParser/Regex/Parse/Diagnostics.swift"
    click Algorithms "https://github.com/swiftlang/swift-experimental-string-processing/tree/main/Sources/_StringProcessing/Algorithms/"
    click Engine "https://github.com/swiftlang/swift-experimental-string-processing/tree/main/Sources/_StringProcessing/Engine/"
    click Unicode "https://github.com/swiftlang/swift-experimental-string-processing/tree/main/Sources/_StringProcessing/Unicode/"
    click RegexImpl "https://github.com/swiftlang/swift-experimental-string-processing/tree/main/Sources/_StringProcessing/Regex/"
    click Matching "https://github.com/swiftlang/swift-experimental-string-processing/tree/main/Sources/_StringProcessing/Algorithms/Matching/"
    click UnicodeData "https://github.com/swiftlang/swift-experimental-string-processing/blob/main/Sources/_CUnicode/UnicodeData.c"
    click CharProps "https://github.com/swiftlang/swift-experimental-string-processing/blob/main/Sources/_CUnicode/include/UnicodeData.h"
    click ScriptData "https://github.com/swiftlang/swift-experimental-string-processing/blob/main/Sources/_CUnicode/Common/ScriptData.h"
    click RegexBuilder "https://github.com/swiftlang/swift-experimental-string-processing/tree/main/Sources/RegexBuilder/"
    click RegexBenchmark "https://github.com/swiftlang/swift-experimental-string-processing/tree/main/Sources/RegexBenchmark/"
    click Docs "https://github.com/swiftlang/swift-experimental-string-processing/tree/main/Documentation/"
    click TestInfra "https://github.com/swiftlang/swift-experimental-string-processing/tree/main/Tests/"
    click Parser "https://github.com/swiftlang/swift-experimental-string-processing/blob/main/Sources/_RegexParser/Regex/Parse/Parse.swift"
    click Compiler "https://github.com/swiftlang/swift-experimental-string-processing/blob/main/Sources/_StringProcessing/Compiler.swift"
    click Bytecode "https://github.com/swiftlang/swift-experimental-string-processing/blob/main/Sources/_StringProcessing/ByteCodeGen.swift"
    click ExecEngine "https://github.com/swiftlang/swift-experimental-string-processing/blob/main/Sources/_StringProcessing/Engine/Processor.swift"

    %% Styling
    classDef parser fill:#e6ccff,stroke:#333
    classDef ast fill:#d9b3ff,stroke:#333
    classDef compiler fill:#cc99ff,stroke:#333
    classDef engine fill:#bf80ff,stroke:#333
    classDef algo fill:#80b3ff,stroke:#333
    classDef unicode fill:#99ff99,stroke:#333
    classDef regex fill:#ff99cc,stroke:#333
    classDef matching fill:#ffb366,stroke:#333
    classDef support fill:#gray,stroke:#333
    classDef diag fill:#ff8080,stroke:#333

    %% Legend
    subgraph Legend
        L1["Parser Components"]:::parser
        L2["AST Components"]:::ast
        L3["Engine Components"]:::engine
        L4["Unicode Processing"]:::unicode
        L5["Support Tools"]:::support
    end
```
