pass_manager.py 文件源码

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

项目:monasca-analytics 作者: openstack 项目源码 文件源码
def execute_banana_string(banana, driver=None, emitter=emit.PrintEmitter()):
    """
    Execute the provided banana string.
    It will run the parse phase, and the typechecker.
    :type banana: str
    :param banana: The string to parse and type check.
    :type driver: monasca_analytics.spark.driver.DriverExecutor | None
    :param driver: Driver that will manage the created
        components and connect them together.
    :type emitter: emit.Emitter
    :param emitter: Emitter for reporting errors/warning.
    """
    try:
        # Convert the grammar into an AST
        parser = grammar.banana_grammar(emitter)
        ast = parser.parse(banana)
        # Compute the type table for the given AST
        type_table = typeck.typeck(ast)
        # Remove from the tree path that are "dead"
        deadpathck.deadpathck(ast, type_table, emitter)
        # Check that there's at least one path to be executed
        deadpathck.contains_at_least_one_path_to_a_sink(ast, type_table)
        # Evaluate the script
        if driver is not None:
            ev.eval_ast(ast, type_table, driver)
    except exception.BananaException as err:
        emitter.emit_error(err.get_span(), str(err))
    except p.ParseSyntaxException as err:
        emitter.emit_error(span_util.from_pyparsing_exception(err), err.msg)
    except p.ParseFatalException as err:
        emitter.emit_error(span_util.from_pyparsing_exception(err), err.msg)
    except p.ParseException as err:
        emitter.emit_error(span_util.from_pyparsing_exception(err), err.msg)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号