Traverse the Tree
The Visitor
public class PrintVisitor : NodeVisitor<string>
{
public PrintVisitor()
{
For<GroupNode>(Visit);
}
private string Visit(GroupNode group)
{
return $"({Visit(group.Expr)})";
}
}Rewriting the tree
Last updated