Compiler/Virtual Machine Environment

Discussion in 'C++' started by ccrabfo, Apr 9, 2004.

  1. ccrabfo

    ccrabfo Guest

    Has anyone ever implemented embedding a "virtual host" or "virual machine"
    environment inside your C/C++ programs so that end-users could write small
    snippets of customized code, compile it using your custom compiler, and if
    the compiled byte-code file exists, it gets loaded and ran by the embedded
    virtual host engine?

    My thought was to develop a basic-like compiler system that the user could
    write a file called TASKA.MSC which looks like:

    // File: TASKA.MSC
    // Simple Task A Example
    Dim userdata as TUserData
    Clear userdata
    if GetUserData(userdata) then
    // do something with the data
    // specific to this end-user install
    end if

    Then run this through my compiler:

    mysc.exe taska.msc

    This would create something like taska.mxc which is a compiled byte-code
    binary file of the instructions found in the 4GL base source file. The
    virtual host environment would be inclusive inside my program or a DLL which
    basically is a virtual machine environment that loads the MXC file, and runs
    the binary version instead of having to verify the 4GL syntax, compile it,
    and then run it. All the virtual environment does is execute it (very much
    like java and its JVM).

    Anyone have any thoughts on:
    1) How to create such a compiler
    2) How to create the host environment to execute the compiled binary?

    ccrabfo, Apr 9, 2004
    1. Advertisements

  2. A number of commercial and free solutions already exist. Commercial
    solutions tend to emulate VBA and are fairly expensive. Free solutions
    include embedding Perl, Python, LISP, or other freely available

    If you want to implement this yourself, you'll save yourself a lot of hassle
    if you write an interpreter instead of a compiler. How to do that, however,
    is both off-topic for this newsgroup and beyond the reasonable scope for any
    posting. You could start with the following book:

    Claudio Puviani
    Claudio Puviani, Apr 9, 2004
    1. Advertisements

  3. Don't know what your exact requirements are but you could try LUA [1]

    Mike Higginbottom, Apr 9, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.