# feni/informal architecture

> Architecture diagram of the GitHub repository feni/informal, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/feni/informal
- Repository: https://github.com/feni/informal

## Overview

##### Main Components

a) Compiler Infrastructure:
- Former (Zig-based implementation)
- Multiple prototype implementations (JS, Python, Rust)
- Core language components (lexer, parser, compiler)

b) Runtime Systems:
- JavaScript runtime
- Rust runtime
- WASM integration

c) Development Tools:
- Testing framework
- Benchmarking system
- Documentation system

- Informal Language           |

- Former    |  |   Prototypes    |   |
- (Zig Core)  |  | (JS/Rust/Python)|   |

- Compiler Pipeline               |

- Lexer  |->| Parser |->| AST    |->|Code Gen| |

- Runtime Systems              |

- JS Runtime|  |  Rust   |  | WASM   | |

##### Important Elements to Highlight

a) Pattern Matching System:
- How it's central to the language design
- Connections to type system and runtime

b) Multiple Implementation Paths:
- How different prototypes relate
- Shared components

c) Build and Test Infrastructure:
- Test framework connections
- Benchmark system integration

##### Specific Implementation Details

Key architectural components:
- Pattern matching engine
- Type system
- Meta-programming facilities
- Runtime environments
- WASM compilation target

##### Component Relationships

Critical interactions:
- Source code → Lexer → Parser → AST
- AST → Pattern Matcher → Type Checker
- Compiler → Multiple Backends (JS/Rust/WASM)
- Runtime ↔ Standard Library
- Meta-programming System ↔ Compiler Pipeline

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core["Core Language Implementation"]
        Former["Former (Zig Core)"]:::core
        Prototypes["Prototypes"]:::core
        
        subgraph ProtoImpl["Implementation Variants"]
            JSProto["JavaScript Prototype"]:::proto
            PythonProto["Python Prototype"]:::proto
            RustProto["Rust Prototype"]:::proto
        end
    end

    subgraph Pipeline["Compiler Pipeline"]
        Lexer["Lexer"]:::compiler
        Parser["Parser"]:::compiler
        AST["AST"]:::compiler
        CodeGen["Code Generation"]:::compiler
        
        Lexer --> Parser
        Parser --> AST
        AST --> CodeGen
    end

    subgraph Runtime["Runtime Systems"]
        JSRuntime["JavaScript Runtime"]:::runtime
        RustRuntime["Rust Runtime"]:::runtime
        WASM["WASM Integration"]:::runtime
    end

    subgraph Tools["Development Infrastructure"]
        Testing["Testing Framework"]:::tools
        Benchmarks["Benchmarking System"]:::tools
        Docs["Documentation"]:::tools
    end

    subgraph Core_Features["Core Language Features"]
        PatternMatch["Pattern Matching System"]:::feature
        TypeSystem["Type System"]:::feature
        MetaProg["Meta-programming Facilities"]:::feature
    end

    Former --> Pipeline
    Prototypes --> ProtoImpl
    ProtoImpl --> Pipeline
    
    AST --> PatternMatch
    PatternMatch --> TypeSystem
    CodeGen --> JSRuntime
    CodeGen --> RustRuntime
    CodeGen --> WASM
    
    MetaProg -.-> Pipeline

    classDef core fill:#2374ab
    classDef proto fill:#2374ab,stroke-dasharray: 5 5
    classDef compiler fill:#147bd1
    classDef runtime fill:#43aa8b
    classDef tools fill:#f8961e
    classDef feature fill:#9c89b8

    click Former "https://github.com/feni/informal/blob/main/Sources/Former/src/main.zig"
    click Lexer "https://github.com/feni/informal/blob/main/Sources/Former/src/lexer.zig"
    click Parser "https://github.com/feni/informal/blob/main/Sources/Former/src/parser.zig"
    click JSProto "https://github.com/feni/informal/tree/main/Sources/Prototypes/js/src/compiler/"
    click PythonProto "https://github.com/feni/informal/blob/main/Sources/Prototypes/python/informal.py"
    click RustProto "https://github.com/feni/informal/tree/main/Sources/Prototypes/rust/runtime/src/"
    click JSRuntime "https://github.com/feni/informal/tree/main/Sources/Prototypes/js/src/runtime/"
    click RustRuntime "https://github.com/feni/informal/tree/main/Sources/Prototypes/rust/runtime/"
    click WASM "https://github.com/feni/informal/tree/main/Sources/Prototypes/js/src/wasm/"
    click AST "https://github.com/feni/informal/blob/main/Sources/Prototypes/js/src/shared/ast.js"
    click Testing "https://github.com/feni/informal/tree/main/Tests/"
    click Benchmarks "https://github.com/feni/informal/tree/main/Benchmarks/"
    click Docs "https://github.com/feni/informal/tree/main/Documentation/"
    click PatternMatch "https://github.com/feni/informal/blob/main/Sources/Prototypes/python/patc.py"
    click MetaProg "https://github.com/feni/informal/blob/main/Sources/Prototypes/js/src/compiler/macro.js"
```
