-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompile.py
More file actions
84 lines (62 loc) · 2.5 KB
/
Compile.py
File metadata and controls
84 lines (62 loc) · 2.5 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
"""File used to compile files to machine code the 5 bit computer can read
Author: Drake Setera
Date: 6/20/2025
Version: 3.1.0
"""
from CompileAssembly import CompiledAssembly
from CompileBase5 import Compiled5Bit
from CompileCode import CompiledCode
def main():
"""Function used to compressed data
"""
file:str = input("What file would you like to compile?\n")
valid_input = False
choice = ''
if file.endswith(".5ba"):
while not valid_input:
choice = input("\nWhat would you like to compress the file to?\nMachine code '.5b' (m)\nBase 5 '.b5' (b)\n")
if choice.upper() in ['M','B']:
valid_input = True
else:
print("Invalid input")
if choice.upper() == 'M':
compiled = CompiledAssembly(file)
if choice.upper() == 'B':
compiled = CompiledAssembly(file,'b5')
elif file.endswith(".5bl"):
while not valid_input:
choice = input("\nWhat would you like to compress the file to?\nAssembly code '.5ba' (a)\nMachine code '.5b' (m)\nBase 5 '.b5' (b)")
if choice.upper() in ['M', 'A', 'B']:
valid_input = True
else:
print("Invalid input")
if choice.upper() == 'A':
compiled = CompiledCode(file)
elif choice.upper() == 'M':
compiled1 = CompiledCode(file)
file = file.removesuffix("l") + "a"
compiled2 = CompiledAssembly(file)
elif choice.upper() == 'B':
compiled1 = CompiledCode(file)
file = file.removesuffix("l") + "a"
compiled2 = CompiledAssembly(file, 'b5')
elif file.endswith(".5b"):
while not valid_input:
choice = input("\nWhat would you like to compress the file to?\nBase 5 '.b5' (b)\n")
if choice.upper() == 'B':
valid_input = True
else:
print("Invalid input")
if choice.upper() == 'B':
compiled = Compiled5Bit(file)
elif file.endswith(".b5"):
while not valid_input:
choice = input("\nWhat would you like to compress the file to?\nMachine code '.5b' (m)\n")
if choice.upper() == 'M':
valid_input = True
else:
print("Invalid input")
if choice.upper() == 'B':
compiled = Compiled5Bit(file)
if __name__ == '__main__':
main()