# vishik-on-github/llvm-programming-lang architecture

> Architecture diagram of the GitHub repository vishik-on-github/llvm-programming-lang, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vishik-on-github/llvm-programming-lang
- Repository: https://github.com/vishik-on-github/llvm-programming-lang

## Overview

##### Main Components
- Source Code Input: Represent the source language file (e.g., test.eva) as the starting input.
- Frontend / Parser Module:
- Grammar (EvaGrammar.bnf) and the parser logic (EvaParser.h).
- Semantic Analysis/Environment:
- Environment module (Environment.h) which likely handles scoping, variable type management, and symbol tables.
- LLVM Integration Module:
- Integration with LLVM through the EvaLLVM module (EvaLLVM.h and eva-llvm.cpp). This part is responsible for converting the parsed and semantically checked input into LLVM intermediate representation (IR).
- Logger:
- Logger module (Logger.h) as a cross-cutting concern for error reporting and debugging.
- Build/Run Pipeline:
- The compile-run.sh acts as the orchestrator of the build and run phases.
- Supporting Documentation/Notes:
- Although not directly part of the execution flow, the notes directory indicates additional design considerations, plans for code improvement, and technical thoughts that influenced the architecture.

##### Relationships and Data Flow
- The process begins with the source file being fed into the Parser.
- The Parser uses the BNF grammar definition to generate an Abstract Syntax Tree (AST) or similar structure.
- The AST is then passed to components that check semantics, maintain the Environment, and potentially log any issues.
- Once analysis is complete, the EvaLLVM module uses LLVM libraries to generate IR (and subsequently, machine code).
- Input Source (test.eva) → Parser (EvaParser, EvaGrammar.bnf)
- Parser → Semantic Environment (Environment.h)
- Semantic Environment → Code Generation (EvaLLVM)
- Each step augmented by Logger outputs (Logger.h)

##### Architectural Patterns and Technologies
- Modular separation: The system cleanly separates concerns (parsing, semantic analysis, code generation, logging).
- Integration with LLVM libraries, which is the backbone for IR generation and subsequent optimizations.
- Infrastructural scripts or automation tools (like compile-run.sh) that provide the execution flow.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Source Code Input
    A["Source File: test.eva"]:::source

    %% Frontend / Parser Module Subgraph
    subgraph "Frontend / Parser Module"
        B["EvaGrammar (Grammar Definition)"]:::frontend
        C["EvaParser (Parser Implementation)"]:::frontend
        B -->|"uses"| C
    end

    %% Semantic Analysis / Environment Module
    D["Semantic Analyzer/Environment"]:::semantics

    %% LLVM Integration Module Subgraph
    subgraph "LLVM Integration Module"
        E1["Main Driver (eva-llvm.cpp)"]:::llvm
        E2["LLVM Interface (EvaLLVM)"]:::llvm
        E1 -->|"generates_IR"| E2
    end

    %% Logger Module
    F["Logger"]:::utility

    %% Build/Run Pipeline
    G["Build/Run Pipeline (compile-run.sh)"]:::script

    %% Supporting Documentation/Notes
    H["Supporting Documentation/Notes"]:::docs

    %% Data/Control Flow
    A -->|"feeds"| B
    C -->|"produces_AST"| D
    D -->|"passes_AST"| E1
    E2 -->|"executes"| G

    %% Logger interactions (cross-cutting logging)
    B ---|"logs"| F
    C ---|"logs"| F
    D ---|"logs"| F
    E1 ---|"logs"| F
    E2 ---|"logs"| F

    %% Supporting documentation association (external)
    G ---|"refers_to"| H

    %% Click Events
    click A "https://github.com/vishik-on-github/llvm-programming-lang/blob/main/codes/eva-llvm/test.eva"
    click B "https://github.com/vishik-on-github/llvm-programming-lang/blob/main/codes/eva-llvm/src/parser/EvaGrammar.bnf"
    click C "https://github.com/vishik-on-github/llvm-programming-lang/blob/main/codes/eva-llvm/src/parser/EvaParser.h"
    click D "https://github.com/vishik-on-github/llvm-programming-lang/blob/main/codes/eva-llvm/src/Environment.h"
    click E1 "https://github.com/vishik-on-github/llvm-programming-lang/blob/main/codes/eva-llvm/eva-llvm.cpp"
    click E2 "https://github.com/vishik-on-github/llvm-programming-lang/blob/main/codes/eva-llvm/src/EvaLLVM.h"
    click F "https://github.com/vishik-on-github/llvm-programming-lang/blob/main/codes/eva-llvm/src/Logger.h"
    click G "https://github.com/vishik-on-github/llvm-programming-lang/blob/main/codes/eva-llvm/compile-run.sh"
    click H "https://github.com/vishik-on-github/llvm-programming-lang/tree/main/notes/"

    %% Styles
    classDef source fill:#ffcccc,stroke:#cc0000,stroke-width:2px;
    classDef frontend fill:#ccffcc,stroke:#009900,stroke-width:2px;
    classDef semantics fill:#ccccff,stroke:#0000cc,stroke-width:2px;
    classDef llvm fill:#ffffcc,stroke:#cccc00,stroke-width:2px;
    classDef utility fill:#e6e6e6,stroke:#333333,stroke-width:2px;
    classDef script fill:#ccffff,stroke:#00cccc,stroke-width:2px;
    classDef docs fill:#ffebcc,stroke:#ff9900,stroke-width:2px;
```
