Not entirely what you're describing, but pandoc goes a long way towards being a sort of LLVM for text documents. In order to do all the format conversions, it transforms inputs into a tree-based internal representation, and then translates that into the output format.
Unfortunately it doesn't have a (pure) TeX reader yet, but that could be implemented relatively easily.
Unfortunately it doesn't have a (pure) TeX reader yet, but that could be implemented relatively easily.