gogen.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:python-driver 作者: bblfsh 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号