Add parent tracking using a stack to track the path from the current node being visited to the tree root. I'm using a ParentNode enum with two variants, one for ExpressionNode and another for StatementNode which covers all possible visitable nodes that may have children, the variants store a reference to the actual node so I had to change the lifetimes to &'ast explicitly on the Visitable trait, perhaps there is a better way.
Add parent tracking using a stack to track the path from the current node being visited to the tree root. I'm using a
ParentNode
enum with two variants, one forExpressionNode
and another forStatementNode
which covers all possible visitable nodes that may have children, the variants store a reference to the actual node so I had to change the lifetimes to &'ast explicitly on theVisitable
trait, perhaps there is a better way.