That is exactly what I am saying.
> TeX's input grammer can change during the TeX run, so I believe it is impossible to make an equivalent of LLVM
The important part is not the grammar, but the internal representation. I don't know enough about TeX to know much about its internal representation post-parsing.