From e2c1c1911e117245551a612499d02eacabbbe5d8 Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Sun, 25 Feb 2024 12:00:16 +0800 Subject: refactor: rename nivis-python to nivis --- nivis/execution.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 nivis/execution.py (limited to 'nivis/execution.py') diff --git a/nivis/execution.py b/nivis/execution.py new file mode 100644 index 0000000..09055cf --- /dev/null +++ b/nivis/execution.py @@ -0,0 +1,47 @@ +from .parsers import Parser +from .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