blob: 0abdf2c0c619c87ee021bc34e3f722293ba9d72f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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()
|