# rdstudios9145/foxlang architecture

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

- Interactive diagram: https://gitdiagram.com/rdstudios9145/foxlang
- Repository: https://github.com/rdstudios9145/foxlang

## Overview

##### Main Components

a) Frontend Pipeline:
- Lexical Analysis (Tokenizer)
- Syntax Analysis (Parser)
- Abstract Syntax Tree (AST)

b) Backend Pipeline:
- LLVM Integration (implied by README mention)

##### Component Organization

**Source Code -> Lexer -> Parser -> AST -> LLVM Backend -> Machine Code**

##### Detailed Component Breakdown

a) Lexer Component (src/lexer/):
- Connection to Tokens definition
- TokenStreamer as an intermediate component

b) Parser Component (src/ast/):
- Parser to AST Nodes
- AST generation flow

c) LLVM Integration:
- Interface between AST and LLVM IR

##### Important Details

- File extension ".fox" as input
- Emoji support (🦊) in the lexer component
- Premake build system integration
- A note about LLVM dependency

##### Relationships to Emphasize

- Token stream flow from Lexer to Parser
- AST construction in the Parser
- Data transformation between stages

##### Implementation Details

- tokenizer.hpp/cpp and tokens.hpp
- parser.hpp/cpp and nodes.hpp
- Main program flow starting from main.cpp

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        SRC[".fox Source Code"]
    end

    subgraph "Frontend Pipeline"
        LEX["Lexical Analyzer (Tokenizer)"]:::frontend
        TOK["Token Definitions"]:::data
        TSTR["Token Streamer"]:::frontend
        PAR["Parser"]:::frontend
        AST["AST Nodes"]:::data
    end

    subgraph "Backend Pipeline"
        LLVM["LLVM Integration"]:::backend
        MC["Machine Code"]:::output
    end

    subgraph "Build System"
        PM["Premake Build System"]:::build
    end

    %% Relationships
    SRC --> LEX
    LEX --> TOK
    TOK --> TSTR
    TSTR --> PAR
    PAR --> AST
    AST --> LLVM
    LLVM --> MC
    PM -.-> SRC

    %% Click Events
    click LEX "https://github.com/RdStudios9145/FoxLang/blob/main/src/lexer/tokenizer.hpp"
    click TOK "https://github.com/RdStudios9145/FoxLang/blob/main/src/lexer/tokens.hpp"
    click TSTR "https://github.com/RdStudios9145/FoxLang/blob/main/src/tokenstreamer.hpp"
    click PAR "https://github.com/RdStudios9145/FoxLang/blob/main/src/ast/parser.hpp"
    click AST "https://github.com/RdStudios9145/FoxLang/blob/main/src/ast/nodes.hpp"
    click PM "https://github.com/RdStudios9145/FoxLang/blob/main/premake5.lua"

    %% Styling
    classDef frontend fill:#a8d1f0,stroke:#333
    classDef data fill:#90EE90,stroke:#333
    classDef backend fill:#FFA500,stroke:#333
    classDef output fill:#d3d3d3,stroke:#333
    classDef build fill:#DEB887,stroke:#333

    %% Legend
    subgraph Legend
        F["Frontend Component"]:::frontend
        D["Data Structure"]:::data
        B["Backend Component"]:::backend
        O["Output"]:::output
        BS["Build System"]:::build
    end
```
