I'm interested in configuring my Emacs environment to perform real-time compilation of a Standard ML buffer, on the event corresponding to a ";" character being entered (at the end of a line), such that the result of the compilation shows in a second buffer in a parallel window. The online SML interpreter SOSML (https://sosml.org/editor) does something like this, with the compiler output going in another text field on the same page. It is reactive this same way, using the ";" character.
I have been able to figure out how to compile SML in Emacs via a shell in a separate buffer and window (M-x run-sml), but only by explicitly entering commands when I'd like to compile an entire file. I do have SML Mode installed in Emacs and the text analysis is working well. But I'm struggling to find documentation about how Emacs might be able to watch a buffer and react in realtime to a character (such as ";") to trigger compilation of that same buffer in another buffer and window.
I appreciate any suggestions as to the appropriate convention and tool here.