From 719b598e98baff2cf5ea34bb6d36eddd8fd29f38 Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Thu, 28 Sep 2023 00:09:06 +0800 Subject: feat(src): delete `src` dir & rename `psi` dir feat(frame): 添加`Lib` `Grammar` `Modules` 目录 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- psi/execution.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 psi/execution.py (limited to 'psi/execution.py') diff --git a/psi/execution.py b/psi/execution.py new file mode 100644 index 0000000..0abdf2c --- /dev/null +++ b/psi/execution.py @@ -0,0 +1,46 @@ +from psi.parsers import Parser +from psi.interpreter import Interpreter + +__all__ = ['Execution'] + +class Execution: + """ + A class representing the execution of Psi code. + + Args: + input: The input code to be executed. + + Returns: + None + + Example: + ```python + execution = Execution("print('Hello, World!')") + execution.execute() + ``` + """ + + def __init__(self, input): + """ + Initializes an Execution object. + + Args: + input: The input code to be executed. + + Returns: + None + """ + self.input = input + + def execute(self): + """ + Executes the input code. + + Returns: + The result of the execution. + """ + parser = Parser(self.input) + ast = parser.parse() + + interpreter = Interpreter(ast) + return interpreter.interpret() -- cgit v1.2.3-70-g09d2