diff options
author | Michael Pavone <pavone@retrodev.com> | 2019-02-15 23:58:34 -0800 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2019-02-15 23:58:34 -0800 |
commit | 9ddf999c06c6a24ab425130de7f01a01f6fa14fa (patch) | |
tree | f4b9f689dc456cf9bdd75bc08d5b76a5bdc4c373 | |
parent | 84198d4ef6e5f311945ec6f6a8956426a52795af (diff) |
Basic support for string operands in CPU DSL
-rwxr-xr-x | cpu_dsl.py | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -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) |