From e84a5b2062ff5e9b010447e3a3c78dd67a653166 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Sun, 1 Sep 2013 02:27:44 -0500 Subject: make extras/ a submodule Use pokemontools v1.3.0 and use the same preprocessor as the pokecrystal project. --- textpre.py | 82 ++++++-------------------------------------------------------- 1 file changed, 7 insertions(+), 75 deletions(-) (limited to 'textpre.py') diff --git a/textpre.py b/textpre.py index d8099693..4a5fb116 100644 --- a/textpre.py +++ b/textpre.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +import extras.pokemontools.preprocessor as preprocessor + import sys chars = { @@ -254,81 +256,11 @@ chars = { "6": 0xFC, "7": 0xFD, "8": 0xFE, -"9": 0xFF - +"9": 0xFF, } -for l in sys.stdin: - - # strip comments - line = l.partition(";") - i = 0 - asm = "" - while i < len(line) and l[0] != ";": - asm = asm + line[i] - i = i + 1 - - # skip asm with no quotes - if "\"" not in asm: - sys.stdout.write(l) - continue - - # split by quotes - asms = asm.split("\"") - - # skip asm that actually does use ASCII in quotes - lowasm = asms[0].lower() - if "section" in lowasm \ - or "include" in lowasm \ - or "incbin" in lowasm: - sys.stdout.write(l) - continue - - even = False - i = 0 - for token in asms: - i = i + 1 - if even: - # token is a string to convert to byte values - - while len(token): - # read a single UTF-8 codepoint - char = token[0] - if ord(char) >= 0xFC: - char = char + token[1:6] - token = token[6:] - elif ord(char) >= 0xF8: - char = char + token[1:5] - token = token[5:] - elif ord(char) >= 0xF0: - char = char + token[1:4] - token = token[4:] - elif ord(char) >= 0xE0: - char = char + token[1:3] - token = token[3:] - elif ord(char) >= 0xC0: - char = char + token[1:2] - token = token[2:] - else: - token = token[1:] - - # certain apostrophe-letter pairs are only a single byte - if char == "'" and \ - (token[0] == "d" or \ - token[0] == "l" or \ - token[0] == "m" or \ - token[0] == "r" or \ - token[0] == "s" or \ - token[0] == "t" or \ - token[0] == "v"): - char = char + token[0] - token = token[1:] - - sys.stdout.write("${0:02X}".format(chars[char])) - - if len(token): - sys.stdout.write(", ") +preprocessor.chars = chars - else: - sys.stdout.write(token) - even = not even +macros = [] +macro_table = preprocessor.make_macro_table(macros) +preprocessor.preprocess(macro_table) -- cgit v1.3.1-sl0p From fecbe4a60c25175a3fec944be9704b27e263142a Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Mon, 16 Sep 2013 12:42:46 -0500 Subject: bump and support latest pokemontools --- extras | 2 +- textpre.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'textpre.py') diff --git a/extras b/extras index 7aa016fb..2374a9ce 160000 --- a/extras +++ b/extras @@ -1 +1 @@ -Subproject commit 7aa016fb528bcc8dcb30c6a887957851623eccc0 +Subproject commit 2374a9ce905ccc4c701f81904b01019641e884b5 diff --git a/textpre.py b/textpre.py index 4a5fb116..c4e65398 100644 --- a/textpre.py +++ b/textpre.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import extras.pokemontools.preprocessor as preprocessor +import extras.pokemontools.configuration as configuration import sys @@ -261,6 +262,6 @@ chars = { preprocessor.chars = chars -macros = [] -macro_table = preprocessor.make_macro_table(macros) -preprocessor.preprocess(macro_table) +config = configuration.Config() +processor = preprocessor.Preprocessor(config, []) +processor.preprocess() -- cgit v1.3.1-sl0p