You could always use [HCR](https://nim-lang.org/docs/nimc.html#additional-features-hot-code-reloading).
I did something similar in my text editor which recompiles its [plugins](https://github.com/genotrance/feud/blob/master/src/plugin.nim) which are Nim dlls when the code changes. In your case, you could generate a nim file for the expression and load it as a dll and execute it that way.
