Begin work on macro support
This commit is contained in:
parent
9228c72911
commit
4b4fa6acc5
18
gen6502.py
18
gen6502.py
|
@ -1,2 +1,20 @@
|
|||
import re, util
|
||||
|
||||
class Keys:
|
||||
MACRO_DEFINITION = "MACRO: (.*)"
|
||||
END = "END"
|
||||
@classmethod
|
||||
def find(cls,lines,k):
|
||||
pattern = getattr(cls,k.upper())
|
||||
pattern = pattern if pattern is not None else ""
|
||||
return [(x,re.match(pattern,lines[x])) for x in util.matchinglines(lines,pattern)]
|
||||
|
||||
def asm(i):
|
||||
macros = dict()
|
||||
lines = [l.strip() for l in i.split("\n") if l.strip()]
|
||||
for index, m in Keys.find(lines,"macro_definition"):
|
||||
m2 = util.walkup(lines,index,Keys.END)
|
||||
# print(index,m2)
|
||||
macros[m.group(1)]="\n".join(lines[index+1:m2])
|
||||
print(macros)
|
||||
return i
|
||||
|
|
Loading…
Reference in New Issue