20 lines
469 B
Python
20 lines
469 B
Python
from parse.map_header import tokenize_line
|
|
|
|
def tokenize_lines(lines):
|
|
for line in lines:
|
|
if 'const' in line:
|
|
yield tokenize_line(line)
|
|
|
|
|
|
def flatten(tokens):
|
|
index = 0
|
|
for t in tokens:
|
|
if t[0] == 'const':
|
|
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'))))
|