def number_of_statements(self, n):
        """Compute the number of AST statements contained in a node."""
        stmt_type = n.type
        if stmt_type == syms.compound_stmt:
            return 1
        elif stmt_type == syms.stmt:
            return self.number_of_statements(n.children[0])
        elif stmt_type == syms.simple_stmt:
            # Divide to remove semi-colons.
            return len(n.children) // 2
        else:
            raise AssertionError("non-statement node")
def number_of_statements ( self , n ) : stmt_type = n . type if stmt_type == syms . compound_stmt : return 1 elif stmt_type == syms . stmt : return self . number_of_statements ( n . children [ 0 ] ) elif stmt_type == syms . simple_stmt : return len ( n . children ) // 2 else : raise AssertionError ( "non-statement node" )
Compute the number of AST statements contained in a node.