Fix argument insertion

This commit is contained in:
Jan-Niclas Loosen
2025-10-18 14:08:20 +02:00
parent 64061d8b79
commit 081a7132fc
3 changed files with 32 additions and 12 deletions

View File

@@ -41,13 +41,20 @@ class MaMa:
# Decodes string MaMa instructions to function callables
@staticmethod
def decode(micro: str) -> Tuple[str, Optional[List[int]]]:
def decode(micro: str) -> Tuple[str, Optional[List[Any]]]:
if "(" in micro:
name, rest = micro.split("(", 1)
args_str = rest[:-1]
if args_str.strip() == "":
args_str = rest[:-1].strip()
if args_str == "":
return name, []
args = [int(a.strip()) for a in args_str.split(",")]
args = []
for a in args_str.split(","):
a = a.strip()
try:
a = int(a)
except ValueError:
pass # keep symbolic argument (e.g., 'n')
args.append(a)
return name, args
return micro, None