# farzonl/warflang architecture

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

- Interactive diagram: https://gitdiagram.com/farzonl/warflang
- Repository: https://github.com/farzonl/warflang
- Video tour (about a minute): https://gitdiagram.com/farzonl/warflang/video

## Overview

WarfLang is a small programming language with an interactive/file CLI, a WebAssembly-facing entry point, and tools for compiling source or running and translating its intermediate representation. The main source workflow parses text into syntax, binds it into typed bound nodes, then either evaluates it or lowers it to IR. Compiler and IR-tool paths extend that workflow to LLVM output when enabled. The graph follows the sampled entry-point orchestration; several internal implementations and the README’s build-focused documentation were not sampled.

Main entry points: [`src/cli/main.cpp`](https://github.com/farzonl/warflang/blob/master/src/cli/main.cpp) (Warf CLI / REPL), [`src/wasmEntry/wasmEntry.cpp`](https://github.com/farzonl/warflang/blob/master/src/wasmEntry/wasmEntry.cpp) (Wasm Entry), [`src/compilerTool/main.cpp`](https://github.com/farzonl/warflang/blob/master/src/compilerTool/main.cpp) (Source Compiler), [`src/irTool/main.cpp`](https://github.com/farzonl/warflang/blob/master/src/irTool/main.cpp) (IR Tool)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_cli["Warf CLI / REPL<br/>[main.cpp]"]
  node_wasm["Wasm Entry<br/>[wasmEntry.cpp]"]
  node_compiler["Source Compiler<br/>[main.cpp]"]
  node_irtool["IR Tool<br/>[main.cpp]"]
end

subgraph group_frontend["Source Frontend"]
  node_syntax_tree["Syntax Tree<br/>[SyntaxTree.cpp]"]
  node_parser["Parser<br/>[Parser.cpp]"]
  node_lexer["Lexer<br/>[Lexer.cpp]"]
end

subgraph group_semantics["Binding and Evaluation"]
  node_binder["Binder<br/>[Binder.cpp]"]
  node_symbols["Symbols and Scopes<br/>[Scope.cpp]"]
  node_evaluator["Bound Evaluator<br/>[Evaluator.cpp]"]
end

subgraph group_ir["IR Processing"]
  node_ir_lowerer["IR Lowerer and Printer<br/>[Ir.cpp]"]
  node_ir_parser["IR Parser<br/>[Ir.cpp]"]
  node_ir_interpreter["IR Interpreter<br/>[Ir.cpp]"]
end

subgraph group_backend["LLVM Backend"]
  node_llvm_backend["LLVM Backend<br/>[LlvmBackend.cpp]"]
end

node_user(("Language User"))
node_clang["Clang Compiler"]
node_result(("Program Result"))

node_user -->|"enters source"| node_cli
node_user -.->|"submits source"| node_wasm
node_user -->|"compiles source"| node_compiler
node_user -->|"runs or translates IR"| node_irtool
node_cli -->|"parses source"| node_syntax_tree
node_wasm -->|"parses source"| node_syntax_tree
node_compiler -->|"parses source"| node_syntax_tree
node_syntax_tree -->|"builds syntax"| node_parser
node_parser -->|"requests tokens"| node_lexer
node_cli -->|"binds syntax"| node_binder
node_wasm -->|"binds syntax"| node_binder
node_compiler -->|"binds syntax"| node_binder
node_binder -->|"resolves names"| node_symbols
node_cli -->|"evaluates bound code"| node_evaluator
node_wasm -->|"evaluates bound code"| node_evaluator
node_evaluator -->|"returns value"| node_result
node_cli -->|"lowers bound code"| node_ir_lowerer
node_wasm -->|"lowers bound code"| node_ir_lowerer
node_compiler -->|"lowers bound code"| node_ir_lowerer
node_ir_lowerer -->|"prints IR"| node_cli
node_ir_lowerer -->|"prints IR"| node_wasm
node_compiler -.->|"emits LLVM"| node_llvm_backend
node_llvm_backend -.->|"compiles LLVM IR"| node_clang
node_irtool -->|"parses IR file"| node_ir_parser
node_irtool -->|"executes module"| node_ir_interpreter
node_ir_interpreter -->|"returns value"| node_result
node_irtool -.->|"emits LLVM or bitcode"| node_llvm_backend
node_irtool -.->|"prints translated output"| node_result

click node_cli "https://github.com/farzonl/warflang/blob/master/src/cli/main.cpp"
click node_wasm "https://github.com/farzonl/warflang/blob/master/src/wasmEntry/wasmEntry.cpp"
click node_compiler "https://github.com/farzonl/warflang/blob/master/src/compilerTool/main.cpp"
click node_irtool "https://github.com/farzonl/warflang/blob/master/src/irTool/main.cpp"
click node_syntax_tree "https://github.com/farzonl/warflang/blob/master/src/lib/Syntax/SyntaxTree.cpp"
click node_parser "https://github.com/farzonl/warflang/blob/master/src/lib/Syntax/Parser.cpp"
click node_lexer "https://github.com/farzonl/warflang/blob/master/src/lib/Syntax/Lexer.cpp"
click node_binder "https://github.com/farzonl/warflang/blob/master/src/lib/Binding/Binder.cpp"
click node_symbols "https://github.com/farzonl/warflang/blob/master/src/lib/Symbol/Scope.cpp"
click node_evaluator "https://github.com/farzonl/warflang/blob/master/src/lib/CodeAnalysis/Evaluator.cpp"
click node_ir_lowerer "https://github.com/farzonl/warflang/blob/master/src/lib/IR/Ir.cpp"
click node_ir_parser "https://github.com/farzonl/warflang/blob/master/src/lib/IR/Ir.cpp"
click node_ir_interpreter "https://github.com/farzonl/warflang/blob/master/src/lib/IR/Ir.cpp"
click node_llvm_backend "https://github.com/farzonl/warflang/blob/master/src/llvmBackend/LlvmBackend.cpp"

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_wasm,node_compiler,node_irtool,node_user toneBlue
class node_syntax_tree,node_parser,node_lexer toneAmber
class node_binder,node_symbols,node_evaluator toneMint
class node_ir_lowerer,node_ir_parser,node_ir_interpreter toneRose
class node_llvm_backend,node_clang,node_result toneIndigo
```

## Components

### User Interfaces

- [Warf CLI / REPL](https://github.com/farzonl/warflang/blob/master/src/cli/main.cpp): `src/cli/main.cpp`
- [Wasm Entry](https://github.com/farzonl/warflang/blob/master/src/wasmEntry/wasmEntry.cpp): `src/wasmEntry/wasmEntry.cpp`
- [Source Compiler](https://github.com/farzonl/warflang/blob/master/src/compilerTool/main.cpp): `src/compilerTool/main.cpp`
- [IR Tool](https://github.com/farzonl/warflang/blob/master/src/irTool/main.cpp): `src/irTool/main.cpp`

### Source Frontend

- [Syntax Tree](https://github.com/farzonl/warflang/blob/master/src/lib/Syntax/SyntaxTree.cpp): `src/lib/Syntax/SyntaxTree.cpp`
- [Parser](https://github.com/farzonl/warflang/blob/master/src/lib/Syntax/Parser.cpp): `src/lib/Syntax/Parser.cpp`
- [Lexer](https://github.com/farzonl/warflang/blob/master/src/lib/Syntax/Lexer.cpp): `src/lib/Syntax/Lexer.cpp`

### Binding and Evaluation

- [Binder](https://github.com/farzonl/warflang/blob/master/src/lib/Binding/Binder.cpp): `src/lib/Binding/Binder.cpp`
- [Symbols and Scopes](https://github.com/farzonl/warflang/blob/master/src/lib/Symbol/Scope.cpp): `src/lib/Symbol/Scope.cpp`
- [Bound Evaluator](https://github.com/farzonl/warflang/blob/master/src/lib/CodeAnalysis/Evaluator.cpp): `src/lib/CodeAnalysis/Evaluator.cpp`

### IR Processing

- [IR Lowerer and Printer](https://github.com/farzonl/warflang/blob/master/src/lib/IR/Ir.cpp): `src/lib/IR/Ir.cpp`
- [IR Parser](https://github.com/farzonl/warflang/blob/master/src/lib/IR/Ir.cpp): `src/lib/IR/Ir.cpp`
- [IR Interpreter](https://github.com/farzonl/warflang/blob/master/src/lib/IR/Ir.cpp): `src/lib/IR/Ir.cpp`

### LLVM Backend

- [LLVM Backend](https://github.com/farzonl/warflang/blob/master/src/llvmBackend/LlvmBackend.cpp): `src/llvmBackend/LlvmBackend.cpp`

### Other components

- **Language User**
- **Clang Compiler**
- **Program Result**

## Connections

- Language User → Warf CLI / REPL: enters source
- Language User → Wasm Entry: submits source
- Language User → Source Compiler: compiles source
- Language User → IR Tool: runs or translates IR
- Warf CLI / REPL → Syntax Tree: parses source
- Wasm Entry → Syntax Tree: parses source
- Source Compiler → Syntax Tree: parses source
- Syntax Tree → Parser: builds syntax
- Parser → Lexer: requests tokens
- Warf CLI / REPL → Binder: binds syntax
- Wasm Entry → Binder: binds syntax
- Source Compiler → Binder: binds syntax
- Binder → Symbols and Scopes: resolves names
- Warf CLI / REPL → Bound Evaluator: evaluates bound code
- Wasm Entry → Bound Evaluator: evaluates bound code
- Bound Evaluator → Program Result: returns value
- Warf CLI / REPL → IR Lowerer and Printer: lowers bound code
- Wasm Entry → IR Lowerer and Printer: lowers bound code
- Source Compiler → IR Lowerer and Printer: lowers bound code
- IR Lowerer and Printer → Warf CLI / REPL: prints IR
- IR Lowerer and Printer → Wasm Entry: prints IR
- Source Compiler → LLVM Backend: emits LLVM
- LLVM Backend → Clang Compiler: compiles LLVM IR
- IR Tool → IR Parser: parses IR file
- IR Tool → IR Interpreter: executes module
- IR Interpreter → Program Result: returns value
- IR Tool → LLVM Backend: emits LLVM or bitcode
- IR Tool → Program Result: prints translated output
