-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcompiler.py
50 lines (36 loc) · 1.01 KB
/
compiler.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
48
49
50
"""Implement compiler using template-method pattern"""
from abc import ABC, abstractmethod
class Compiler(ABC):
"""Abstract Compiler Class
"""
@abstractmethod
def collect_source(self):
"""collect source code
"""
@abstractmethod
def compile_to_binary(self):
"""compile codes to binary
"""
@abstractmethod
def run(self):
"""run source code
"""
def compile_and_run(self):
"""compile and run codes,
with call all methods!
"""
self.collect_source()
self.compile_to_binary()
self.run()
class AndroidCompiler(Compiler):
"""android source code compiler
"""
def collect_source(self):
print("collecting source code...")
def compile_to_binary(self):
print("compiling source code to binary code...")
def run(self):
print("compiler is running...")
if __name__ == "__main__":
android_store_app = AndroidCompiler()
android_store_app.compile_and_run()