Alright - let me make this simple and straight:
How can I take advantage of the tex/latex parsing mechanism in a custom c/c++ application that need scripting/parsing support?
I see two ways: one is extracting the parsing code and placing it in the custom application and go from there, or the second way of - tex/latex being extensible, write a new document style with commands defined to be place holders for the C/C++ calls.
The background is like this: I have this CFugue music note parser that parses the music notes and plays them on MIDI. The basic note parser works fine in that CFugue. But, we need to add support for users to be able to define and extend their own commands (just like tex/latex allows its users). The other alternative scripting mechanisms - I dont like them. Nothing comes close to the simplicity and extensibility of this tex style of scripting.
So, instead of reinventing the wheel, I want to reuse the existing tex framework so that the commands when parsed and executed, instead of computing layouts for paper or book, they do something else that I want (may be play a midi command on a device, or write midi note to a file on disk).
In this sense, I am not sure the tex/latex code is modular enough to be placed directly into third party applications and reuse it directly by configuring the output device. So, seems the second alternative of defining custom commands is the way.
For example, how to write a command that can load a shared library (dll on windows) and make a call to one of its methods?
I know this is not something tex/latex is designed for from its usage point - but, as an opensource developer and architect I would expect the tex/latex code-design certainly to be capable of doing this if designed correctly.
Is there any work already done / existing on these lines? Or no other way than to start digging into the tex code and see what can be done to redesign it to be modular enough to segregate the parsing from the input and output devices?
In other words, how to make the tex/latex generate not the postscript commands onto a file, but some other commands understandable by some other device?