At times I forget what I have already written. I hope that this might help keep things more organized.
17 lines
443 B
Python
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'))))
|