Skip to content

Commit f25d17a

Browse files
committed
split instructions on commas and whitespace
All of the following now parse as `["mov", "pins", "1"]` and assemble to 0x6001: ``` out pins , 1 ; out pins, 1 ; out pins,1 ; out pins ,1 ; out pins 1 ; ``` This brings pioasm closer to what upstream's examples show Closes: #7
1 parent f227a50 commit f25d17a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

adafruit_pioasm.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
"""
1313

1414
import array
15+
import re
16+
17+
splitter = re.compile(r',\s*|\s+(?:,\s*)?').split
1518

1619
__version__ = "0.0.0-auto.0"
1720
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PIOASM.git"
@@ -61,7 +64,7 @@ def assemble(text_program):
6164
assembled = []
6265
for instruction in instructions:
6366
# print(instruction)
64-
instruction = instruction.split()
67+
instruction = splitter(instruction.strip())
6568
delay = 0
6669
if instruction[-1].endswith("]"): # Delay
6770
delay = int(instruction[-1].strip("[]"))

0 commit comments

Comments
 (0)