# mista7/joe_script architecture

> Architecture diagram of the GitHub repository mista7/joe_script, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mista7/joe_script
- Repository: https://github.com/mista7/joe_script

## Overview

JoeScript is a source-to-object compiler. Its principal workflow is a user supplying a .joe file, followed by tokenization, parsing into an AST, semantic validation, and LLVM IR/object generation. The sampled entry point explicitly runs semantic analysis and reports compilation failure; it also shows object-file output. The repository includes a separate frontend, but its sampled index gives no runtime wiring to the compiler, so it is represented as a distinct subsystem without inferred connections. Some entry-point stages are not visible in the excerpt; their links are omitted.

Main entry points: [`src/main.cc`](https://github.com/mista7/joe_script/blob/main/src/main.cc) (Compiler Driver), [`src/semantics.cc`](https://github.com/mista7/joe_script/blob/main/src/semantics.cc) (Semantic Checks), [`src/codegen.cc`](https://github.com/mista7/joe_script/blob/main/src/codegen.cc) (LLVM Codegen), [`src/lexer.cc`](https://github.com/mista7/joe_script/blob/main/src/lexer.cc) (Tokenizer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web Frontend"]
  node_frontend_app["Browser App<br/>[app.js]"]
  node_frontend_server["Web Server<br/>[server.mjs]"]
end

subgraph group_front["Compiler Front End"]
  node_entry["Compiler Driver<br/>[main.cc]"]
  node_lexer["Tokenizer<br/>[lexer.cc]"]
  node_parser["Parser and AST<br/>[parser.cc]"]
end

subgraph group_analysis["Semantic Analysis"]
  node_semantics["Semantic Checks<br/>[semantics.cc]"]
  node_symbols["Scoped Symbols<br/>[symbol-table.cc]"]
end

subgraph group_backend["Code Generation"]
  node_codegen["LLVM Codegen<br/>[codegen.cc]"]
  node_llvm["LLVM IR Module<br/>[codegen.h]"]
end

node_user(("Compiler User"))
node_source["JoeScript Source"]
node_object["Object File"]

node_user -->|"provides"| node_source
node_entry -->|"scans AST"| node_semantics
node_semantics -->|"tracks names"| node_symbols
node_entry -.->|"invokes"| node_lexer
node_entry -.->|"invokes"| node_parser
node_entry -.->|"generates IR"| node_codegen
node_codegen -->|"builds module"| node_llvm
node_entry -->|"writes output"| node_object

click node_entry "https://github.com/mista7/joe_script/blob/main/src/main.cc"
click node_lexer "https://github.com/mista7/joe_script/blob/main/src/lexer.cc"
click node_parser "https://github.com/mista7/joe_script/blob/main/src/parser.cc"
click node_semantics "https://github.com/mista7/joe_script/blob/main/src/semantics.cc"
click node_symbols "https://github.com/mista7/joe_script/blob/main/src/symbol-table.cc"
click node_codegen "https://github.com/mista7/joe_script/blob/main/src/codegen.cc"
click node_llvm "https://github.com/mista7/joe_script/blob/main/src/codegen.h"
click node_frontend_app "https://github.com/mista7/joe_script/blob/main/src/frontend/app.js"
click node_frontend_server "https://github.com/mista7/joe_script/blob/main/src/frontend/server.mjs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend_app,node_frontend_server,node_user toneBlue
class node_entry,node_lexer,node_parser toneAmber
class node_semantics,node_symbols toneMint
class node_codegen,node_llvm toneRose
class node_source,node_object toneIndigo
```

## Components

### Web Frontend

- [Browser App](https://github.com/mista7/joe_script/blob/main/src/frontend/app.js): `src/frontend/app.js`
- [Web Server](https://github.com/mista7/joe_script/blob/main/src/frontend/server.mjs): `src/frontend/server.mjs`

### Compiler Front End

- [Compiler Driver](https://github.com/mista7/joe_script/blob/main/src/main.cc): `src/main.cc`
- [Tokenizer](https://github.com/mista7/joe_script/blob/main/src/lexer.cc): `src/lexer.cc`
- [Parser and AST](https://github.com/mista7/joe_script/blob/main/src/parser.cc): `src/parser.cc`

### Semantic Analysis

- [Semantic Checks](https://github.com/mista7/joe_script/blob/main/src/semantics.cc): `src/semantics.cc`
- [Scoped Symbols](https://github.com/mista7/joe_script/blob/main/src/symbol-table.cc): `src/symbol-table.cc`

### Code Generation

- [LLVM Codegen](https://github.com/mista7/joe_script/blob/main/src/codegen.cc): `src/codegen.cc`
- [LLVM IR Module](https://github.com/mista7/joe_script/blob/main/src/codegen.h): `src/codegen.h`

### Other components

- **Compiler User**
- **JoeScript Source**
- **Object File**

## Connections

- Compiler User → JoeScript Source: provides
- Compiler Driver → Semantic Checks: scans AST (evidence: `src/main.cc`)
- Semantic Checks → Scoped Symbols: tracks names (evidence: `src/semantics.cc`)
- Compiler Driver → Tokenizer: invokes
- Compiler Driver → Parser and AST: invokes
- Compiler Driver → LLVM Codegen: generates IR
- LLVM Codegen → LLVM IR Module: builds module (evidence: `src/codegen.cc`)
- Compiler Driver → Object File: writes output (evidence: `src/main.cc`)
