mirror of
https://github.com/piotr-wiszowaty/foco65.git
synced 2024-06-01 20:41:36 +00:00
added '[include] "<filename>"' statement
This commit is contained in:
parent
711a691dee
commit
68bd24bcd3
18
foco65
18
foco65
|
@ -623,7 +623,7 @@ class Forth:
|
|||
item_outputs = map(lambda i: i.output(section), self.items)
|
||||
section_outputs.append("".join(item_outputs))
|
||||
return "\n".join(section_outputs)
|
||||
|
||||
|
||||
#####
|
||||
|
||||
boot_text = """
|
||||
|
@ -1952,6 +1952,20 @@ m_star_done
|
|||
[end-code] ;
|
||||
"""
|
||||
|
||||
def resolve_includes(text):
|
||||
i = text.find("[include]")
|
||||
if (i > 0):
|
||||
start = text.find('"',i+10)
|
||||
end = text.find('"', start+1)
|
||||
chunk1 = text[:i-1]
|
||||
chunk2 = text[end+1:]
|
||||
filename = text[start+1:end]
|
||||
with open(filename, "rt") as f:
|
||||
ntext = f.read()
|
||||
text = resolve_includes(chunk1 + " " + ntext + " " + chunk2)
|
||||
|
||||
return text
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--sections", "-s", metavar="STR", default="init,boot,data,text")
|
||||
parser.add_argument("--pstack-bottom", "-p", metavar="ADDR", default="$600")
|
||||
|
@ -1965,6 +1979,8 @@ boot_params = {"pstack_bottom": args.pstack_bottom,
|
|||
with open(args.file, "rt") as f:
|
||||
text = f.read()
|
||||
|
||||
text = resolve_includes(text)
|
||||
|
||||
f = Forth(args.sections.split(","))
|
||||
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue
Block a user