Mercurial > repos > blastem
comparison cpu_dsl.py @ 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 | 6e4faa10f9ee |
comparison
equal
deleted
inserted
replaced
1753:33ec5df77fac | 1754:043cf458704c |
---|---|
1574 line,_,comment = line.partition('#') | 1574 line,_,comment = line.partition('#') |
1575 if not line.strip(): | 1575 if not line.strip(): |
1576 continue | 1576 continue |
1577 if line[0].isspace(): | 1577 if line[0].isspace(): |
1578 if not cur_object is None: | 1578 if not cur_object is None: |
1579 parts = [el.strip() for el in line.split(' ')] | 1579 sep = True |
1580 parts = [] | |
1581 while sep: | |
1582 before,sep,after = line.partition('"') | |
1583 before = before.strip() | |
1584 if before: | |
1585 parts += [el.strip() for el in before.split(' ')] | |
1586 if sep: | |
1587 #TODO: deal with escaped quotes | |
1588 inside,sep,after = after.partition('"') | |
1589 parts.append('"' + inside + '"') | |
1590 line = after | |
1580 if type(cur_object) is dict: | 1591 if type(cur_object) is dict: |
1581 cur_object[parts[0]] = parts[1:] | 1592 cur_object[parts[0]] = parts[1:] |
1582 elif type(cur_object) is list: | 1593 elif type(cur_object) is list: |
1583 cur_object.append(line.strip()) | 1594 cur_object.append(' '.join(parts)) |
1584 else: | 1595 else: |
1585 cur_object = cur_object.processLine(parts) | 1596 cur_object = cur_object.processLine(parts) |
1586 | 1597 |
1587 # if type(cur_object) is Registers: | 1598 # if type(cur_object) is Registers: |
1588 # if len(parts) > 2: | 1599 # if len(parts) > 2: |