Beyond Notations: Hygienic Macro Expansion for Theorem Proving Languages
arxiv.org
arxiv.org
With some improvements and modifications, this algorithm is part of the meta-programming system of Lean 4; it is what allows complex syntactic transformations in a context where safety/correctness is crucial.
A more broad overview of Lean's metaprogramming can be found in [0], but the algorithm is of independent interest and language developers may be interested in studying it.
[0] https://leanprover-community.github.io/lean4-metaprogramming...
The cure is daily s-expression.