18 lines
460 B
Python
18 lines
460 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
|
|
_, (name,) = t
|
|
yield name, index
|
|
index += 1
|
|
|
|
def parse(prefix):
|
|
path = prefix / 'constants/move_constants.asm'
|
|
with open(path) as f:
|
|
return dict(flatten(tokenize_lines(f.read().split('\n'))))
|