_fn.py 文件源码

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

项目:tidy 作者: cyrus- 项目源码 文件源码
def _compile_rule(rule_translation, rest):
        test, binding_translations, ctx_update, branch_translation = \
            rule_translation

        if len(binding_translations) == 0:
            body = branch_translation
        else:
            body_lambda = astx.make_Lambda(
                (ctx_update[id][0] 
                 for id in binding_translations.iterkeys()),
                branch_translation)
            body = astx.make_simple_Call(
                body_lambda, 
                binding_translations.values())

        if len(rest) == 0:
            orelse = astx.expr_Raise_Exception_string("Match failure.")
        else:
            orelse = fn._compile_rule(rest[0], rest[1:])

        return ast.IfExp(
            test=test,
            body=body,
            orelse=orelse)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号