summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2019-02-15 23:58:34 -0800
committerMichael Pavone <pavone@retrodev.com>2019-02-15 23:58:34 -0800
commit9ddf999c06c6a24ab425130de7f01a01f6fa14fa (patch)
treef4b9f689dc456cf9bdd75bc08d5b76a5bdc4c373
parent84198d4ef6e5f311945ec6f6a8956426a52795af (diff)
Basic support for string operands in CPU DSL
-rwxr-xr-xcpu_dsl.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/cpu_dsl.py b/cpu_dsl.py
index e77fe34..651a5b0 100755
--- a/cpu_dsl.py
+++ b/cpu_dsl.py
@@ -1576,11 +1576,22 @@ def parse(args):
continue
if line[0].isspace():
if not cur_object is None:
- parts = [el.strip() for el in line.split(' ')]
+ sep = True
+ parts = []
+ while sep:
+ before,sep,after = line.partition('"')
+ before = before.strip()
+ if before:
+ parts += [el.strip() for el in before.split(' ')]
+ if sep:
+ #TODO: deal with escaped quotes
+ inside,sep,after = after.partition('"')
+ parts.append('"' + inside + '"')
+ line = after
if type(cur_object) is dict:
cur_object[parts[0]] = parts[1:]
elif type(cur_object) is list:
- cur_object.append(line.strip())
+ cur_object.append(' '.join(parts))
else:
cur_object = cur_object.processLine(parts)