From 9ddf999c06c6a24ab425130de7f01a01f6fa14fa Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Fri, 15 Feb 2019 23:58:34 -0800 Subject: Basic support for string operands in CPU DSL --- cpu_dsl.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'cpu_dsl.py') 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) -- cgit v1.2.3