changeset 1754:043cf458704c

Basic support for string operands in CPU DSL
author Michael Pavone <pavone@retrodev.com>
date Fri, 15 Feb 2019 23:58:34 -0800
parents 33ec5df77fac
children 28635b733d97
files cpu_dsl.py
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/cpu_dsl.py	Tue Feb 12 09:58:04 2019 -0800
+++ b/cpu_dsl.py	Fri Feb 15 23:58:34 2019 -0800
@@ -1576,11 +1576,22 @@
 			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)