When I was at uni back in the late 1980's we had an introductory course where we were taught Scheme (a LISP dialect). The book that was used throughout the course was Structure and Interpretation of Computer Programs
] by H. Abelson and G.J. Sussman.
One of the things that was engraved indelibly in my mind was an expression simulator written completely in Scheme. One of the principles that was used to solve this was called Propagation of Constraints
] in Chapter 3 about Modularity, Objects, and State
Please read this! Even though you'll not be implementing this in Scheme, there's still a lot to be learned from that book, especially how signals\states propagate through the network. The Celsius-Fahrenheit calculator works both ways for instance without you having to rewrite anything. It merely depends which pin is assigned a value the correct counterpart will be calculated. Back then I was really amazed at this principle.
This chapter is a bit closer to what you are looking for while I still think that above mentioned principle will be helpful in more general expression evaluators: 3.3.4 A Simulator for Digital Circuits
If you have any doubts, leave me a comment.