# quark-programming/quark architecture

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

- Interactive diagram: https://gitdiagram.com/quark-programming/quark
- Repository: https://github.com/quark-programming/quark

## Overview

Quark is an early-stage programming language compiler that translates Quark source into C. The principal workflow is command-line input, tokenization, parsing into syntax nodes, and compilation to an output file; parsing covers expressions, declarations, statements, literals, and types. The compiler dispatches syntax nodes to code-generation handlers. The README establishes the compiler’s purpose, while edges are limited to relationships shown in the supplied excerpts or SOURCE INDEX; several parser and compiler internals were not sampled.

Main entry points: [`src/main.c`](https://github.com/quark-programming/quark/blob/main/src/main.c) (CLI and orchestration), [`src/compiler/compiler.c`](https://github.com/quark-programming/quark/blob/main/src/compiler/compiler.c) (Compiler dispatch), [`src/parser/righthand/righthand.c`](https://github.com/quark-programming/quark/blob/main/src/parser/righthand/righthand.c) (Right expressions), [`src/parser/statement/keywords.c`](https://github.com/quark-programming/quark/blob/main/src/parser/statement/keywords.c) (Statement keywords)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_front["Source processing"]
  node_tokenizer["Tokenizer<br/>[tokenizer.c]"]
end

subgraph group_parse["Parsing and types"]
  node_parser_core["Parser state<br/>[parser.c]"]
  node_syntax_nodes["Syntax nodes<br/>[nodes.c]"]
  node_statements["Statements and scopes<br/>[statement.c]"]
  node_statement_keywords["Statement keywords<br/>[keywords.c]"]
  node_left_expr["Left expressions<br/>[lefthand.c]"]
  node_right_expr["Right expressions<br/>[righthand.c]"]
  node_field_access["Field and index access<br/>[field_access.c]"]
  node_declarations["Declarations<br/>[declaration.c]"]
  node_literals["Literal parsing<br/>[array.c]"]
  node_type_system["Type operations<br/>[types.c]"]
  node_generics["Generic types<br/>[generics.c]"]
end

subgraph group_compile["C generation"]
  node_compiler["Compiler dispatch<br/>[compiler.c]"]
  node_literal_codegen["Literal codegen<br/>[literals.c]"]
  node_expression_codegen["Expression codegen<br/>[righthand.c]"]
  node_declaration_codegen["Declaration codegen"]
  node_statement_codegen["Statement codegen<br/>[statement.c]"]
end

node_user(("Compiler user"))
node_cli["CLI and orchestration<br/>[main.c]"]
node_c_output["Generated C file"]

node_user -->|"provides source"| node_cli
node_cli -->|"creates tokenizer"| node_tokenizer
node_cli -->|"initializes parser"| node_parser_core
node_cli -->|"collects statements"| node_statements
node_cli -->|"compiles entry"| node_compiler
node_cli -->|"writes C"| node_c_output
node_parser_core -->|"uses node types"| node_syntax_nodes
node_left_expr -->|"parses continuation"| node_right_expr
node_left_expr -->|"parses literals"| node_literals
node_left_expr -->|"uses scopes"| node_statements
node_right_expr -.->|"dispatches access"| node_field_access
node_field_access -->|"resolves members"| node_declarations
node_field_access -->|"opens types"| node_type_system
node_statement_keywords -->|"uses scopes"| node_statements
node_statement_keywords -->|"parses expressions"| node_right_expr
node_statement_keywords -->|"checks types"| node_type_system
node_generics -->|"clashes types"| node_type_system
node_generics -->|"parses arguments"| node_right_expr
node_generics -->|"applies arguments"| node_declarations
node_compiler -->|"dispatches literals"| node_literal_codegen
node_compiler -->|"dispatches expressions"| node_expression_codegen
node_compiler -->|"dispatches declarations"| node_declaration_codegen
node_compiler -->|"dispatches statements"| node_statement_codegen

click node_cli "https://github.com/quark-programming/quark/blob/main/src/main.c"
click node_tokenizer "https://github.com/quark-programming/quark/blob/main/src/tokenizer/tokenizer.c"
click node_parser_core "https://github.com/quark-programming/quark/blob/main/src/parser/parser.c"
click node_syntax_nodes "https://github.com/quark-programming/quark/blob/main/src/parser/nodes/nodes.c"
click node_statements "https://github.com/quark-programming/quark/blob/main/src/parser/statement/statement.c"
click node_statement_keywords "https://github.com/quark-programming/quark/blob/main/src/parser/statement/keywords.c"
click node_left_expr "https://github.com/quark-programming/quark/blob/main/src/parser/lefthand/lefthand.c"
click node_right_expr "https://github.com/quark-programming/quark/blob/main/src/parser/righthand/righthand.c"
click node_field_access "https://github.com/quark-programming/quark/blob/main/src/parser/righthand/field_access.c"
click node_declarations "https://github.com/quark-programming/quark/blob/main/src/parser/righthand/declaration/declaration.c"
click node_literals "https://github.com/quark-programming/quark/blob/main/src/parser/literal/array.c"
click node_type_system "https://github.com/quark-programming/quark/blob/main/src/parser/type/types.c"
click node_generics "https://github.com/quark-programming/quark/blob/main/src/parser/type/generics.c"
click node_compiler "https://github.com/quark-programming/quark/blob/main/src/compiler/compiler.c"
click node_literal_codegen "https://github.com/quark-programming/quark/blob/main/src/compiler/literal/literals.c"
click node_expression_codegen "https://github.com/quark-programming/quark/blob/main/src/compiler/righthand/righthand.c"
click node_declaration_codegen "https://github.com/quark-programming/quark/blob/main/src/compiler/righthand/declaration/variable_declaration.c"
click node_statement_codegen "https://github.com/quark-programming/quark/blob/main/src/compiler/statement/statement.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_user toneBlue
class node_parser_core,node_syntax_nodes,node_statements,node_statement_keywords,node_left_expr,node_right_expr,node_field_access,node_declarations,node_literals,node_type_system,node_generics toneAmber
class node_compiler,node_literal_codegen,node_expression_codegen,node_declaration_codegen,node_statement_codegen toneMint
class node_cli toneTeal
class node_c_output toneIndigo
```

## Components

### Source processing

- [Tokenizer](https://github.com/quark-programming/quark/blob/main/src/tokenizer/tokenizer.c): `src/tokenizer/tokenizer.c`

### Parsing and types

- [Parser state](https://github.com/quark-programming/quark/blob/main/src/parser/parser.c): `src/parser/parser.c`
- [Syntax nodes](https://github.com/quark-programming/quark/blob/main/src/parser/nodes/nodes.c): `src/parser/nodes/nodes.c`
- [Statements and scopes](https://github.com/quark-programming/quark/blob/main/src/parser/statement/statement.c): `src/parser/statement/statement.c`
- [Statement keywords](https://github.com/quark-programming/quark/blob/main/src/parser/statement/keywords.c): `src/parser/statement/keywords.c`
- [Left expressions](https://github.com/quark-programming/quark/blob/main/src/parser/lefthand/lefthand.c): `src/parser/lefthand/lefthand.c`
- [Right expressions](https://github.com/quark-programming/quark/blob/main/src/parser/righthand/righthand.c): `src/parser/righthand/righthand.c`
- [Field and index access](https://github.com/quark-programming/quark/blob/main/src/parser/righthand/field_access.c): `src/parser/righthand/field_access.c`
- [Declarations](https://github.com/quark-programming/quark/blob/main/src/parser/righthand/declaration/declaration.c): `src/parser/righthand/declaration/declaration.c`
- [Literal parsing](https://github.com/quark-programming/quark/blob/main/src/parser/literal/array.c): `src/parser/literal/array.c`
- [Type operations](https://github.com/quark-programming/quark/blob/main/src/parser/type/types.c): `src/parser/type/types.c`
- [Generic types](https://github.com/quark-programming/quark/blob/main/src/parser/type/generics.c): `src/parser/type/generics.c`

### C generation

- [Compiler dispatch](https://github.com/quark-programming/quark/blob/main/src/compiler/compiler.c): `src/compiler/compiler.c`
- [Literal codegen](https://github.com/quark-programming/quark/blob/main/src/compiler/literal/literals.c): `src/compiler/literal/literals.c`
- [Expression codegen](https://github.com/quark-programming/quark/blob/main/src/compiler/righthand/righthand.c): `src/compiler/righthand/righthand.c`
- [Declaration codegen](https://github.com/quark-programming/quark/blob/main/src/compiler/righthand/declaration/variable_declaration.c): `src/compiler/righthand/declaration/variable_declaration.c`
- [Statement codegen](https://github.com/quark-programming/quark/blob/main/src/compiler/statement/statement.c): `src/compiler/statement/statement.c`

### Other components

- **Compiler user**
- [CLI and orchestration](https://github.com/quark-programming/quark/blob/main/src/main.c): `src/main.c`
- **Generated C file**

## Connections

- Compiler user → CLI and orchestration: provides source (evidence: `src/main.c`)
- CLI and orchestration → Tokenizer: creates tokenizer (evidence: `src/main.c`)
- CLI and orchestration → Parser state: initializes parser (evidence: `src/main.c`)
- CLI and orchestration → Statements and scopes: collects statements (evidence: `src/main.c`)
- CLI and orchestration → Compiler dispatch: compiles entry (evidence: `src/main.c`)
- CLI and orchestration → Generated C file: writes C (evidence: `src/main.c`)
- Parser state → Syntax nodes: uses node types
- Left expressions → Right expressions: parses continuation (evidence: `src/parser/lefthand/lefthand.c`)
- Left expressions → Literal parsing: parses literals (evidence: `src/parser/lefthand/lefthand.c`)
- Left expressions → Statements and scopes: uses scopes (evidence: `src/parser/lefthand/lefthand.c`)
- Right expressions → Field and index access: dispatches access
- Field and index access → Declarations: resolves members (evidence: `src/parser/righthand/field_access.c`)
- Field and index access → Type operations: opens types (evidence: `src/parser/righthand/field_access.c`)
- Statement keywords → Statements and scopes: uses scopes (evidence: `src/parser/statement/keywords.c`)
- Statement keywords → Right expressions: parses expressions (evidence: `src/parser/statement/keywords.c`)
- Statement keywords → Type operations: checks types (evidence: `src/parser/statement/keywords.c`)
- Generic types → Type operations: clashes types (evidence: `src/parser/type/generics.c`)
- Generic types → Right expressions: parses arguments (evidence: `src/parser/type/generics.c`)
- Generic types → Declarations: applies arguments (evidence: `src/parser/type/generics.c`)
- Compiler dispatch → Literal codegen: dispatches literals (evidence: `src/compiler/compiler.c`)
- Compiler dispatch → Expression codegen: dispatches expressions (evidence: `src/compiler/compiler.c`)
- Compiler dispatch → Declaration codegen: dispatches declarations (evidence: `src/compiler/compiler.c`)
- Compiler dispatch → Statement codegen: dispatches statements (evidence: `src/compiler/compiler.c`)
