当前位置: 首页>>代码示例>>Python>>正文


Python L.tree_size方法代码示例

本文整理汇总了Python中incoq.compiler.incast.L.tree_size方法的典型用法代码示例。如果您正苦于以下问题:Python L.tree_size方法的具体用法?Python L.tree_size怎么用?Python L.tree_size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在incoq.compiler.incast.L的用法示例。


在下文中一共展示了L.tree_size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: transform_source

# 需要导入模块: from incoq.compiler.incast import L [as 别名]
# 或者: from incoq.compiler.incast.L import tree_size [as 别名]
def transform_source(input_source, *, options=None, query_options=None):
    """Take in the Python source code to a module and return the
    transformed source code and the symbol table.
    """
    tree = P.Parser.p(input_source)
    
    t1 = process_time()
    tree, symtab = transform_ast(tree, options=options,
                                 query_options=query_options)
    t2 = process_time()
    
    source = P.Parser.ts(tree)
    # All good human beings have trailing newlines in their
    # text files.
    source = source + '\n'
    
    symtab.stats['lines'] = get_loc_source(source)
    # L.tree_size() is for IncASTs, but it should also work for
    # Python ASTs. We have to re-parse the source to get rid of
    # our Comment pseudo-nodes.
    tree = P.Parser.p(source)
    symtab.stats['ast_nodes'] = L.tree_size(tree)
    symtab.stats['time'] = t2 - t1
    
    return source, symtab
开发者ID:jieaozhu,项目名称:dist_lang_reviews,代码行数:27,代码来源:apply.py

示例2: process

# 需要导入模块: from incoq.compiler.incast import L [as 别名]
# 或者: from incoq.compiler.incast.L import tree_size [as 别名]
 def process(self, tree):
     # Keep maps from each seen query name to its original expression
     # and its rewritten expression.
     self.queries_before = {}
     self.queries_after = {}
     
     # A query's symbol definition has to be updated before we
     # discover any of its occurrences, or it will be incorrectly
     # interpreted as a consistency error. For this reason, process
     # all query definitions before the tree, and process these
     # definitions in order of increasing size so that inner queries
     # come first.
     queries = list(self.symtab.get_queries().values())
     queries.sort(key=lambda q: L.tree_size(q.node))
     for query in queries:
         query.node = super().process(query.node)
     
     # Process tree.
     tree = super().process(tree)
     
     return tree
开发者ID:jieaozhu,项目名称:dist_lang_reviews,代码行数:23,代码来源:symtab.py


注:本文中的incoq.compiler.incast.L.tree_size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。