# tau-lang/tau architecture

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

- Interactive diagram: https://gitdiagram.com/tau-lang/tau
- Repository: https://github.com/tau-lang/tau

## Overview

Tau is a modular compiler. Its main workflow accepts a source file and CLI options, processes the source through lexing, parsing, declaration collection and semantic analysis, then generates C, QBE or LLVM output. The graph preserves the documented compiler stages and the distinct backend implementations. Evidence is limited to the README, source excerpts and SOURCE INDEX references; unsampled module internals are not assumed to call one another.

Main entry points: [`compiler-cli/src/lib.rs`](https://github.com/tau-lang/tau/blob/main/compiler-cli/src/lib.rs) (Compile dispatch), [`compiler-core/src/analyzer.rs`](https://github.com/tau-lang/tau/blob/main/compiler-core/src/analyzer.rs) (Semantic analysis), [`generator-llvm/src/expression.rs`](https://github.com/tau-lang/tau/blob/main/generator-llvm/src/expression.rs) (LLVM backend), [`compiler-core/src/ast/declaration.rs`](https://github.com/tau-lang/tau/blob/main/compiler-core/src/ast/declaration.rs) (Typed AST)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["Command line"]
  node_options["CLI options<br/>[options.rs]"]
  node_compile["Compile dispatch<br/>[lib.rs]"]
end

subgraph group_core["Compiler core"]
  node_lexer["Lexer<br/>[lexer.rs]"]
  node_parser["Parser<br/>[parser.rs]"]
  node_header["Header pass<br/>[header.rs]"]
  node_analyzer["Semantic analysis<br/>[analyzer.rs]"]
  node_type_inference["Type inference<br/>[expression.rs]"]
  node_type_system["Type system<br/>[type_.rs]"]
  node_typed_ast["Typed AST<br/>[declaration.rs]"]
  node_translator["IR translator<br/>[translator.rs]"]
  node_ir_emitter["IR emitter API<br/>[emitter.rs]"]
end

subgraph group_c_backend["C backend"]
  node_c_codegen["C code generator<br/>[code.rs]"]
  node_c_header["C header generator<br/>[header.rs]"]
  node_c_format["C source formatting<br/>[source_code.rs]"]
end

subgraph group_other_backends["Other backends"]
  node_llvm["LLVM backend<br/>[expression.rs]"]
  node_llvm_declarations["LLVM declarations<br/>[declaration.rs]"]
  node_llvm_statements["LLVM statements<br/>[statement.rs]"]
  node_qbe["QBE backend<br/>[emitter.rs]"]
end

node_developer(("Compiler user"))

node_developer -->|"sets options"| node_options
node_options -->|"configures"| node_compile
node_compile -->|"processes source"| node_lexer
node_lexer -->|"supplies tokens"| node_parser
node_parser -->|"passes AST"| node_header
node_header -->|"precedes analysis"| node_analyzer
node_analyzer -.->|"checks types"| node_type_inference
node_type_inference -->|"uses types"| node_type_system
node_analyzer -->|"produces typed AST"| node_typed_ast
node_compile -->|"receives result"| node_typed_ast
node_typed_ast -->|"translated by"| node_translator
node_translator -->|"calls emitter"| node_ir_emitter
node_compile -->|"transpiles AST"| node_c_codegen
node_compile -->|"transpiles AST"| node_c_header
node_c_codegen -->|"formats output"| node_c_format
node_c_header -->|"uses formatting"| node_c_format
node_compile -->|"folds AST"| node_llvm
node_compile -->|"translates AST"| node_qbe
node_llvm -.->|"delegates declarations"| node_llvm_declarations
node_llvm -.->|"delegates statements"| node_llvm_statements

click node_options "https://github.com/tau-lang/tau/blob/main/compiler-cli/src/options.rs"
click node_compile "https://github.com/tau-lang/tau/blob/main/compiler-cli/src/lib.rs"
click node_lexer "https://github.com/tau-lang/tau/blob/main/compiler-core/src/lexer.rs"
click node_parser "https://github.com/tau-lang/tau/blob/main/compiler-core/src/parser.rs"
click node_header "https://github.com/tau-lang/tau/blob/main/compiler-core/src/header.rs"
click node_analyzer "https://github.com/tau-lang/tau/blob/main/compiler-core/src/analyzer.rs"
click node_type_inference "https://github.com/tau-lang/tau/blob/main/compiler-core/src/type_/expression.rs"
click node_type_system "https://github.com/tau-lang/tau/blob/main/compiler-core/src/type_.rs"
click node_typed_ast "https://github.com/tau-lang/tau/blob/main/compiler-core/src/ast/declaration.rs"
click node_translator "https://github.com/tau-lang/tau/blob/main/compiler-core/src/translator.rs"
click node_ir_emitter "https://github.com/tau-lang/tau/blob/main/compiler-core/src/ir/emitter.rs"
click node_c_codegen "https://github.com/tau-lang/tau/blob/main/generator-c/src/code.rs"
click node_c_header "https://github.com/tau-lang/tau/blob/main/generator-c/src/header.rs"
click node_c_format "https://github.com/tau-lang/tau/blob/main/generator-c/src/source_code.rs"
click node_llvm "https://github.com/tau-lang/tau/blob/main/generator-llvm/src/expression.rs"
click node_llvm_declarations "https://github.com/tau-lang/tau/blob/main/generator-llvm/src/declaration.rs"
click node_llvm_statements "https://github.com/tau-lang/tau/blob/main/generator-llvm/src/statement.rs"
click node_qbe "https://github.com/tau-lang/tau/blob/main/generator-qbe/src/emitter.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_options,node_compile,node_developer toneBlue
class node_lexer,node_parser,node_header,node_analyzer,node_type_inference,node_type_system,node_typed_ast,node_translator,node_ir_emitter toneAmber
class node_c_codegen,node_c_header,node_c_format toneMint
class node_llvm,node_llvm_declarations,node_llvm_statements,node_qbe toneRose
```

## Components

### Command line

- [CLI options](https://github.com/tau-lang/tau/blob/main/compiler-cli/src/options.rs): `compiler-cli/src/options.rs`
- [Compile dispatch](https://github.com/tau-lang/tau/blob/main/compiler-cli/src/lib.rs): `compiler-cli/src/lib.rs`

### Compiler core

- [Lexer](https://github.com/tau-lang/tau/blob/main/compiler-core/src/lexer.rs): `compiler-core/src/lexer.rs`
- [Parser](https://github.com/tau-lang/tau/blob/main/compiler-core/src/parser.rs): `compiler-core/src/parser.rs`
- [Header pass](https://github.com/tau-lang/tau/blob/main/compiler-core/src/header.rs): `compiler-core/src/header.rs`
- [Semantic analysis](https://github.com/tau-lang/tau/blob/main/compiler-core/src/analyzer.rs): `compiler-core/src/analyzer.rs`
- [Type inference](https://github.com/tau-lang/tau/blob/main/compiler-core/src/type_/expression.rs): `compiler-core/src/type_/expression.rs`
- [Type system](https://github.com/tau-lang/tau/blob/main/compiler-core/src/type_.rs): `compiler-core/src/type_.rs`
- [Typed AST](https://github.com/tau-lang/tau/blob/main/compiler-core/src/ast/declaration.rs): `compiler-core/src/ast/declaration.rs`
- [IR translator](https://github.com/tau-lang/tau/blob/main/compiler-core/src/translator.rs): `compiler-core/src/translator.rs`
- [IR emitter API](https://github.com/tau-lang/tau/blob/main/compiler-core/src/ir/emitter.rs): `compiler-core/src/ir/emitter.rs`

### C backend

- [C code generator](https://github.com/tau-lang/tau/blob/main/generator-c/src/code.rs): `generator-c/src/code.rs`
- [C header generator](https://github.com/tau-lang/tau/blob/main/generator-c/src/header.rs): `generator-c/src/header.rs`
- [C source formatting](https://github.com/tau-lang/tau/blob/main/generator-c/src/source_code.rs): `generator-c/src/source_code.rs`

### Other backends

- [LLVM backend](https://github.com/tau-lang/tau/blob/main/generator-llvm/src/expression.rs): `generator-llvm/src/expression.rs`
- [LLVM declarations](https://github.com/tau-lang/tau/blob/main/generator-llvm/src/declaration.rs): `generator-llvm/src/declaration.rs`
- [LLVM statements](https://github.com/tau-lang/tau/blob/main/generator-llvm/src/statement.rs): `generator-llvm/src/statement.rs`
- [QBE backend](https://github.com/tau-lang/tau/blob/main/generator-qbe/src/emitter.rs): `generator-qbe/src/emitter.rs`

### Other components

- **Compiler user**

## Connections

- Compiler user → CLI options: sets options (evidence: `compiler-cli/src/options.rs`)
- CLI options → Compile dispatch: configures (evidence: `compiler-cli/src/lib.rs`)
- Compile dispatch → Lexer: processes source
- Lexer → Parser: supplies tokens (evidence: `compiler-core/src/lib.rs`)
- Parser → Header pass: passes AST (evidence: `compiler-core/src/lib.rs`)
- Header pass → Semantic analysis: precedes analysis (evidence: `compiler-core/src/lib.rs`)
- Semantic analysis → Type inference: checks types
- Type inference → Type system: uses types (evidence: `compiler-core/src/type_/expression.rs`)
- Semantic analysis → Typed AST: produces typed AST
- Compile dispatch → Typed AST: receives result (evidence: `compiler-cli/src/lib.rs`)
- Typed AST → IR translator: translated by
- IR translator → IR emitter API: calls emitter
- Compile dispatch → C code generator: transpiles AST (evidence: `compiler-cli/src/lib.rs`)
- Compile dispatch → C header generator: transpiles AST (evidence: `compiler-cli/src/lib.rs`)
- C code generator → C source formatting: formats output (evidence: `generator-c/src/code.rs`)
- C header generator → C source formatting: uses formatting (evidence: `generator-c/src/header.rs`)
- Compile dispatch → LLVM backend: folds AST (evidence: `compiler-cli/src/lib.rs`)
- Compile dispatch → QBE backend: translates AST (evidence: `compiler-cli/src/lib.rs`)
- LLVM backend → LLVM declarations: delegates declarations
- LLVM backend → LLVM statements: delegates statements
