# nuistmrchest/chest_b_compiler architecture

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

- Interactive diagram: https://gitdiagram.com/nuistmrchest/chest_b_compiler
- Repository: https://github.com/nuistmrchest/chest_b_compiler

## Overview

Chest_B_Compiler is an early-stage Rust compiler. The demonstrated workflow is a hard-coded source expression in main, tokenized, converted to an expression, validated and reordered into postfix form, then compiled to assembly text. The statement parser supports additional control-flow and declaration forms, but main currently comments out that module. Evidence is limited to the excerpts and README; the statement parser's broader runtime integration is not demonstrated.

Main entry points: [`src/main.rs`](https://github.com/nuistmrchest/chest_b_compiler/blob/main/src/main.rs) (Demo driver), [`src/cbc_statement.rs`](https://github.com/nuistmrchest/chest_b_compiler/blob/main/src/cbc_statement.rs) (Statement parser), [`src/cbc_token.rs`](https://github.com/nuistmrchest/chest_b_compiler/blob/main/src/cbc_token.rs) (Tokenizer), [`src/cbc_expression.rs`](https://github.com/nuistmrchest/chest_b_compiler/blob/main/src/cbc_expression.rs) (Expression processing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_driver["Demo driver<br/>[main.rs]"]
  node_lexer["Tokenizer<br/>[cbc_token.rs]"]
  node_statement["Statement parser<br/>[cbc_statement.rs]"]
end

subgraph group_semantics["Expression processing"]
  node_expression["Expression processing<br/>[cbc_expression.rs]"]
  node_variables[("Variable scopes<br/>[cbc_variable.rs]")]
end

subgraph group_backend["Code generation"]
  node_assembly["Assembly constants<br/>[cbc_sys.rs]"]
end

node_developer(("Compiler user"))

node_developer -->|"runs demo"| node_driver
node_driver -->|"tokenizes source"| node_lexer
node_driver -->|"builds and compiles"| node_expression
node_statement -->|"consumes tokens"| node_lexer
node_statement -->|"parses conditions"| node_expression

click node_driver "https://github.com/nuistmrchest/chest_b_compiler/blob/main/src/main.rs"
click node_lexer "https://github.com/nuistmrchest/chest_b_compiler/blob/main/src/cbc_token.rs"
click node_statement "https://github.com/nuistmrchest/chest_b_compiler/blob/main/src/cbc_statement.rs"
click node_expression "https://github.com/nuistmrchest/chest_b_compiler/blob/main/src/cbc_expression.rs"
click node_variables "https://github.com/nuistmrchest/chest_b_compiler/blob/main/src/cbc_variable.rs"
click node_assembly "https://github.com/nuistmrchest/chest_b_compiler/blob/main/src/cbc_sys.rs"

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_driver,node_lexer,node_statement,node_developer toneBlue
class node_expression,node_variables toneAmber
class node_assembly toneMint
```

## Components

### Frontend

- [Demo driver](https://github.com/nuistmrchest/chest_b_compiler/blob/main/src/main.rs): `src/main.rs`
- [Tokenizer](https://github.com/nuistmrchest/chest_b_compiler/blob/main/src/cbc_token.rs): `src/cbc_token.rs`
- [Statement parser](https://github.com/nuistmrchest/chest_b_compiler/blob/main/src/cbc_statement.rs): `src/cbc_statement.rs`

### Expression processing

- [Expression processing](https://github.com/nuistmrchest/chest_b_compiler/blob/main/src/cbc_expression.rs): `src/cbc_expression.rs`
- [Variable scopes](https://github.com/nuistmrchest/chest_b_compiler/blob/main/src/cbc_variable.rs): `src/cbc_variable.rs`

### Code generation

- [Assembly constants](https://github.com/nuistmrchest/chest_b_compiler/blob/main/src/cbc_sys.rs): `src/cbc_sys.rs`

### Other components

- **Compiler user**

## Connections

- Compiler user → Demo driver: runs demo (evidence: `src/main.rs`)
- Demo driver → Tokenizer: tokenizes source (evidence: `src/main.rs`)
- Demo driver → Expression processing: builds and compiles (evidence: `src/main.rs`)
- Statement parser → Tokenizer: consumes tokens (evidence: `src/cbc_statement.rs`)
- Statement parser → Expression processing: parses conditions (evidence: `src/cbc_statement.rs`)
