我们从Python开源项目中,提取了以下15个代码示例,用于说明如何使用symbol.small_stmt()。
def simple_stmt(self, nodelist): # small_stmt (';' small_stmt)* [';'] NEWLINE stmts = [] for i in range(0, len(nodelist), 2): self.com_append_stmt(stmts, nodelist[i]) return Stmt(stmts)
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:])
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