# girishg17/gscript architecture

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

- Interactive diagram: https://gitdiagram.com/girishg17/gscript
- Repository: https://github.com/girishg17/gscript

## Overview

This repository implements a small language compiler and command-line runner. The main workflow reads a source file, tokenizes and parses it into an AST, generates assembly, then the runner invokes NASM and the linker before executing the binary. The language includes say, variable, and conditional statements. The graph separates the front end, AST model, code generation, and runner pipeline; source excerpts support the compiler calls, while the README is empty and unsampled internals are not inferred.

Main entry points: [`gscript-run.cpp`](https://github.com/girishg17/gscript/blob/main/gscript-run.cpp) (Build And Run), [`src/main.cpp`](https://github.com/girishg17/gscript/blob/main/src/main.cpp) (Compiler CLI), [`src/parser/parser.cpp`](https://github.com/girishg17/gscript/blob/main/src/parser/parser.cpp) (Parser), [`src/codegen/codegen.cpp`](https://github.com/girishg17/gscript/blob/main/src/codegen/codegen.cpp) (Assembly Generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runner["Runner"]
  node_runner["Build And Run<br/>[gscript-run.cpp]"]
  node_assembler["NASM"]
  node_object["Object File"]
  node_linker["Linker"]
  node_binary["Executable"]
end

subgraph group_frontend["Compiler Front End"]
  node_compiler["Compiler CLI<br/>[main.cpp]"]
  node_tokenizer["Tokenizer<br/>[tokenizer.cpp]"]
  node_parser["Parser<br/>[parser.cpp]"]
  node_ast_display["AST Display<br/>[main.cpp]"]
end

subgraph group_model["Language Model"]
  node_tokens["Token Types<br/>[token.hpp]"]
  node_ast["AST Nodes<br/>[ast.hpp]"]
end

subgraph group_backend["Code Generation"]
  node_codegen["Assembly Generator<br/>[codegen.cpp]"]
  node_assembly["Assembly File"]
end

node_user(("CLI User"))

node_user -->|"provides source"| node_runner
node_runner -->|"invokes compiler"| node_compiler
node_compiler -->|"tokenizes source"| node_tokenizer
node_tokenizer -->|"produces tokens"| node_tokens
node_compiler -->|"parses tokens"| node_parser
node_parser -->|"reads tokens"| node_tokens
node_parser -->|"builds nodes"| node_ast
node_compiler -->|"prints AST"| node_ast_display
node_compiler -->|"generates assembly"| node_codegen
node_codegen -->|"reads nodes"| node_ast
node_codegen -->|"writes assembly"| node_assembly
node_runner -->|"invokes NASM"| node_assembler
node_assembly -->|"assembles input"| node_assembler
node_assembler -->|"writes object"| node_object
node_runner -->|"invokes linker"| node_linker
node_object -->|"links input"| node_linker
node_linker -->|"writes executable"| node_binary
node_runner -->|"executes binary"| node_binary

click node_runner "https://github.com/girishg17/gscript/blob/main/gscript-run.cpp"
click node_compiler "https://github.com/girishg17/gscript/blob/main/src/main.cpp"
click node_tokenizer "https://github.com/girishg17/gscript/blob/main/src/lexer/tokenizer.cpp"
click node_tokens "https://github.com/girishg17/gscript/blob/main/src/lexer/token.hpp"
click node_parser "https://github.com/girishg17/gscript/blob/main/src/parser/parser.cpp"
click node_ast "https://github.com/girishg17/gscript/blob/main/src/parser/ast.hpp"
click node_ast_display "https://github.com/girishg17/gscript/blob/main/src/main.cpp"
click node_codegen "https://github.com/girishg17/gscript/blob/main/src/codegen/codegen.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_runner,node_assembler,node_object,node_linker,node_binary,node_user toneBlue
class node_compiler,node_tokenizer,node_parser,node_ast_display toneAmber
class node_tokens,node_ast toneMint
class node_codegen,node_assembly toneRose
```

## Components

### Runner

- [Build And Run](https://github.com/girishg17/gscript/blob/main/gscript-run.cpp): `gscript-run.cpp`
- **NASM**
- **Object File**
- **Linker**
- **Executable**

### Compiler Front End

- [Compiler CLI](https://github.com/girishg17/gscript/blob/main/src/main.cpp): `src/main.cpp`
- [Tokenizer](https://github.com/girishg17/gscript/blob/main/src/lexer/tokenizer.cpp): `src/lexer/tokenizer.cpp`
- [Parser](https://github.com/girishg17/gscript/blob/main/src/parser/parser.cpp): `src/parser/parser.cpp`
- [AST Display](https://github.com/girishg17/gscript/blob/main/src/main.cpp): `src/main.cpp`

### Language Model

- [Token Types](https://github.com/girishg17/gscript/blob/main/src/lexer/token.hpp): `src/lexer/token.hpp`
- [AST Nodes](https://github.com/girishg17/gscript/blob/main/src/parser/ast.hpp): `src/parser/ast.hpp`

### Code Generation

- [Assembly Generator](https://github.com/girishg17/gscript/blob/main/src/codegen/codegen.cpp): `src/codegen/codegen.cpp`
- **Assembly File**

### Other components

- **CLI User**

## Connections

- CLI User → Build And Run: provides source (evidence: `gscript-run.cpp`)
- Build And Run → Compiler CLI: invokes compiler (evidence: `gscript-run.cpp`)
- Compiler CLI → Tokenizer: tokenizes source (evidence: `src/main.cpp`)
- Tokenizer → Token Types: produces tokens (evidence: `src/lexer/tokenizer.cpp`)
- Compiler CLI → Parser: parses tokens (evidence: `src/main.cpp`)
- Parser → Token Types: reads tokens
- Parser → AST Nodes: builds nodes (evidence: `src/parser/parser.cpp`)
- Compiler CLI → AST Display: prints AST (evidence: `src/main.cpp`)
- Compiler CLI → Assembly Generator: generates assembly (evidence: `src/main.cpp`)
- Assembly Generator → AST Nodes: reads nodes
- Assembly Generator → Assembly File: writes assembly (evidence: `src/codegen/codegen.cpp`)
- Build And Run → NASM: invokes NASM (evidence: `gscript-run.cpp`)
- Assembly File → NASM: assembles input
- NASM → Object File: writes object
- Build And Run → Linker: invokes linker (evidence: `gscript-run.cpp`)
- Object File → Linker: links input
- Linker → Executable: writes executable
- Build And Run → Executable: executes binary (evidence: `gscript-run.cpp`)
