# matslina/awib architecture

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

- Interactive diagram: https://gitdiagram.com/matslina/awib
- Repository: https://github.com/matslina/awib

## Overview

Awib is a brainfuck-written optimizing cross-compiler. Users provide brainfuck source, optionally select a target, and receive generated code or an i386 Linux executable. The README documents optimization and all supported backends; source excerpts are limited to standalone utilities, so internal compiler calls and backend dispatch wiring cannot be verified. Those documented relationships are shown with README evidence. The utilities include a brainfuck preprocessor with optional polyglot interpreter attachment and a separate brainfuck interpreter.

Main entry points: [`frontend/frontend.b`](https://github.com/matslina/awib/blob/master/frontend/frontend.b) (Optimizations), [`lang_generic/backend.b`](https://github.com/matslina/awib/blob/master/lang_generic/backend.b) (Generic backend), [`386_linux/backend.b`](https://github.com/matslina/awib/blob/master/386_linux/backend.b) (i386 Linux), [`lang_c/backend.b`](https://github.com/matslina/awib/blob/master/lang_c/backend.b) (C backend)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_compiler["Compiler Core"]
  node_frontend["Source processing<br/>[frontend.b]"]
  node_optimizer["Optimizations<br/>[frontend.b]"]
end

subgraph group_targets["Output Backends"]
  node_backend386["i386 Linux<br/>[backend.b]"]
  node_backendc["C backend<br/>[backend.b]"]
  node_backendjava["Java backend<br/>[backend.b]"]
  node_backendgeneric["Generic backend<br/>[backend.b]"]
  node_backendgo["Go output<br/>[go.b]"]
  node_backendruby["Ruby output<br/>[ruby.b]"]
  node_backendrust["Rust output<br/>[rust.b]"]
  node_backendtcl["Tcl output<br/>[tcl.b]"]
end

subgraph group_utilities["Brainfuck Utilities"]
  node_preprocessor["BF preprocessor<br/>[bfpp.py]"]
  node_interpreter["BF interpreter<br/>[bfint.c]"]
end

node_user(("Compiler user"))
node_source["Brainfuck source"]
node_output["Generated program"]

node_user -->|"provides"| node_source
node_source -->|"compiles"| node_frontend
node_frontend -->|"optimizes"| node_optimizer
node_optimizer -->|"targets"| node_backend386
node_optimizer -->|"targets"| node_backendc
node_optimizer -->|"targets"| node_backendjava
node_optimizer -->|"targets"| node_backendgeneric
node_backendgeneric -.->|"emits"| node_backendgo
node_backendgeneric -.->|"emits"| node_backendruby
node_backendgeneric -.->|"emits"| node_backendrust
node_backendgeneric -.->|"emits"| node_backendtcl
node_backend386 -->|"generates"| node_output
node_backendc -->|"generates"| node_output
node_backendjava -->|"generates"| node_output
node_backendgo -->|"generates"| node_output
node_backendruby -->|"generates"| node_output
node_backendrust -->|"generates"| node_output
node_backendtcl -->|"generates"| node_output
node_preprocessor -->|"attaches option"| node_interpreter

click node_frontend "https://github.com/matslina/awib/blob/master/frontend/frontend.b"
click node_optimizer "https://github.com/matslina/awib/blob/master/frontend/frontend.b"
click node_backend386 "https://github.com/matslina/awib/blob/master/386_linux/backend.b"
click node_backendc "https://github.com/matslina/awib/blob/master/lang_c/backend.b"
click node_backendjava "https://github.com/matslina/awib/blob/master/lang_java/backend.b"
click node_backendgeneric "https://github.com/matslina/awib/blob/master/lang_generic/backend.b"
click node_backendgo "https://github.com/matslina/awib/blob/master/lang_generic/go.b"
click node_backendruby "https://github.com/matslina/awib/blob/master/lang_generic/ruby.b"
click node_backendrust "https://github.com/matslina/awib/blob/master/lang_generic/rust.b"
click node_backendtcl "https://github.com/matslina/awib/blob/master/lang_generic/tcl.b"
click node_preprocessor "https://github.com/matslina/awib/blob/master/util/bfpp.py"
click node_interpreter "https://github.com/matslina/awib/blob/master/util/bfint.c"

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,node_optimizer,node_user toneBlue
class node_backend386,node_backendc,node_backendjava,node_backendgeneric,node_backendgo,node_backendruby,node_backendrust,node_backendtcl toneAmber
class node_preprocessor,node_interpreter toneMint
class node_source,node_output toneIndigo
```

## Components

### Compiler Core

- [Source processing](https://github.com/matslina/awib/blob/master/frontend/frontend.b): `frontend/frontend.b`
- [Optimizations](https://github.com/matslina/awib/blob/master/frontend/frontend.b): `frontend/frontend.b`

### Output Backends

- [i386 Linux](https://github.com/matslina/awib/blob/master/386_linux/backend.b): `386_linux/backend.b`
- [C backend](https://github.com/matslina/awib/blob/master/lang_c/backend.b): `lang_c/backend.b`
- [Java backend](https://github.com/matslina/awib/blob/master/lang_java/backend.b): `lang_java/backend.b`
- [Generic backend](https://github.com/matslina/awib/blob/master/lang_generic/backend.b): `lang_generic/backend.b`
- [Go output](https://github.com/matslina/awib/blob/master/lang_generic/go.b): `lang_generic/go.b`
- [Ruby output](https://github.com/matslina/awib/blob/master/lang_generic/ruby.b): `lang_generic/ruby.b`
- [Rust output](https://github.com/matslina/awib/blob/master/lang_generic/rust.b): `lang_generic/rust.b`
- [Tcl output](https://github.com/matslina/awib/blob/master/lang_generic/tcl.b): `lang_generic/tcl.b`

### Brainfuck Utilities

- [BF preprocessor](https://github.com/matslina/awib/blob/master/util/bfpp.py): `util/bfpp.py`
- [BF interpreter](https://github.com/matslina/awib/blob/master/util/bfint.c): `util/bfint.c`

### Other components

- **Compiler user**
- **Brainfuck source**
- **Generated program**

## Connections

- Compiler user → Brainfuck source: provides (evidence: `README.md`)
- Brainfuck source → Source processing: compiles (evidence: `README.md`)
- Source processing → Optimizations: optimizes (evidence: `README.md`)
- Optimizations → i386 Linux: targets (evidence: `README.md`)
- Optimizations → C backend: targets (evidence: `README.md`)
- Optimizations → Java backend: targets (evidence: `README.md`)
- Optimizations → Generic backend: targets (evidence: `README.md`)
- Generic backend → Go output: emits
- Generic backend → Ruby output: emits
- Generic backend → Rust output: emits
- Generic backend → Tcl output: emits
- i386 Linux → Generated program: generates (evidence: `README.md`)
- C backend → Generated program: generates (evidence: `README.md`)
- Java backend → Generated program: generates (evidence: `README.md`)
- Go output → Generated program: generates (evidence: `README.md`)
- Ruby output → Generated program: generates (evidence: `README.md`)
- Rust output → Generated program: generates (evidence: `README.md`)
- Tcl output → Generated program: generates (evidence: `README.md`)
- BF preprocessor → BF interpreter: attaches option (evidence: `util/bfpp.py`)
