-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot.py
executable file
·46 lines (36 loc) · 1.18 KB
/
boot.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
#/usr/bin/python3
from optparse import OptionParser
from processor import Processor
from assembler import Assembler
import exceptions as exp
# Handle the options and arguments
def get_options():
parser = OptionParser(usage='t816 file [options]')
parser.add_option("-d", "--debug", dest="debug", action="store_true",
default=False, help="Show debug panel")
options, args = parser.parse_args()
if len(args) != 1:
parser.error("You must specify a file to execute")
return options, args
# This is our main entry point into the application
def main():
options, args = get_options()
# Create Processor
processor = Processor(options.debug)
# Load the programe given by the user
filename = args[0]
try:
if filename[-3:] == 'tsm':
processor.load(Assembler(filename).code, name=filename)
else:
processor.load_from_file(filename)
except exp.InvalidFile:
print("Invalid file %s" % filename)
exit(1)
except IOError:
print("File %s does not exist" % filename)
exit(1)
# Start the processing
processor.run()
if __name__ == '__main__':
main()