curry.backends.py.graph.walkexpr module

Utilities for working with Curry expressions.

curry.backends.py.graph.walkexpr.iterexpr(expr)[source]

Generate each node in a Curry expression exactly once.

curry.backends.py.graph.walkexpr.walk(root, realpath=None)[source]

Walk a Curry expression.

This yields a “state” objects for each successor of the given root. The state consists of a cursor pointing to a subexpression, current path to the cursor, and other attributes. Iteration may be pruned or deepened by modifying the state. The subexpression under the cursor may be modified.

Variables:
  • stack – The remaining iteration state. May be modified to control the search. Call push to add the successors of the node under the cursor.

  • realpath – A list of integers giving the real path from the root to the cursor. Not to be modified.

  • spine – A list of nodes, equal in length to realpath, giving the node at each point along the path. Not to be modified.

  • cursor – The node currently being visited. Equivalent to spine[-1].

  • parent – The parent of the node at the cursor. Equivalent to spine[-2].