# yassine-jemi01/ylang architecture

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

- Interactive diagram: https://gitdiagram.com/yassine-jemi01/ylang
- Repository: https://github.com/yassine-jemi01/ylang

## Overview

YLang is a compiled language toolchain: a programmer invokes its CLI to check or fix source, emit C, or build a native executable. The principal build flow is source loading, lexing and parsing, semantic checking, C generation, then native compilation. The graph also retains the documented language/runtime capabilities, optional SDL GUI API, and VS Code support. Stage handoffs are documented in the README; several implementation details and editor wiring are not excerpted, so uncertain links are omitted or marked unverified.

Main entry points: [`src/driver.c`](https://github.com/yassine-jemi01/ylang/blob/main/src/driver.c) (Compiler driver), [`src/codegen.c`](https://github.com/yassine-jemi01/ylang/blob/main/src/codegen.c) (C code generator), [`src/parser.c`](https://github.com/yassine-jemi01/ylang/blob/main/src/parser.c) (Parser and AST), [`src/internal.h`](https://github.com/yassine-jemi01/ylang/blob/main/src/internal.h) (Compiler state and utilities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and orchestration"]
  node_cli["Compiler CLI<br/>[main.c]"]
  node_driver["Compiler driver<br/>[driver.c]"]
  node_internal["Compiler state and utilities<br/>[internal.h]"]
end

subgraph group_frontend["Language frontend"]
  node_lexer["Lexer<br/>[lexer.c]"]
  node_tokens["Token model<br/>[lexer.h]"]
  node_parser["Parser and AST<br/>[parser.c]"]
  node_ast["Compiler AST types<br/>[compiler.h]"]
  node_sema["Semantic checker<br/>[sema.c]"]
end

subgraph group_backend["Code generation and runtime"]
  node_codegen["C code generator<br/>[codegen.c]"]
  node_builtins["Language built-ins<br/>[sema.c]"]
end

subgraph group_integrations["Editor and GUI"]
  node_gui_api["GUI API<br/>[gui.h]"]
  node_gui_runtime["SDL GUI runtime<br/>[gui.c]"]
  node_vscode["VS Code support<br/>[extension.js]"]
end

node_programmer(("Programmer"))
node_source["YLang source"]
node_nativecc["GCC or Clang"]
node_executable["Native executable"]
node_sdl["SDL2"]

node_programmer -->|"invokes"| node_cli
node_cli -->|"dispatches"| node_driver
node_driver -->|"reads"| node_source
node_driver -.->|"starts compilation"| node_lexer
node_lexer -->|"produces"| node_tokens
node_parser -->|"requests tokens"| node_lexer
node_parser -->|"builds"| node_ast
node_driver -->|"parses source"| node_parser
node_driver -->|"checks program"| node_sema
node_driver -->|"generates C"| node_codegen
node_sema -->|"checks"| node_ast
node_codegen -->|"emits from"| node_ast
node_driver -->|"uses state"| node_internal
node_parser -->|"uses utilities"| node_internal
node_sema -->|"uses compiler state"| node_internal
node_codegen -->|"uses compiler state"| node_internal
node_codegen -.->|"emits runtime helpers"| node_builtins
node_driver -->|"invokes"| node_nativecc
node_nativecc -->|"compiles"| node_executable
node_programmer -.->|"edits source"| node_vscode
node_vscode -.->|"checks files"| node_cli
node_gui_api -->|"implemented by"| node_gui_runtime
node_gui_runtime -->|"uses"| node_sdl

click node_cli "https://github.com/yassine-jemi01/ylang/blob/main/src/main.c"
click node_driver "https://github.com/yassine-jemi01/ylang/blob/main/src/driver.c"
click node_lexer "https://github.com/yassine-jemi01/ylang/blob/main/src/lexer.c"
click node_tokens "https://github.com/yassine-jemi01/ylang/blob/main/include/ylang/lexer.h"
click node_parser "https://github.com/yassine-jemi01/ylang/blob/main/src/parser.c"
click node_ast "https://github.com/yassine-jemi01/ylang/blob/main/include/ylang/compiler.h"
click node_sema "https://github.com/yassine-jemi01/ylang/blob/main/src/sema.c"
click node_internal "https://github.com/yassine-jemi01/ylang/blob/main/src/internal.h"
click node_codegen "https://github.com/yassine-jemi01/ylang/blob/main/src/codegen.c"
click node_builtins "https://github.com/yassine-jemi01/ylang/blob/main/src/sema.c"
click node_gui_api "https://github.com/yassine-jemi01/ylang/blob/main/include/ylang/gui.h"
click node_gui_runtime "https://github.com/yassine-jemi01/ylang/blob/main/stdlib/gui/gui.c"
click node_vscode "https://github.com/yassine-jemi01/ylang/blob/main/editors/vscode/extension.js"

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_cli,node_driver,node_internal toneBlue
class node_lexer,node_tokens,node_parser,node_ast,node_sema toneAmber
class node_codegen,node_builtins toneMint
class node_gui_api,node_gui_runtime,node_vscode toneRose
class node_programmer,node_source,node_nativecc,node_executable,node_sdl toneIndigo
```

## Components

### CLI and orchestration

- [Compiler CLI](https://github.com/yassine-jemi01/ylang/blob/main/src/main.c): `src/main.c`
- [Compiler driver](https://github.com/yassine-jemi01/ylang/blob/main/src/driver.c): `src/driver.c`
- [Compiler state and utilities](https://github.com/yassine-jemi01/ylang/blob/main/src/internal.h): `src/internal.h`

### Language frontend

- [Lexer](https://github.com/yassine-jemi01/ylang/blob/main/src/lexer.c): `src/lexer.c`
- [Token model](https://github.com/yassine-jemi01/ylang/blob/main/include/ylang/lexer.h): `include/ylang/lexer.h`
- [Parser and AST](https://github.com/yassine-jemi01/ylang/blob/main/src/parser.c): `src/parser.c`
- [Compiler AST types](https://github.com/yassine-jemi01/ylang/blob/main/include/ylang/compiler.h): `include/ylang/compiler.h`
- [Semantic checker](https://github.com/yassine-jemi01/ylang/blob/main/src/sema.c): `src/sema.c`

### Code generation and runtime

- [C code generator](https://github.com/yassine-jemi01/ylang/blob/main/src/codegen.c): `src/codegen.c`
- [Language built-ins](https://github.com/yassine-jemi01/ylang/blob/main/src/sema.c): `src/sema.c`

### Editor and GUI

- [GUI API](https://github.com/yassine-jemi01/ylang/blob/main/include/ylang/gui.h): `include/ylang/gui.h`
- [SDL GUI runtime](https://github.com/yassine-jemi01/ylang/blob/main/stdlib/gui/gui.c): `stdlib/gui/gui.c`
- [VS Code support](https://github.com/yassine-jemi01/ylang/blob/main/editors/vscode/extension.js): `editors/vscode/extension.js`

### Other components

- **Programmer**
- **YLang source**
- **GCC or Clang**
- **Native executable**
- **SDL2**

## Connections

- Programmer → Compiler CLI: invokes (evidence: `src/main.c`)
- Compiler CLI → Compiler driver: dispatches (evidence: `src/main.c`)
- Compiler driver → YLang source: reads (evidence: `src/driver.c`)
- Compiler driver → Lexer: starts compilation
- Lexer → Token model: produces (evidence: `src/lexer.c`)
- Parser and AST → Lexer: requests tokens (evidence: `src/parser.c`)
- Parser and AST → Compiler AST types: builds (evidence: `include/ylang/compiler.h`)
- Compiler driver → Parser and AST: parses source (evidence: `README.md`)
- Compiler driver → Semantic checker: checks program (evidence: `README.md`)
- Compiler driver → C code generator: generates C (evidence: `README.md`)
- Semantic checker → Compiler AST types: checks (evidence: `src/sema.c`)
- C code generator → Compiler AST types: emits from (evidence: `src/codegen.c`)
- Compiler driver → Compiler state and utilities: uses state (evidence: `src/driver.c`)
- Parser and AST → Compiler state and utilities: uses utilities (evidence: `src/parser.c`)
- Semantic checker → Compiler state and utilities: uses compiler state (evidence: `src/sema.c`)
- C code generator → Compiler state and utilities: uses compiler state (evidence: `src/codegen.c`)
- C code generator → Language built-ins: emits runtime helpers
- Compiler driver → GCC or Clang: invokes (evidence: `README.md`)
- GCC or Clang → Native executable: compiles (evidence: `README.md`)
- Programmer → VS Code support: edits source
- VS Code support → Compiler CLI: checks files
- GUI API → SDL GUI runtime: implemented by (evidence: `stdlib/gui/gui.c`)
- SDL GUI runtime → SDL2: uses (evidence: `stdlib/gui/gui.c`)
