# zakiraghakishiyev/pldpi-mini-project architecture

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

- Interactive diagram: https://gitdiagram.com/zakiraghakishiyev/pldpi-mini-project
- Repository: https://github.com/zakiraghakishiyev/pldpi-mini-project

## Overview

IMPlex is a small Go interpreter for an imperative language. A user supplies a source file and optional integer inputs to the CLI; the CLI tokenizes and parses the program, then executes its AST and prints accumulated results. The runtime supports scoped variables and ordered input/output, while expression evaluation checks arithmetic overflow and runtime errors. The README documents control flow, lexical scoping, Boolean and comparison operators, and checked arithmetic. Relationships below follow the CLI and sampled implementation; unsampled modules are not inferred.

Main entry points: [`internal/runtime/runtime.go`](https://github.com/zakiraghakishiyev/pldpi-mini-project/blob/main/internal/runtime/runtime.go) (Run State), [`cmd/implex/main.go`](https://github.com/zakiraghakishiyev/pldpi-mini-project/blob/main/cmd/implex/main.go) (IMPlex CLI), [`internal/interpreter/statements.go`](https://github.com/zakiraghakishiyev/pldpi-mini-project/blob/main/internal/interpreter/statements.go) (Statement Evaluator), [`internal/interpreter/expressions.go`](https://github.com/zakiraghakishiyev/pldpi-mini-project/blob/main/internal/interpreter/expressions.go) (Expression Evaluator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Source Front End"]
  node_lexer["Lexer<br/>[lexer.go]"]
  node_parser["Parser<br/>[parser.go]"]
end

subgraph group_syntax["Program Syntax"]
  node_ast["AST Types<br/>[ast.go]"]
end

subgraph group_execution["Execution"]
  node_statements["Statement Evaluator<br/>[statements.go]"]
  node_expressions["Expression Evaluator<br/>[expressions.go]"]
end

subgraph group_state["Runtime State"]
  node_runtime["Run State<br/>[runtime.go]"]
  node_environment["Scoped Variables<br/>[environment.go]"]
  node_errors["Runtime Errors<br/>[errors.go]"]
end

node_user(("User"))
node_cli["IMPlex CLI<br/>[main.go]"]

node_user -->|"runs with inputs"| node_cli
node_cli -->|"tokenizes source"| node_lexer
node_cli -->|"parses tokens"| node_parser
node_cli -->|"creates run state"| node_runtime
node_cli -->|"executes program"| node_statements
node_cli -->|"prints results"| node_runtime
node_lexer -->|"uses positions"| node_ast
node_parser -->|"builds syntax tree"| node_ast
node_parser -->|"consumes tokens"| node_lexer
node_statements -->|"dispatches statements"| node_ast
node_statements -->|"evaluates expressions"| node_expressions
node_statements -->|"reads and writes state"| node_runtime
node_expressions -->|"evaluates expression nodes"| node_ast
node_expressions -->|"looks up variables"| node_runtime
node_statements -->|"manages block scopes"| node_environment
node_environment -->|"updates bindings"| node_runtime
node_runtime -->|"stores scope stack"| node_environment
node_expressions -->|"reports arithmetic errors"| node_errors
node_environment -->|"reports binding errors"| node_errors
node_runtime -->|"reports input errors"| node_errors

click node_cli "https://github.com/zakiraghakishiyev/pldpi-mini-project/blob/main/cmd/implex/main.go"
click node_lexer "https://github.com/zakiraghakishiyev/pldpi-mini-project/blob/main/internal/lexer/lexer.go"
click node_parser "https://github.com/zakiraghakishiyev/pldpi-mini-project/blob/main/internal/parser/parser.go"
click node_ast "https://github.com/zakiraghakishiyev/pldpi-mini-project/blob/main/internal/ast/ast.go"
click node_statements "https://github.com/zakiraghakishiyev/pldpi-mini-project/blob/main/internal/interpreter/statements.go"
click node_expressions "https://github.com/zakiraghakishiyev/pldpi-mini-project/blob/main/internal/interpreter/expressions.go"
click node_runtime "https://github.com/zakiraghakishiyev/pldpi-mini-project/blob/main/internal/runtime/runtime.go"
click node_environment "https://github.com/zakiraghakishiyev/pldpi-mini-project/blob/main/internal/runtime/environment.go"
click node_errors "https://github.com/zakiraghakishiyev/pldpi-mini-project/blob/main/internal/runtime/errors.go"

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_lexer,node_parser,node_user toneBlue
class node_ast toneAmber
class node_statements,node_expressions toneMint
class node_runtime,node_environment,node_errors toneRose
class node_cli toneTeal
```

## Components

### Source Front End

- [Lexer](https://github.com/zakiraghakishiyev/pldpi-mini-project/blob/main/internal/lexer/lexer.go): `internal/lexer/lexer.go`
- [Parser](https://github.com/zakiraghakishiyev/pldpi-mini-project/blob/main/internal/parser/parser.go): `internal/parser/parser.go`

### Program Syntax

- [AST Types](https://github.com/zakiraghakishiyev/pldpi-mini-project/blob/main/internal/ast/ast.go): `internal/ast/ast.go`

### Execution

- [Statement Evaluator](https://github.com/zakiraghakishiyev/pldpi-mini-project/blob/main/internal/interpreter/statements.go): `internal/interpreter/statements.go`
- [Expression Evaluator](https://github.com/zakiraghakishiyev/pldpi-mini-project/blob/main/internal/interpreter/expressions.go): `internal/interpreter/expressions.go`

### Runtime State

- [Run State](https://github.com/zakiraghakishiyev/pldpi-mini-project/blob/main/internal/runtime/runtime.go): `internal/runtime/runtime.go`
- [Scoped Variables](https://github.com/zakiraghakishiyev/pldpi-mini-project/blob/main/internal/runtime/environment.go): `internal/runtime/environment.go`
- [Runtime Errors](https://github.com/zakiraghakishiyev/pldpi-mini-project/blob/main/internal/runtime/errors.go): `internal/runtime/errors.go`

### Other components

- **User**
- [IMPlex CLI](https://github.com/zakiraghakishiyev/pldpi-mini-project/blob/main/cmd/implex/main.go): `cmd/implex/main.go`

## Connections

- User → IMPlex CLI: runs with inputs (evidence: `README.md`)
- IMPlex CLI → Lexer: tokenizes source (evidence: `cmd/implex/main.go`)
- IMPlex CLI → Parser: parses tokens (evidence: `cmd/implex/main.go`)
- IMPlex CLI → Run State: creates run state (evidence: `cmd/implex/main.go`)
- IMPlex CLI → Statement Evaluator: executes program (evidence: `cmd/implex/main.go`)
- IMPlex CLI → Run State: prints results (evidence: `cmd/implex/main.go`)
- Lexer → AST Types: uses positions (evidence: `internal/lexer/lexer.go`)
- Parser → AST Types: builds syntax tree (evidence: `internal/parser/parser.go`)
- Parser → Lexer: consumes tokens (evidence: `internal/parser/parser.go`)
- Statement Evaluator → AST Types: dispatches statements (evidence: `internal/interpreter/statements.go`)
- Statement Evaluator → Expression Evaluator: evaluates expressions (evidence: `internal/interpreter/statements.go`)
- Statement Evaluator → Run State: reads and writes state (evidence: `internal/interpreter/statements.go`)
- Expression Evaluator → AST Types: evaluates expression nodes (evidence: `internal/interpreter/expressions.go`)
- Expression Evaluator → Run State: looks up variables (evidence: `internal/interpreter/expressions.go`)
- Statement Evaluator → Scoped Variables: manages block scopes (evidence: `internal/interpreter/statements.go`)
- Scoped Variables → Run State: updates bindings (evidence: `internal/runtime/environment.go`)
- Run State → Scoped Variables: stores scope stack (evidence: `internal/runtime/runtime.go`)
- Expression Evaluator → Runtime Errors: reports arithmetic errors (evidence: `internal/interpreter/expressions.go`)
- Scoped Variables → Runtime Errors: reports binding errors (evidence: `internal/runtime/environment.go`)
- Run State → Runtime Errors: reports input errors (evidence: `internal/runtime/runtime.go`)
