It's definitely me being to naive, however I would type all the expression, in either the source code (into comment) or in a separate file, and all the statement.
Now I do have a table of symbols and their type.
At this point its just a matter of using the AST to being sure that everything is correctly typed...
Then we interface with the AST of any language and we can stop re-iventing the wheel every two week...
It is so crazy ?
Nobody tried it before ?