-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterpret.py
47 lines (38 loc) · 1.1 KB
/
interpret.py
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
47
from ArgParser import ArgParser
from FlowManager import FlowManager
from FrameManager import FrameManager
from IOManager import IOManager
from InstructionFactory import InstructionFactory
from StackManager import StackManager
from XMLManager import XMLManager
class Interpreter:
__instance = None
def __new__(cls):
if cls.__instance == None:
cls.__instance = super().__new__(cls)
return cls.__instance
def __init__(self):
# initialize all
ArgParser()
IOManager()
XMLManager()
FlowManager()
FrameManager()
StackManager()
InstructionFactory()
@staticmethod
def getInstance():
return __class__.__instance
def interpret(self):
FLOW = FlowManager.getInstance()
IF = InstructionFactory.getInstance()
# program loop
while (True):
curr = FLOW.getNextIns()
# end condition
if curr == None:
break
ins = IF.gen(curr)
ins.execute()
my_interpreter = Interpreter()
my_interpreter.interpret()