# albertejuku/boma architecture

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

- Interactive diagram: https://gitdiagram.com/albertejuku/boma
- Repository: https://github.com/albertejuku/boma

## Overview

##### Project Type and Purpose
- The README indicates that this is a programming language project with advanced features for AI and mathematics.
- The file structure confirms that this project is geared toward language processing by including dedicated folders for the lexer and parser, as well as a folder (rules) that documents the grammar and language rules.

##### File Structure
- At the top level, you have configuration and build files like “CMakeLists.txt” and “.gitignore” which imply standard C++ build management.
- The “lexer” directory contains components like Lexer.cpp/h, Location.cpp/h, and Token.cpp/h that indicate the lexical analyzer is designed to read source code, track positions, and output tokens.
- The “parser” directory contains Parser.cpp/h which will take the tokens produced from the lexer and construct the syntax tree.
- The “rules” directory (with GRAMMAR.md and RULES.md) plays a critical role in defining the language syntax and semantics.
- “main.cpp” likely serves as the entry point for orchestrating the analysis of a source file through lexing and parsing.

##### Main Components of the System
- Input Module: Represents a source code file or stream that will be processed.
- Lexer (Lexical Analyzer): Reads the source input, converts characters into tokens (using Location and Token classes to keep track of positions and types).
- Parser (Syntax Analyzer): Consumes the token stream provided by the lexer and builds the corresponding syntactic structure (parsing according to the grammar rules defined in the “rules” folder).
- Grammar/Rules: Although not executable code, these documents serve as the specification guiding how the lexer and parser work.
- Coordinator/Main: The main.cpp that glues these components together.

##### Relationships and Data Flow
- Input flows into the Lexer.
- The Lexer outputs a stream of tokens.
- The Parser takes these tokens as input and generates an abstract syntax tree or other structured representation.
- Underlying documents (in “rules”) inform both the lexer and parser about the language specifications.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Each component (lexical analysis vs. parsing) is independently maintained.
- Modularity: With distinct directories encapsulating each functionality (lexer, parser, grammar rules), changes in one area can be isolated from others.
- Incremental Processing: The design follows a pipeline—source input is progressively processed into tokens and then parsed.
- Use of standard build tools (via CMakeLists.txt) indicates adherence to typical C++ project organization patterns.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build & Configuration
    subgraph "Build & Configuration"
        B1["CMakeLists.txt"]:::build
        B2[".gitignore"]:::build
    end

    %% Language Components
    subgraph "Language Components"
        I["Input Source"]:::input
        M["Entry Point (main.cpp)"]:::core
        subgraph "Lexical Analysis"
            L["Lexer (Lexer, Token, Location)"]:::core
        end
        P["Parser (Syntax Analyzer)"]:::core
        G["Grammar Rules Docs"]:::doc
    end

    I -->|"starts"| M
    M -->|"invokes"| L
    L -->|"outputs_to"| P
    G -->|"informs"| L
    G -->|"informs"| P

    B1 -.->|"supports"| M
    B2 -.->|"supports"| M

    %% Click Events
    click M "https://github.com/albertejuku/boma/blob/master/main.cpp"
    click L "https://github.com/albertejuku/boma/tree/master/lexer/"
    click P "https://github.com/albertejuku/boma/tree/master/parser/"
    click G "https://github.com/albertejuku/boma/tree/master/rules/"
    click B1 "https://github.com/albertejuku/boma/blob/master/CMakeLists.txt"
    click B2 "https://github.com/albertejuku/boma/blob/master/.gitignore"

    %% Styles
    classDef build fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef input fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef core fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef doc fill:#f08080,stroke:#333,stroke-width:2px;
```
