|
|
@ -82,6 +82,7 @@ class Tokenizer: |
|
|
|
|
|
|
|
|
|
|
|
tok = Tokenizer(sys.stdin.read()) |
|
|
|
global_names = set() |
|
|
|
|
|
|
|
|
|
|
|
def processExpression(): |
|
|
@ -177,9 +178,13 @@ while tok: |
|
|
|
elif start.isA("COMMENT"): |
|
|
|
print(start.value) |
|
|
|
elif start.isA("DIRECTIVE"): |
|
|
|
if start.value in {".module", ".optsdcc", ".globl"}: |
|
|
|
if start.value in {".module", ".optsdcc"}: |
|
|
|
while not tok.pop().isA("NEWLINE"): |
|
|
|
pass |
|
|
|
elif start.value == ".globl": |
|
|
|
global_name = tok.pop().value |
|
|
|
global_names.add(global_name) |
|
|
|
assert tok.pop().isA("NEWLINE") |
|
|
|
elif start.value == ".area": |
|
|
|
area_name = tok.pop().value |
|
|
|
if area_name == "_DATA": |
|
|
@ -251,7 +256,10 @@ while tok: |
|
|
|
processExpression() |
|
|
|
sys.stdout.write("\n") |
|
|
|
elif tok.peek().isA("LABEL"): |
|
|
|
print("%s%s" % (start.value, tok.pop().value)) |
|
|
|
label_suffix = tok.pop().value |
|
|
|
if label_suffix == ":" and start.value in global_names: |
|
|
|
label_suffix = "::" |
|
|
|
print("%s%s" % (start.value, label_suffix)) |
|
|
|
elif start.isA("ID", "ldhl"): |
|
|
|
tok.expect("ID", "sp") |
|
|
|
tok.expect("OP", ",") |
|
|
|