How sebastianzapatar/compi works
Main Components
• Main Entry Point:
• main.py – Initializes the system and likely starts the REPL or main loop.
• Language Core (located under the "lenguaje" directory):
• lexer.py – Contains the lexical analyzer (tokenizer) that reads input strings and produces tokens.
• token.py – Defines the token types and possibly token attributes used by the lexer.
• parser.py – Implements the parser which converts the stream of tokens into a syntactic structure.
• ast.py – Constructs and manages the Abstract Syntax Tree (AST) that represents the parsed program.
• object.py – Likely contains definitions for runtime objects and possibly mechanisms for evaluation.
• repl.py – Provides an interactive Read-Eval-Print Loop interface for the language.
• __init__.py – Initializes the module for easier imports.
Relationships and Data Flow
• The program starts in main.py, which probably sets up the system environment and invokes the REPL.
• The REPL (repl.py) receives user input and passes it to the lexer (lexer.py), which produces a series of tokens (using definitions from token.py).
• Tokens are then fed into the parser (parser.py) to build an AST (constructed via ast.py).
• The AST is either evaluated directly—using mechanisms in object.py—or further processed.
• There might be feedback from the evaluation to the REPL for displaying results.
Architectural Patterns and Design Principles
• Modularization: The project is broken down into distinct components (lexer, parser, REPL, etc.) to separate concerns.
• Pipeline Structure: Data flows sequentially—source code input → lexing → parsing → AST creation → evaluation.
• Interpreter Pattern: The design suggests interpreting the language as input is processed (especially given the presence of a REPL).
• Clear separation between language definition parts (lexer, parser, ast) and the execution environment (repl, object handling).
Relevant Technologies or Libraries
• Standard Python modules and conventions since the project is implemented in Python.
• Although there’s no explicit listing of external libraries, note that Python’s dynamic and interpreted nature is a design choice here.
Instructing the Software Engineer
• Use callouts or annotations where necessary to explain that the REPL is the interactive component bridging user input and the language engine.
• Separation between the system’s core language processing components and the external interface (REPL/main.py).