# jakemuzy/brian-language architecture

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

- Interactive diagram: https://gitdiagram.com/jakemuzy/brian-language
- Repository: https://github.com/jakemuzy/brian-language

## Overview

BrIan is an in-progress compiler for a concurrency-oriented language targeting RISC-V. The user supplies a `.b` source file; the compiler entry point coordinates tokenization, parsing into an AST, name resolution, and type checking. The implementation also includes symbol tables, namespaces, arena allocation, and diagnostics. The README documents these principal language and compiler capabilities, but the sampled material does not show code-generation implementation or prove the runtime call sequence between individual phases, so those links are left unverified.

Main entry points: [`src/Parser.c`](https://github.com/jakemuzy/brian-language/blob/main/src/Parser.c) (Parser), [`src/Tokenizer.c`](https://github.com/jakemuzy/brian-language/blob/main/src/Tokenizer.c) (Tokenizer), [`src/NameResolver.c`](https://github.com/jakemuzy/brian-language/blob/main/src/NameResolver.c) (Name resolver), [`src/Compiler.c`](https://github.com/jakemuzy/brian-language/blob/main/src/Compiler.c) (Compile entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_front["Frontend"]
  node_tokenizer["Tokenizer<br/>[Tokenizer.c]"]
  node_tokens["Tokens<br/>[Token.c]"]
  node_parser["Parser<br/>[Parser.c]"]
  node_ast["AST<br/>[AST.c]"]
end

subgraph group_semantics["Semantic analysis"]
  node_resolver["Name resolver<br/>[NameResolver.c]"]
  node_typechecker["Type checker<br/>[TypeChecker.c]"]
  node_environment["Symbol table<br/>[Environment.c]"]
  node_namespace["Namespaces<br/>[Namespace.c]"]
  node_operator["Operator rules<br/>[OperatorRules.h]"]
end

subgraph group_support["Compiler support"]
  node_arena["Arena allocator<br/>[ArenaAllocator.c]"]
  node_errors["Diagnostics<br/>[ErrorHandler.c]"]
  node_debug["Debug tools<br/>[DebugTools.c]"]
end

subgraph group_control["Compiler control"]
  node_entry["Compile entry<br/>[Compiler.c]"]
  node_cli["CLI entry<br/>[main.c]"]
end

node_programmer(("Programmer"))
node_source["Brian source"]

node_programmer -->|"writes"| node_source
node_source -.->|"provides input"| node_cli
node_cli -->|"calls"| node_entry
node_entry -.->|"runs phase"| node_tokenizer
node_tokenizer -->|"produces"| node_tokens
node_entry -.->|"runs phase"| node_parser
node_parser -->|"reads tokens"| node_tokenizer
node_parser -->|"builds"| node_ast
node_entry -.->|"runs phase"| node_resolver
node_resolver -->|"resolves"| node_ast
node_resolver -->|"uses symbols"| node_environment
node_resolver -->|"uses namespaces"| node_namespace
node_entry -.->|"runs phase"| node_typechecker
node_typechecker -->|"checks"| node_ast
node_typechecker -->|"uses rules"| node_operator
node_parser -->|"allocates in"| node_arena
node_tokenizer -->|"allocates in"| node_arena
node_resolver -->|"allocates in"| node_arena
node_tokenizer -->|"reports errors"| node_errors
node_parser -->|"reports errors"| node_errors
node_debug -->|"supports debugging"| node_tokenizer
node_debug -->|"supports debugging"| node_parser

click node_entry "https://github.com/jakemuzy/brian-language/blob/main/src/Compiler.c"
click node_cli "https://github.com/jakemuzy/brian-language/blob/main/src/main.c"
click node_tokenizer "https://github.com/jakemuzy/brian-language/blob/main/src/Tokenizer.c"
click node_tokens "https://github.com/jakemuzy/brian-language/blob/main/src/Token.c"
click node_parser "https://github.com/jakemuzy/brian-language/blob/main/src/Parser.c"
click node_ast "https://github.com/jakemuzy/brian-language/blob/main/src/AST.c"
click node_resolver "https://github.com/jakemuzy/brian-language/blob/main/src/NameResolver.c"
click node_typechecker "https://github.com/jakemuzy/brian-language/blob/main/src/TypeChecker.c"
click node_environment "https://github.com/jakemuzy/brian-language/blob/main/src/Environment.c"
click node_namespace "https://github.com/jakemuzy/brian-language/blob/main/src/Namespace.c"
click node_operator "https://github.com/jakemuzy/brian-language/blob/main/include/OperatorRules.h"
click node_arena "https://github.com/jakemuzy/brian-language/blob/main/src/ArenaAllocator.c"
click node_errors "https://github.com/jakemuzy/brian-language/blob/main/src/ErrorHandler.c"
click node_debug "https://github.com/jakemuzy/brian-language/blob/main/src/DebugTools.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_tokenizer,node_tokens,node_parser,node_ast toneBlue
class node_resolver,node_typechecker,node_environment,node_namespace,node_operator toneAmber
class node_arena,node_errors,node_debug toneMint
class node_entry,node_cli toneRose
class node_programmer,node_source toneIndigo
```

## Components

### Frontend

- [Tokenizer](https://github.com/jakemuzy/brian-language/blob/main/src/Tokenizer.c): `src/Tokenizer.c`
- [Tokens](https://github.com/jakemuzy/brian-language/blob/main/src/Token.c): `src/Token.c`
- [Parser](https://github.com/jakemuzy/brian-language/blob/main/src/Parser.c): `src/Parser.c`
- [AST](https://github.com/jakemuzy/brian-language/blob/main/src/AST.c): `src/AST.c`

### Semantic analysis

- [Name resolver](https://github.com/jakemuzy/brian-language/blob/main/src/NameResolver.c): `src/NameResolver.c`
- [Type checker](https://github.com/jakemuzy/brian-language/blob/main/src/TypeChecker.c): `src/TypeChecker.c`
- [Symbol table](https://github.com/jakemuzy/brian-language/blob/main/src/Environment.c): `src/Environment.c`
- [Namespaces](https://github.com/jakemuzy/brian-language/blob/main/src/Namespace.c): `src/Namespace.c`
- [Operator rules](https://github.com/jakemuzy/brian-language/blob/main/include/OperatorRules.h): `include/OperatorRules.h`

### Compiler support

- [Arena allocator](https://github.com/jakemuzy/brian-language/blob/main/src/ArenaAllocator.c): `src/ArenaAllocator.c`
- [Diagnostics](https://github.com/jakemuzy/brian-language/blob/main/src/ErrorHandler.c): `src/ErrorHandler.c`
- [Debug tools](https://github.com/jakemuzy/brian-language/blob/main/src/DebugTools.c): `src/DebugTools.c`

### Compiler control

- [Compile entry](https://github.com/jakemuzy/brian-language/blob/main/src/Compiler.c): `src/Compiler.c`
- [CLI entry](https://github.com/jakemuzy/brian-language/blob/main/src/main.c): `src/main.c`

### Other components

- **Programmer**
- **Brian source**

## Connections

- Programmer → Brian source: writes (evidence: `README.md`)
- Brian source → CLI entry: provides input
- CLI entry → Compile entry: calls (evidence: `src/main.c`)
- Compile entry → Tokenizer: runs phase
- Tokenizer → Tokens: produces
- Compile entry → Parser: runs phase
- Parser → Tokenizer: reads tokens
- Parser → AST: builds
- Compile entry → Name resolver: runs phase
- Name resolver → AST: resolves
- Name resolver → Symbol table: uses symbols
- Name resolver → Namespaces: uses namespaces
- Compile entry → Type checker: runs phase
- Type checker → AST: checks
- Type checker → Operator rules: uses rules
- Parser → Arena allocator: allocates in
- Tokenizer → Arena allocator: allocates in
- Name resolver → Arena allocator: allocates in
- Tokenizer → Diagnostics: reports errors
- Parser → Diagnostics: reports errors
- Debug tools → Tokenizer: supports debugging
- Debug tools → Parser: supports debugging
