I created the data structure to implement it as immutable code. If you look at the expression precedence implementation they do it with mutable code and one can barely understand what is going on. That being said, if you have any suggestions how to implement this better, I will gladly revise my code.
Discuss with @adriaanm, but I think you'll increase your chances of the code being merged if you make it as consistent as possible with what's already there. Ideally sharing the term logic with the type logic.
If you can share type and term logic with a pure implementation and not degrade performance then that would stand a good chance. The performance hurdle might be a tough one unless you're very very careful.