def generate23(outpath):
allsyms = list( generate2().union(generate3()) )
# add the types that we add to improve the raw AST information
allsyms.extend(["StringLiteral", "NoneLiteral", "NumLiteral", "ByteLiteral", "BoolLiteral",
"PreviousNoops", "NoopLine", "SameLineNoops", "RemainderNoops",
"noop_line"])
allsyms.sort()
maxlen = max((len(i) for i in allsyms))
decl_list = ['\t{symbol:<{maxlen}} = "{symbol}"'.format(symbol=i, maxlen=maxlen) for i in allsyms]
symlist_str = '\n'.join(decl_list)
final_content = CONTENT.format(constants=symlist_str).lstrip()
with open(outpath, 'w') as destfile:
print(final_content, file=destfile)
评论列表
文章目录