aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/psi/execution.py
diff options
context:
space:
mode:
Diffstat (limited to 'psi/execution.py')
-rw-r--r--psi/execution.py46
1 files changed, 46 insertions, 0 deletions
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()