pystencils.backend.ast.astnode.PsAstNode#

class pystencils.backend.ast.astnode.PsAstNode#

Base class for all nodes in the pystencils AST.

This base class provides a common interface to inspect and update the AST’s branching structure. The two methods get_children and set_child must be implemented by each subclass. Subclasses are also responsible for doing the necessary type checks if they place restrictions on the types of their children.

abstract get_children()#

Retrieve child nodes of this AST node

This operation must be implemented by subclasses.

Return type:

tuple[PsAstNode, ...]

abstract set_child(idx, c)#

Update a child node of this AST node.

This operation must be implemented by subclasses.

Parameters:
abstract clone()#

Perform a deep copy of the AST.

Return type:

PsAstNode

structurally_equal(other)#

Check two ASTs for structural equality.

By default this method checks the node’s type and children. If an AST node has additional internal state, it MUST override this method.

Return type:

bool

Parameters:

other (PsAstNode)