Merge pull request #8 from jepler/commas

split instructions on commas and whitespace
This commit is contained in:
Scott Shawcroft 2021-02-12 11:06:28 -08:00 committed by GitHub
commit a631797c0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,6 +12,9 @@ Simple assembler to convert pioasm to bytes
""" """
import array import array
import re
splitter = re.compile(r",\s*|\s+(?:,\s*)?").split
__version__ = "0.0.0-auto.0" __version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PIOASM.git" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PIOASM.git"
@ -61,7 +64,7 @@ def assemble(text_program):
assembled = [] assembled = []
for instruction in instructions: for instruction in instructions:
# print(instruction) # print(instruction)
instruction = instruction.split() instruction = splitter(instruction.strip())
delay = 0 delay = 0
if instruction[-1].endswith("]"): # Delay if instruction[-1].endswith("]"): # Delay
delay = int(instruction[-1].strip("[]")) delay = int(instruction[-1].strip("[]"))