How simocastro18/interprete_python works
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 CLI runner · EvaluationVisitor.cpp Evaluator · Parser.cpp Parser · Syntax.cpp AST dispatch
Components 13
Script entry
- CLI runner
main.cpp
Language frontend
- Lexer
Lexer.cpp - Token model
Token.h - Parser
Parser.cpp - AST nodes
Syntax.h - AST dispatch
Syntax.cpp
Execution runtime
- Visitor interface
Visitor.h - Evaluator
EvaluationVisitor.cpp - Symbol table
SymbolTable.h
Other components
- Script user
- Input script
- Program output
- Error output
Connections 14
- 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