From f25d17af8e139ad52e5974cbd19e90141d7af8b3 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 12 Feb 2021 08:55:04 -0600 Subject: [PATCH 1/2] 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 --- adafruit_pioasm.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/adafruit_pioasm.py b/adafruit_pioasm.py index cc86192..c60db0c 100644 --- a/adafruit_pioasm.py +++ b/adafruit_pioasm.py @@ -12,6 +12,9 @@ """ import array +import re + +splitter = re.compile(r',\s*|\s+(?:,\s*)?').split __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PIOASM.git" @@ -61,7 +64,7 @@ def assemble(text_program): assembled = [] for instruction in instructions: # print(instruction) - instruction = instruction.split() + instruction = splitter(instruction.strip()) delay = 0 if instruction[-1].endswith("]"): # Delay delay = int(instruction[-1].strip("[]")) From bfbd002c246901656be2bc1c4306b50921548594 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 12 Feb 2021 09:44:54 -0600 Subject: [PATCH 2/2] run black --- adafruit_pioasm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_pioasm.py b/adafruit_pioasm.py index c60db0c..22bf47b 100644 --- a/adafruit_pioasm.py +++ b/adafruit_pioasm.py @@ -14,7 +14,7 @@ import array import re -splitter = re.compile(r',\s*|\s+(?:,\s*)?').split +splitter = re.compile(r",\s*|\s+(?:,\s*)?").split __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PIOASM.git"