aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-03-02 18:17:10 +0100
committerNao Pross <np@0hm.ch>2024-03-02 18:17:10 +0100
commit9dc875e5e67835ad1974b52491a4b7af072d52a3 (patch)
tree64ab75e1193a981f883f1d74a1f5cf4379351141
parentRewrite state type annotations to avoid circular import (diff)
downloadmdpoly-9dc875e5e67835ad1974b52491a4b7af072d52a3.tar.gz
mdpoly-9dc875e5e67835ad1974b52491a4b7af072d52a3.zip
Add Expr.node to ease iteration expression tree node children
-rw-r--r--mdpoly/abc.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/mdpoly/abc.py b/mdpoly/abc.py
index 7ac21dd..c60311a 100644
--- a/mdpoly/abc.py
+++ b/mdpoly/abc.py
@@ -33,6 +33,9 @@ class Expr(Protocol):
name = self.__class__.__qualname__
return f"{name}(left={self.left}, right={self.right})"
+ def nodes(self) -> Sequence[Self]:
+ return self.left, self.right
+
def leaves(self) -> Sequence[Leaf]:
if isinstance(self.left, Leaf):
yield self.left