# simocastro18/interprete_python architecture

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

- Interactive diagram: https://gitdiagram.com/simocastro18/interprete_python
- Repository: https://github.com/simocastro18/interprete_python

## Overview

This is a lightweight C++ interpreter for a Python-like language. A user supplies a script to the command-line entry point, which tokenizes it, parses tokens into an AST, and evaluates that tree to produce output. The runtime supports variables, arithmetic and boolean expressions, conditionals, loops, break, and integer lists. The excerpts show the main orchestration and evaluator; connections for capabilities documented in the README but not fully sampled are limited to the evidenced parser and evaluator paths.

Main entry points: [`main.cpp`](https://github.com/simocastro18/interprete_python/blob/main/main.cpp) (CLI runner), [`EvaluationVisitor.cpp`](https://github.com/simocastro18/interprete_python/blob/main/EvaluationVisitor.cpp) (Evaluator), [`Parser.cpp`](https://github.com/simocastro18/interprete_python/blob/main/Parser.cpp) (Parser), [`Syntax.cpp`](https://github.com/simocastro18/interprete_python/blob/main/Syntax.cpp) (AST dispatch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Script entry"]
  node_main["CLI runner<br/>[main.cpp]"]
end

subgraph group_front["Language frontend"]
  node_lexer["Lexer<br/>[Lexer.cpp]"]
  node_token["Token model<br/>[Token.h]"]
  node_parser["Parser<br/>[Parser.cpp]"]
  node_ast["AST nodes<br/>[Syntax.h]"]
  node_ast_impl["AST dispatch<br/>[Syntax.cpp]"]
end

subgraph group_runtime["Execution runtime"]
  node_visitor["Visitor interface<br/>[Visitor.h]"]
  node_evaluator["Evaluator"]
  node_symbols[("Symbol table<br/>[SymbolTable.h]")]
end

node_user(("Script user"))
node_script["Input script"]
node_stdout(("Program output"))
node_stderr(("Error output"))

node_user -->|"provides"| node_script
node_script -->|"opens"| node_main
node_main -->|"tokenizes"| node_lexer
node_lexer -->|"creates tokens"| node_token
node_main -->|"parses tokens"| node_parser
node_parser -->|"reads"| node_token
node_parser -->|"builds"| node_ast
node_main -->|"starts evaluation"| node_ast_impl
node_ast -->|"dispatches visits"| node_ast_impl
node_ast_impl -->|"uses interface"| node_visitor
node_evaluator -->|"implements"| node_visitor
node_evaluator -->|"reads and writes"| node_symbols
node_evaluator -->|"prints values"| node_stdout
node_main -->|"reports errors"| node_stderr

click node_main "https://github.com/simocastro18/interprete_python/blob/main/main.cpp"
click node_lexer "https://github.com/simocastro18/interprete_python/blob/main/Lexer.cpp"
click node_token "https://github.com/simocastro18/interprete_python/blob/main/Token.h"
click node_parser "https://github.com/simocastro18/interprete_python/blob/main/Parser.cpp"
click node_ast "https://github.com/simocastro18/interprete_python/blob/main/Syntax.h"
click node_ast_impl "https://github.com/simocastro18/interprete_python/blob/main/Syntax.cpp"
click node_visitor "https://github.com/simocastro18/interprete_python/blob/main/Visitor.h"
click node_evaluator "https://github.com/simocastro18/interprete_python/blob/main/EvaluationVisitor.cpp"
click node_symbols "https://github.com/simocastro18/interprete_python/blob/main/SymbolTable.h"

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,node_user toneBlue
class node_lexer,node_token,node_parser,node_ast,node_ast_impl toneAmber
class node_visitor,node_evaluator,node_symbols toneMint
class node_script,node_stdout,node_stderr toneIndigo
```

## Components

### Script entry

- [CLI runner](https://github.com/simocastro18/interprete_python/blob/main/main.cpp): `main.cpp`

### Language frontend

- [Lexer](https://github.com/simocastro18/interprete_python/blob/main/Lexer.cpp): `Lexer.cpp`
- [Token model](https://github.com/simocastro18/interprete_python/blob/main/Token.h): `Token.h`
- [Parser](https://github.com/simocastro18/interprete_python/blob/main/Parser.cpp): `Parser.cpp`
- [AST nodes](https://github.com/simocastro18/interprete_python/blob/main/Syntax.h): `Syntax.h`
- [AST dispatch](https://github.com/simocastro18/interprete_python/blob/main/Syntax.cpp): `Syntax.cpp`

### Execution runtime

- [Visitor interface](https://github.com/simocastro18/interprete_python/blob/main/Visitor.h): `Visitor.h`
- [Evaluator](https://github.com/simocastro18/interprete_python/blob/main/EvaluationVisitor.cpp): `EvaluationVisitor.cpp`
- [Symbol table](https://github.com/simocastro18/interprete_python/blob/main/SymbolTable.h): `SymbolTable.h`

### Other components

- **Script user**
- **Input script**
- **Program output**
- **Error output**

## Connections

- Script user → Input script: provides
- Input script → CLI runner: opens
- CLI runner → Lexer: tokenizes
- Lexer → Token model: creates tokens
- CLI runner → Parser: parses tokens
- Parser → Token model: reads
- Parser → AST nodes: builds
- CLI runner → AST dispatch: starts evaluation
- AST nodes → AST dispatch: dispatches visits
- AST dispatch → Visitor interface: uses interface
- Evaluator → Visitor interface: implements
- Evaluator → Symbol table: reads and writes
- Evaluator → Program output: prints values
- CLI runner → Error output: reports errors
