pokemon/tools/parse/tileset_constants.py
Zack Buhman a921a44b66 parse: move tokenize_line/tokenize_lines to a new module
At times I forget what I have already written. I hope that this might help keep
things more organized.
2023-07-31 16:23:55 -07:00

17 lines
443 B
Python

from functools import partial
from parse.generic import macro_line
tokenize_lines = partial(macro_line.tokenize_lines, prefix='const ')
def flatten(tokens):
index = 0
for t in tokens:
assert t[0] == 'const', t
yield t[1][0], index
index += 1
def parse(prefix):
path = prefix / 'constants/tileset_constants.asm'
with open(path) as f:
return dict(flatten(tokenize_lines(f.read().split('\n'))))