# namanrajput-git/reilang architecture

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

- Interactive diagram: https://gitdiagram.com/namanrajput-git/reilang
- Repository: https://github.com/namanrajput-git/reilang

## Overview

##### Project type and purpose
- ReiLang is a small, Python-inspired interpreted language written in Java. It follows the classical compiler/interpreter pipeline (lexing → parsing → AST construction → interpretation).
- Key use case: embed a simple scripting language into Java applications or experiment with language design.

##### File structure
- Top level:
- Main.java – entry point / CLI launcher
- Expr.java, Stmt.java – AST node definitions
- Token.java, TokenType.java – lexical token model
- ReiLexer.java – tokenizer
- ReiParser.java – parser producing List<Stmt>
- ReiInterpreter.java – AST walker / evaluator
- README.md, build metadata (.iml, .idea)
- No GUI or web frontend; this is a pure‐Java console application.
- The “out” directory is just compiled classes; ignore for architecture.

##### README for additional insights
- Describes the four stages: calling ReiLexer(source) → tokenize() → ReiParser(tokens) → parse() → List<Stmt> → ReiInterpreter.execute(stmt).
- Confirms Java 11+ requirement and planned future work (loops, functions).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Input
    SourceInput["Source Input<br/>(String or File)"]:::data
    %% Orchestrator
    Main["Main<br/>(Orchestrator)"]:::orchestrator
    %% Lexing Stage
    Lexer["ReiLexer<br/>(Lexical Analyzer)"]:::lex
    %% Token Stream
    TokenStream(("List&lt;Token&gt;")):::data
    %% Parsing Stage
    Parser["ReiParser<br/>(Syntax Analyzer)"]:::parse
    %% AST Data
    AST(("AST<br/>(Expr, Stmt)")):::data
    %% Execution Stage
    Interpreter["ReiInterpreter<br/>(AST Evaluator)"]:::exec
    %% Console Output
    Console["Console I/O<br/>(Print Statements)"]:::exec

    %% Flow
    SourceInput -->|"String source"| Main
    Main -->|"source"| Lexer
    Lexer -->|"List&lt;Token&gt;"| TokenStream
    TokenStream -->|"tokens"| Parser
    Parser -->|"List&lt;Stmt&gt;"| AST
    AST -->|"AST"| Interpreter
    Interpreter -->|"println"| Console

    %% Click Events
    click Main "https://github.com/namanrajput-git/reilang/blob/main/Main.java"
    click Lexer "https://github.com/namanrajput-git/reilang/blob/main/ReiLexer.java"
    click TokenStream "https://github.com/namanrajput-git/reilang/blob/main/Token.java"
    click Parser "https://github.com/namanrajput-git/reilang/blob/main/ReiParser.java"
    click AST "https://github.com/namanrajput-git/reilang/blob/main/Expr.java"
    click AST "https://github.com/namanrajput-git/reilang/blob/main/Stmt.java"
    click Interpreter "https://github.com/namanrajput-git/reilang/blob/main/ReiInterpreter.java"
    click SourceInput "https://github.com/namanrajput-git/reilang/blob/main/README.md"

    %% Styles
    classDef lex fill:#aed6f1,stroke:#1f618d,color:#1f618d;
    classDef parse fill:#a9dfbf,stroke:#239b56,color:#239b56;
    classDef exec fill:#f9e79f,stroke:#b9770e,color:#b9770e;
    classDef data fill:#d5dbdb,stroke:#566573,color:#566573;
    classDef orchestrator fill:#d7bde2,stroke:#7d3c98,color:#7d3c98;
```
