blob: 9871a3197f6c1aeb5e96f59052515ec0abf79baa (
plain)
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
|
import sys
#pywrong: THIS IS A FUCKING EXECUTABLE! LEAVE ME THE FUCK ALONE.
from py_nand_ass import parser_types as pt # pyright: ignore[reportImplicitRelativeImport]
from py_nand_ass.parser import parse_file # pyright: ignore[reportImplicitRelativeImport]
from py_nand_ass import assembler as ass # pyright: ignore[reportImplicitRelativeImport]
if __name__ == "__main__":
result = parse_file(sys.argv[1])
if not result:
print("Parsing returned an empty result")
sys.exit(1)
errors = ass.check_instructions(result)
errors = list(errors)
if errors:
for e in errors:
print(f"ERROR: On line {e.lineno}: {e.opcode} : {e.error_message}")
sys.exit(1)
print("Instruction checks passed")
p = ass.assemble(result)
if len(sys.argv) >= 3:
dest = sys.argv[2]
else:
dest = sys.argv[1] + ".bin"
p.write_to_file(dest)
|