Arborist.jl
https://github.com/oxinabox/Arborist.jl/It implements one of the more advanced tricks in JuliaLang.
Which is the concept behind Cassette.jl (https://github.com/jrevels/Cassette.jl) and IRTools.jl (https://github.com/MikeInnes/IRTools.jl).
which is this notion of a recursive source code tranformation.
This is the thing where you tranform code (kind of like a macro but not lexically scoped), including tranforming all function calls to also tranform their code.
It's super powerful
For example Zygote.jl (https://github.com/FluxML/Zygote.jl) implements reverse mode automatic differentiation, by defining a function that is a generated transformation of the function being differentiated.
MagneticReadHead.jl (https://github.com/oxinabox/MagneticReadHead.jl/) implements a debugger by defining a function that has been transformed to include debugger interupts.
This stuff also has a bunch of use for probabalistic programming languages etc.
The thing is Cassette and IRTools implement this at the lowered code level.
It runs on the SSA-form IR.
This IR was never really designed for the user to write it.
Though IRTools does a noble attempt to make it nice.
Arborist instead runs at the Abstract Syntax Tree (AST) level.
Just like macros.
This is designed to be written and manipulated by users. Users do that all the time by writing macros.
I haven't touched it in a while (apparently 2 years).
Largely because AFAICT it's not useful outside of pedagogical purposes.
AST is not actually that nice for any program tranforms i want to do,
since there are so many ways to write the same thing.
E.g. different kinds of loops and branches, where as in SSA form IR they all look the same.
Probably could be made to work, but i just don't really have a usecase that I can't do easier on IR.
(probably people who haven't been deep into IR on the other hand would think of some)
There are a bunch of edge cases where it crashes still, for things that are not allowed to appear in generated code.
It wouldn't be too hard to make it work though, not really.
Particularly since we now have tools like
https://github.com/SciML/RuntimeGeneratedFunctions.jl
https://github.com/JuliaStaging/GeneralizedGenerated.jl