# zvnoob/another architecture

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

- Interactive diagram: https://gitdiagram.com/zvnoob/another
- Repository: https://github.com/zvnoob/another

## Overview

##### Main Components
- Main Entrypoint: File “main.cpp” is the execution starting point which likely initializes the interpreter.
- Lexical Analyzer (Tokenizer): Files like “token.hpp” and “tokenizer.hpp” indicate that there is a dedicated module for breaking the source code into tokens.
- Parser: “parser.hpp” is used to construct the Abstract Syntax Tree (AST) or some intermediate representation from tokens.
- Execution Engine: “executer.hpp” handles the evaluation or runtime processing of the parsed structures. This module likely traverses the AST or the compiled intermediate representation.
- Object System: “object.hpp”, “object_function.hpp”, and “object_operator.hpp” show that the language uses an object model to represent variables, functions, and operators.
- Core Library / Runtime Support: The “corelib_*” header files (core, env, io, thread, type) suggest a runtime/core library that implements the built-in functions and environment support (e.g., the “shared” scope detailed in the README).
- Utility/Support Modules: Files such as “str.hpp”, “type.hpp”, and “error.hpp” aid in string operations, type management, and error handling respectively.
- Build/Config: “compile_commands.json” and “.gitignore” are not part of the runtime but help with development.

##### Relationships and Interactions
- Input source code is fed into the Tokenizer, where it is segmented into tokens.
- The Parser consumes these tokens to generate a structured representation (likely an AST).
- The Execution Engine takes this representation and evaluates it, calling functions, and managing scopes.
- The Core Library components (corelib_*) provide pre-defined functions (like if, while, try, throw, etc.) and are accessible in the shared “@” scope.
- The Object System is intertwined with the Execution Engine, representing variables, functions, and operators during execution.
- Utility modules (error handling, string manipulation, type conversions) are used throughout the system to facilitate robust processing.

##### Architectural Patterns and Design Principles
- The project uses a layered design: starting from input processing (tokenizing/parsing), constructing an intervening structured representation, and then executing the program.
- A clear separation between syntax analysis (lexer/parser) and execution/interpretation (executer and object handling) is reflected.
- Core functions built into “shared” scope exemplify a runtime environment design where built-in functionalities are embedded into the interpreter’s environment.

b. In the center, place an “AST/Intermediate Representation” block.
g. Module relationships, such as dependency and control flows, are clearly visually indicated.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Entrypoint
    MAIN("Main (main.cpp)"):::mainModule

    %% Lexical Analysis Subgraph
    subgraph "Lexical Analysis"
        TOKEN_H("Token Definition"):::frontend
        TOKENIZER_IMPL("Tokenizer Implementation"):::frontend
        TOKEN_H -->|"together"| TOKENIZER_IMPL
    end

    %% Parser Module
    PARSER("Parser (parser.hpp)"):::frontend

    %% Intermediate Representation
    AST("AST/Intermediate Representation"):::middle

    %% Execution Engine
    EXECUTION("Execution Engine (executer.hpp)"):::middle

    %% Object System Subgraph
    subgraph "Object System"
        OBJ_BASE("Object Base"):::backend
        OBJ_FUNC("Object Function"):::backend
        OBJ_OP("Object Operator"):::backend
        OBJ_BASE --> OBJ_FUNC
        OBJ_BASE --> OBJ_OP
    end

    %% Core Library / Runtime Support Subgraph
    subgraph "Core Library / Runtime Support"
        CORE_CORE("Core Core"):::backend
        CORE_ENV("Environment"):::backend
        CORE_IO("I/O Module"):::backend
        CORE_THREAD("Thread Module"):::backend
        CORE_TYPE("Type Module"):::backend
        CORE_CORE --> CORE_ENV
        CORE_ENV --> CORE_IO
        CORE_ENV --> CORE_THREAD
        CORE_ENV --> CORE_TYPE
    end

    %% Utility / Support Modules Subgraph
    subgraph "Utility / Support Modules"
        UTIL_ERR("Error Handler"):::utility
        UTIL_STR("String Utils"):::utility
        UTIL_TYPE("Type Utils"):::utility
    end

    %% Connections between main components
    MAIN -->|"sourceCodeInput"| TOKEN_H
    TOKENIZER_IMPL -->|"producesTokens"| PARSER
    PARSER -->|"buildsAST"| AST
    AST -->|"evaluatedBy"| EXECUTION

    %% Connections from Execution Engine to supporting systems
    EXECUTION -->|"manages"| OBJ_BASE
    EXECUTION -->|"integrates"| CORE_CORE

    %% Dotted links from Utility Modules to support processing
    UTIL_ERR ---|"supports"| PARSER
    UTIL_ERR ---|"supports"| EXECUTION
    UTIL_STR ---|"aids"| PARSER
    UTIL_TYPE ---|"aids"| PARSER

    %% Bidirectional link between Execution Engine and Core Library
    EXECUTION <==>|"runtimeSupport"| CORE_ENV

    %% Styles
    classDef mainModule fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef frontend fill:#99ccff,stroke:#333,stroke-width:2px;
    classDef middle fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef backend fill:#ff9999,stroke:#333,stroke-width:2px;
    classDef utility fill:#ccccff,stroke:#333,stroke-width:2px;

    %% Click Events
    click MAIN "https://github.com/zvnoob/another/blob/main/main.cpp"
    click TOKEN_H "https://github.com/zvnoob/another/blob/main/token.hpp"
    click TOKENIZER_IMPL "https://github.com/zvnoob/another/blob/main/tokenizer.hpp"
    click PARSER "https://github.com/zvnoob/another/blob/main/parser.hpp"
    click EXECUTION "https://github.com/zvnoob/another/blob/main/executer.hpp"
    click OBJ_BASE "https://github.com/zvnoob/another/blob/main/object.hpp"
    click OBJ_FUNC "https://github.com/zvnoob/another/blob/main/object_function.hpp"
    click OBJ_OP "https://github.com/zvnoob/another/blob/main/object_operator.hpp"
    click CORE_CORE "https://github.com/zvnoob/another/blob/main/corelib_core.hpp"
    click CORE_ENV "https://github.com/zvnoob/another/blob/main/corelib_env.hpp"
    click CORE_IO "https://github.com/zvnoob/another/blob/main/corelib_io.hpp"
    click CORE_THREAD "https://github.com/zvnoob/another/blob/main/corelib_thread.hpp"
    click CORE_TYPE "https://github.com/zvnoob/another/blob/main/corelib_type.hpp"
    click UTIL_ERR "https://github.com/zvnoob/another/blob/main/error.hpp"
    click UTIL_STR "https://github.com/zvnoob/another/blob/main/str.hpp"
    click UTIL_TYPE "https://github.com/zvnoob/another/blob/main/type.hpp"
```
