Abstract

An object-oriented framework is proposed for constructing a virtual machine (VM) to be used in the context of incrementally and iteratively developing a domain-specific language (DSL). The framework is written in C#. It includes abstract instruction and environment classes. By extending these, a concrete layer of classes is obtained whose instances define the semantics of a set of instructions, as well as one or more execution environment instances that can be manipulated by the instructions. The framework provides a generic mechanism for reading a set of instructions, executing them sequentially by default but branching if necessary, storing or retrieving internal variables, and accessing and manipulating the environment as per the instructions. In general, each instruction can execute an arbitrary C# method as specified by the developer. The syntactic form of instructions is limited to five possibilities. Using the framework, a range of VMs can be generated, each tailored to support a developer-designed target-level DSL. Since each such language is built in terms of these five instruction formats, these target-level languages share a common syntactic structure. The result is a platform to support an incremental iterative language design and implementation approach that involves the following three phases: determine a set of target-level instructions with semantics appropriate to the specific domain; determine source-level language instructions whose syntax appeals to the domain specialist and provide a simple compiler to map the source to target instructions. The first two phases are relatively disjoint and importantly separate syntax concerns from semantics concerns. The final phase is quite straightforward. Comparative performance results support the use of the framework as an alternative to using an interpreter or hardcoded VM for DSL development.

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call