visitor class is in the library for exactly this reason, though: to allow people to create custom visitors to accomplish whatever task they’d like to on top of a
parse_tree output by the parser. In fact, almost all of the things we do with the parse trees are actually implemented as sublcasses of
visitor in the library itself (see, for example, our implementation of evalb). So this is the approach I would recommend—the library API directly encourages creating your own custom
visitor objects by design.
If you feel your particular task is something that many other people would benefit from, however, then we should probably add it as a built-in visitor in the toolkit so that people don’t need to re-implement it every time—feel free to submit a pull request in this case.
(Towards the very end of this tutorial you can see an example custom vistor. This is using the Python bindings, but the principle is the same in C++ as well.)