Skip to content

Commit c6f7971

Browse files
committed
implement some stuff
1 parent 4c3760e commit c6f7971

File tree

5 files changed

+37
-0
lines changed

5 files changed

+37
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
venv/
2+
__pycache__/

src/__init__.py

Whitespace-only changes.

src/__main__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# type: ignore
2+
from parser import parse_instruction
3+
from translate_code import translate_a_instruction, translate_c_instruction
4+
5+
6+
def main():
7+
user_input = input("Enter the full instruction: ")
8+
parse_instruction(user_input)
9+
10+
11+
if __name__ == "__main__":
12+
main()

src/parser.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
def parse_instruction(instruction: str):
2+
if instruction.startswith("@"):
3+
parse_a_instruction(instruction)
4+
5+
parse_c_instruction(instruction)
6+
7+
8+
def parse_c_instruction(instruction: str) -> tuple[str, str, str]:
9+
split_instruction = instruction.split("=")
10+
dest = split_instruction[0]
11+
12+
if ";" in split_instruction[1]:
13+
comp, jump = split_instruction[1].split(";")
14+
else:
15+
comp = split_instruction[1]
16+
jump = ""
17+
18+
print("dest: {}, comp: {}, jump: {}".format(dest, comp, jump))
19+
return (dest, comp, jump)
20+
21+
22+
def parse_a_instruction(instruction: str) -> str:
23+
print("Stubbed")
24+
return ""
File renamed without changes.

0 commit comments

Comments
 (0)