# xxrjun/mini-lisp-interpreter architecture

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

- Interactive diagram: https://gitdiagram.com/xxrjun/mini-lisp-interpreter
- Repository: https://github.com/xxrjun/mini-lisp-interpreter

## Overview

##### Main Components
- Lexical Analyzer: Represent the component that is built from the Lex source (src/minilisp.l). Indicate that this module tokenizes the input LISP code.
- Syntax Analyzer / Parser: Show that the Yacc/Bison file (src/minilisp.y) defines the grammar rules which, together with the lexical analyzer, build the parse tree / semantic structure of the program.
- Build/Compilation Process:
- Build process steps described in the README (using bison and lex/ flex, then compiling with gcc).
- That the output from these processes lands in the bin directory (e.g., bin/minilisp or bin/minilisp.exe).
- Testing Suite: Outline the tests folder which includes public test cases (LISP source files and an answer file) and the test scripts (run_tests.sh) that compile, execute, and verify the output.
- Documentation and Assets: Although not central to the execution pipeline, include the docs and assets directories to indicate supplementary design documents and visual aids (like the PDF specifications).

##### And Represent the Relationships and Interactions
- Data flow should begin with the input LISP programs (files in tests/public_test_data or the example folder) going into the lexical analysis phase.
- Once tokens are processed by Lex, these are passed to the parser (Yacc/Bison) to validate the syntax and build the underlying representation (such as an AST or parse stack).
- Build scripts and Makefile should be included as orchestration elements that integrate all these processes.

##### Architectural Patterns and Key Technologies
- Common compiler construction pattern: Input → Lexical Analysis → Parsing → Evaluation/Execution.
- Use annotations to indicate that the parsing phase is responsible for handling LISP-specific syntax (as specified in the Mini-LISP language documents).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Compiler Pipeline"
        A("Input LISP Code"):::input
        B("Lexical Analyzer (minilisp.l)"):::compiler
        C("Parser (minilisp.y)"):::compiler
        D("Interpreter/Runtime Engine"):::runtime
        A --> B
        B --> C
        C --> D
    end

    subgraph "Build Process"
        E("Makefile"):::buildscript
        F("raw_make.sh"):::buildscript
        G("Compiled Executable (bin/minilisp.exe)"):::executable
        H("Compiled Executable (bin/smli)"):::executable
        E --> G
        E --> H
        F --> G
        F --> H
        D --> G
        D --> H
    end

    subgraph "Testing Suite"
        I("Test Runner (run_tests.sh)"):::testing
        J("Public Test Data (tests/public_test_data)"):::testing
        G --> I
        H --> I
        J --> I
    end

    subgraph "Documentation & Assets"
        K("Documentation (docs)"):::documentation
        L("Assets (assets)"):::documentation
        K --> L
    end

    %% Click Events
    click B "https://github.com/xxrjun/mini-lisp-interpreter/blob/main/src/minilisp.l"
    click C "https://github.com/xxrjun/mini-lisp-interpreter/blob/main/src/minilisp.y"
    click E "https://github.com/xxrjun/mini-lisp-interpreter/tree/main/Makefile"
    click F "https://github.com/xxrjun/mini-lisp-interpreter/blob/main/raw_make.sh"
    click G "https://github.com/xxrjun/mini-lisp-interpreter/blob/main/bin/minilisp.exe"
    click H "https://github.com/xxrjun/mini-lisp-interpreter/tree/main/bin/smli"
    click I "https://github.com/xxrjun/mini-lisp-interpreter/blob/main/run_tests.sh"
    click J "https://github.com/xxrjun/mini-lisp-interpreter/tree/main/tests/public_test_data"
    click K "https://github.com/xxrjun/mini-lisp-interpreter/tree/main/docs"
    click L "https://github.com/xxrjun/mini-lisp-interpreter/tree/main/assets"

    %% Styles
    classDef input fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef compiler fill:#a0d8f1,stroke:#333,stroke-width:2px;
    classDef runtime fill:#c0f0c0,stroke:#333,stroke-width:2px;
    classDef buildscript fill:#f9c0d9,stroke:#333,stroke-width:2px;
    classDef executable fill:#a6e1a6,stroke:#333,stroke-width:2px;
    classDef testing fill:#c8e1ff,stroke:#333,stroke-width:2px;
    classDef documentation fill:#fff2cc,stroke:#333,stroke-width:2px;
```
