# albazzaztariq/unilogic architecture

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

- Interactive diagram: https://gitdiagram.com/albazzaztariq/unilogic
- Repository: https://github.com/albazzaztariq/unilogic

## Overview

UniLogic is a multi-target language compiler and toolchain. A user supplies a UL source file; the driver coordinates lexing, parsing into an AST, normalization and semantic checks, then invokes a selected backend to produce C, Python, JavaScript, LLVM IR or WebAssembly. The repository also documents reverse-transpilation, configurable memory models, profiling, project/package commands and interactive tools. The graph centers on the compiler workflow and retains these documented capability branches. Some peripheral features are README-only; their internal wiring is not established by the sampled source.

Main entry points: [`Main.py`](https://github.com/albazzaztariq/unilogic/blob/main/Main.py) (Compiler driver), [`Compiler/SynTree Def/ast_nodes.py`](https://github.com/albazzaztariq/unilogic/blob/main/Compiler/SynTree%20Def/ast_nodes.py) (AST nodes), [`Compiler/AST Gen/token2ast.py`](https://github.com/albazzaztariq/unilogic/blob/main/Compiler/AST%20Gen/token2ast.py) (Parser), [`Transcoder/Decoder/ul2c.py`](https://github.com/albazzaztariq/unilogic/blob/main/Transcoder/Decoder/ul2c.py) (C backend)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_driver["Compiler Driver"]
  node_main["Compiler driver<br/>[Main.py]"]
end

subgraph group_front["Language Front End"]
  node_lexer["Lexer<br/>[src2token.py]"]
  node_parser["Parser<br/>[token2ast.py]"]
  node_ast["AST nodes<br/>[ast_nodes.py]"]
  node_normalize["AST normalizer<br/>[simplifycode.py]"]
  node_semcheck["Semantic checker<br/>[semcheck.py]"]
end

subgraph group_backends["Code Generation"]
  node_cgen["C backend<br/>[ul2c.py]"]
  node_pygen["Python backend<br/>[ul2py.py]"]
  node_jsgen["JavaScript backend<br/>[ul2js.py]"]
  node_llvmgen["LLVM backend<br/>[ul2llvm.py]"]
  node_wasm["WebAssembly target"]
  node_pyencode["Python encoder<br/>[py2ul.py]"]
  node_cencode["C encoder<br/>[c2ul.py]"]
  node_ubicode["Bytecode encoder<br/>[ul2ubi.py]"]
end

subgraph group_extras["Runtime And Tools"]
  node_memory["Memory models"]
  node_profiler["Profiler"]
  node_pkg["Package manager"]
  node_repl["REPL"]
  node_vscode["VS Code extension"]
  node_project["Project manager"]
end

node_user(("UL author"))
node_target["Generated target"]

node_user -->|"submits source"| node_main
node_main -->|"tokenizes source"| node_lexer
node_main -->|"parses tokens"| node_parser
node_parser -->|"builds nodes"| node_ast
node_main -->|"normalizes AST"| node_normalize
node_main -->|"checks semantics"| node_semcheck
node_main -->|"selects backend"| node_cgen
node_main -->|"selects backend"| node_pygen
node_main -->|"selects backend"| node_jsgen
node_main -->|"selects backend"| node_llvmgen
node_main -->|"offers target"| node_wasm
node_cgen -->|"walks AST"| node_ast
node_pygen -->|"walks AST"| node_ast
node_jsgen -->|"walks AST"| node_ast
node_llvmgen -->|"walks AST"| node_ast
node_main -->|"emits target"| node_target
node_user -->|"transpiles from"| node_pyencode
node_user -->|"transpiles from"| node_cencode
node_user -->|"chooses bytecode"| node_ubicode
node_user -->|"configures memory"| node_memory
node_user -->|"profiles execution"| node_profiler
node_user -->|"manages project"| node_pkg
node_user -->|"runs interactively"| node_repl
node_user -->|"uses editor tools"| node_vscode
node_user -->|"manages projects"| node_project

click node_main "https://github.com/albazzaztariq/unilogic/blob/main/Main.py"
click node_lexer "https://github.com/albazzaztariq/unilogic/blob/main/Compiler/Lexer/src2token.py"
click node_parser "https://github.com/albazzaztariq/unilogic/blob/main/Compiler/AST%20Gen/token2ast.py"
click node_ast "https://github.com/albazzaztariq/unilogic/blob/main/Compiler/SynTree%20Def/ast_nodes.py"
click node_normalize "https://github.com/albazzaztariq/unilogic/blob/main/Compiler/simplifycode.py"
click node_semcheck "https://github.com/albazzaztariq/unilogic/blob/main/Compiler/Semantic/semcheck.py"
click node_cgen "https://github.com/albazzaztariq/unilogic/blob/main/Transcoder/Decoder/ul2c.py"
click node_pygen "https://github.com/albazzaztariq/unilogic/blob/main/Transcoder/Decoder/ul2py.py"
click node_jsgen "https://github.com/albazzaztariq/unilogic/blob/main/Transcoder/Decoder/ul2js.py"
click node_llvmgen "https://github.com/albazzaztariq/unilogic/blob/main/Transcoder/Decoder/ul2llvm.py"
click node_wasm "https://github.com/albazzaztariq/unilogic/tree/main/Transcoder/Decoder"
click node_pyencode "https://github.com/albazzaztariq/unilogic/blob/main/Transcoder/Encoder/py2ul.py"
click node_cencode "https://github.com/albazzaztariq/unilogic/blob/main/Transcoder/Encoder/c2ul.py"
click node_ubicode "https://github.com/albazzaztariq/unilogic/blob/main/Transcoder/Encoder/ul2ubi.py"
click node_memory "https://github.com/albazzaztariq/unilogic/tree/main/Compiler/Runtime"

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_main toneBlue
class node_lexer,node_parser,node_ast,node_normalize,node_semcheck toneAmber
class node_cgen,node_pygen,node_jsgen,node_llvmgen,node_wasm,node_pyencode,node_cencode,node_ubicode toneMint
class node_memory,node_profiler,node_pkg,node_repl,node_vscode,node_project toneRose
class node_user,node_target toneIndigo
```

## Components

### Compiler Driver

- [Compiler driver](https://github.com/albazzaztariq/unilogic/blob/main/Main.py): `Main.py`

### Language Front End

- [Lexer](https://github.com/albazzaztariq/unilogic/blob/main/Compiler/Lexer/src2token.py): `Compiler/Lexer/src2token.py`
- [Parser](https://github.com/albazzaztariq/unilogic/blob/main/Compiler/AST%20Gen/token2ast.py): `Compiler/AST Gen/token2ast.py`
- [AST nodes](https://github.com/albazzaztariq/unilogic/blob/main/Compiler/SynTree%20Def/ast_nodes.py): `Compiler/SynTree Def/ast_nodes.py`
- [AST normalizer](https://github.com/albazzaztariq/unilogic/blob/main/Compiler/simplifycode.py): `Compiler/simplifycode.py`
- [Semantic checker](https://github.com/albazzaztariq/unilogic/blob/main/Compiler/Semantic/semcheck.py): `Compiler/Semantic/semcheck.py`

### Code Generation

- [C backend](https://github.com/albazzaztariq/unilogic/blob/main/Transcoder/Decoder/ul2c.py): `Transcoder/Decoder/ul2c.py`
- [Python backend](https://github.com/albazzaztariq/unilogic/blob/main/Transcoder/Decoder/ul2py.py): `Transcoder/Decoder/ul2py.py`
- [JavaScript backend](https://github.com/albazzaztariq/unilogic/blob/main/Transcoder/Decoder/ul2js.py): `Transcoder/Decoder/ul2js.py`
- [LLVM backend](https://github.com/albazzaztariq/unilogic/blob/main/Transcoder/Decoder/ul2llvm.py): `Transcoder/Decoder/ul2llvm.py`
- [WebAssembly target](https://github.com/albazzaztariq/unilogic/tree/main/Transcoder/Decoder): `Transcoder/Decoder`
- [Python encoder](https://github.com/albazzaztariq/unilogic/blob/main/Transcoder/Encoder/py2ul.py): `Transcoder/Encoder/py2ul.py`
- [C encoder](https://github.com/albazzaztariq/unilogic/blob/main/Transcoder/Encoder/c2ul.py): `Transcoder/Encoder/c2ul.py`
- [Bytecode encoder](https://github.com/albazzaztariq/unilogic/blob/main/Transcoder/Encoder/ul2ubi.py): `Transcoder/Encoder/ul2ubi.py`

### Runtime And Tools

- [Memory models](https://github.com/albazzaztariq/unilogic/tree/main/Compiler/Runtime): `Compiler/Runtime`
- **Profiler**
- **Package manager**
- **REPL**
- **VS Code extension**
- **Project manager**

### Other components

- **UL author**
- **Generated target**

## Connections

- UL author → Compiler driver: submits source
- Compiler driver → Lexer: tokenizes source (evidence: `Main.py`)
- Compiler driver → Parser: parses tokens (evidence: `Main.py`)
- Parser → AST nodes: builds nodes (evidence: `Compiler/AST Gen/token2ast.py`)
- Compiler driver → AST normalizer: normalizes AST (evidence: `Main.py`)
- Compiler driver → Semantic checker: checks semantics (evidence: `Main.py`)
- Compiler driver → C backend: selects backend (evidence: `Main.py`)
- Compiler driver → Python backend: selects backend (evidence: `Main.py`)
- Compiler driver → JavaScript backend: selects backend (evidence: `Main.py`)
- Compiler driver → LLVM backend: selects backend (evidence: `Main.py`)
- Compiler driver → WebAssembly target: offers target (evidence: `Main.py`)
- C backend → AST nodes: walks AST (evidence: `Transcoder/Decoder/ul2c.py`)
- Python backend → AST nodes: walks AST (evidence: `Transcoder/Decoder/ul2py.py`)
- JavaScript backend → AST nodes: walks AST (evidence: `Transcoder/Decoder/ul2js.py`)
- LLVM backend → AST nodes: walks AST (evidence: `Transcoder/Decoder/ul2llvm.py`)
- Compiler driver → Generated target: emits target (evidence: `Main.py`)
- UL author → Python encoder: transpiles from
- UL author → C encoder: transpiles from
- UL author → Bytecode encoder: chooses bytecode
- UL author → Memory models: configures memory
- UL author → Profiler: profiles execution
- UL author → Package manager: manages project
- UL author → REPL: runs interactively
- UL author → VS Code extension: uses editor tools
- UL author → Project manager: manages projects
