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


Python symbol.stmt方法代码示例

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


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

示例1: Annotate

# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import stmt [as 别名]
def Annotate(cls, symbol_type, children):
    if symbol_type != symbol.stmt:
      return None

    compound_statement = children[0]
    if compound_statement.type != symbol.compound_stmt:
      return None

    statement = compound_statement.children[0]
    if statement.type == symbol.funcdef:
      return cls(statement.type, statement.children)
    elif (statement.type == symbol.decorated and
          statement.children[-1].type == symbol.funcdef):
      return cls(statement.type, statement.children)
    else:
      return None 
开发者ID:FSecureLABS,项目名称:Jandroid,代码行数:18,代码来源:function_definition.py

示例2: Annotate

# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import stmt [as 别名]
def Annotate(cls, symbol_type, children):
    if symbol_type != symbol.stmt:
      return None

    compound_statement = children[0]
    if compound_statement.type != symbol.compound_stmt:
      return None

    statement = compound_statement.children[0]
    if statement.type == symbol.classdef:
      return cls(statement.type, statement.children)
    elif (statement.type == symbol.decorated and
          statement.children[-1].type == symbol.classdef):
      return cls(statement.type, statement.children)
    else:
      return None 
开发者ID:FSecureLABS,项目名称:Jandroid,代码行数:18,代码来源:class_definition.py

示例3: stmt

# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import stmt [as 别名]
def stmt(self, nodelist):
        return self.com_stmt(nodelist[0]) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:4,代码来源:transformer.py

示例4: suite

# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import stmt [as 别名]
def suite(self, nodelist):
        # simple_stmt | NEWLINE INDENT NEWLINE* (stmt NEWLINE*)+ DEDENT
        if len(nodelist) == 1:
            return self.com_stmt(nodelist[0])

        stmts = []
        for node in nodelist:
            if node[0] == symbol.stmt:
                self.com_append_stmt(stmts, node)
        return Stmt(stmts)

    # --------------------------------------------------------------
    #
    # EXPRESSION NODES  (invoked by com_node())
    # 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:transformer.py

示例5: com_node

# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import stmt [as 别名]
def com_node(self, node):
        # Note: compile.c has handling in com_node for del_stmt, pass_stmt,
        #       break_stmt, stmt, small_stmt, flow_stmt, simple_stmt,
        #       and compound_stmt.
        #       We'll just dispatch them.
        return self._dispatch[node[0]](node[1:]) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:transformer.py

示例6: get_docstring

# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import stmt [as 别名]
def get_docstring(self, node, n=None):
        if n is None:
            n = node[0]
            node = node[1:]
        if n == symbol.suite:
            if len(node) == 1:
                return self.get_docstring(node[0])
            for sub in node:
                if sub[0] == symbol.stmt:
                    return self.get_docstring(sub)
            return None
        if n == symbol.file_input:
            for sub in node:
                if sub[0] == symbol.stmt:
                    return self.get_docstring(sub)
            return None
        if n == symbol.atom:
            if node[0][0] == token.STRING:
                s = ''
                for t in node:
                    s = s + eval(t[1])
                return s
            return None
        if n == symbol.stmt or n == symbol.simple_stmt \
           or n == symbol.small_stmt:
            return self.get_docstring(node[0])
        if n in _doc_nodes and len(node) == 1:
            return self.get_docstring(node[0])
        return None 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:31,代码来源:transformer.py

示例7: analyze_morf

# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import stmt [as 别名]
def analyze_morf(self, morf):
        if self.analysis_cache.has_key(morf):
            return self.analysis_cache[morf]
        filename = self.morf_filename(morf)
        ext = os.path.splitext(filename)[1]
        if ext == '.pyc':
            if not os.path.exists(filename[0:-1]):
                raise self.error, ("No source for compiled code '%s'."
                                   % filename)
            filename = filename[0:-1]
        elif ext != '.py':
            raise self.error, "File '%s' not Python source." % filename
        source = open(filename, 'r')
        import parser
        tree = parser.suite(source.read()).totuple(1)
        source.close()
        statements = {}
        self.find_statements(tree, statements)
        lines = statements.keys()
        lines.sort()
        result = filename, lines
        self.analysis_cache[morf] = result
        return result

    # find_statements(tree, dict).  Find each statement in the parse
    # tree and record the line on which the statement starts in the
    # dictionary (by assigning it to 1).
    #
    # It works by walking the whole tree depth-first.  Every time it
    # comes across a statement (symbol.stmt -- this includes compound
    # statements like 'if' and 'while') it calls find_statement, which
    # descends the tree below the statement to find the first terminal
    # token in that statement and record the lines on which that token
    # was found.
    #
    # This algorithm may find some lines several times (because of the
    # grammar production statement -> compound statement -> statement),
    # but that doesn't matter because we record lines as the keys of the
    # dictionary.
    #
    # See also [GDR 2001-12-04b, 3.2]. 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:43,代码来源:coverage.py

示例8: find_statements

# 需要导入模块: import symbol [as 别名]
# 或者: from symbol import stmt [as 别名]
def find_statements(self, tree, dict):
        import symbol, token
        if token.ISNONTERMINAL(tree[0]):
            for t in tree[1:]:
                self.find_statements(t, dict)
            if tree[0] == symbol.stmt:
                self.find_statement(tree[1], dict)
        elif (tree[0] == token.NAME
              and tree[1] in ['elif', 'except', 'finally']):
            dict[tree[2]] = 1 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:12,代码来源:coverage.py


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