MLML

Project Details

The Meta Language Markup Language, MLML, is an abstract source code representation in XML. MLML, pronounced mummel, is an open-source project, published under the GNU General Public Licence.

The notation will form the basis of the next generation of o:XML tools, including an new compiler/interpreter. One of the aims is to provide improved language integration, initially with Java, but in the future with other languages too. Another goal is to provide a neutral platform for cross-language development and deployment.

Phase I

enables o:XML programs to either run interpreted or be transformed to Java. Includes an MLML compiler/interpreter and Java compatibility libraries that implement o:XML core types.

Phase II

allows closer integration of o:XML and Java, as well as Java and MLML. Includes transformation of Java source code to MLML, and transformations to o:XML.

Phase III

extends the deployment options for o:XML, as well as other MLML code, which can be transformed to C. With the compatibility libraries implementing o:XML core types in C, o:XML programs can be compiled and linked using standard C tools. The C parser (producing MLML code) will allow code written in C to be imported to MLML platforms.

The first phase of the project will produce:

  • the MLML language schema
  • a parser that generates MLML from o:XML
  • an MLML compiler and interpreter (ObjectBox2)
  • o:XML compatibility libraries for Java
  • an MLML to Java code transformation

Limitations

MLML will not magically allow for example any C code to be transformed into Java, or vice versa. For code to still work (ie be semantically identical) across language transformations, these conditions must be satisfied:

  • semantically correct transformations between specific language operators and primitives
  • compatibility libraries implementing 'missing' or incompatible language features
  • reliable transformations to/from MLML

Requirements

The MLML vocabulary should be capable of expressing:

  • function and operator definitions
  • statically and dynamically typed function and operator calls
  • constants, variables and references
  • types and type hierarchies
  • exceptions and handlers
  • procedural and object-oriented language constructs
  • functional language constructs
  • parameterised types

If two code fragments look the same, they must be semantically identical, regardless of what source language they were created from.

The language should not require any parsing beyond the XML stage. There should be no composite string expressions apart from normal QNames. The syntax should be extensible using the XML namespace mechanism.

MLML as a source code representation must aim to preserve semantics, not necessarily syntax. It should facilitate translations between language paradigms, for example from object-oriented to strictly procedural, and provide an experimental platform for semantic equivalence problems.

Syntax Overview

Type references are represented with elements rather than attributes to allow for parameterised types. Examples of parameterised types may be 'array of integers', 'pointer to char', 'function that returns short' etc.

Example 1: Java method call

Example of a statically typed function call.


TheClass theInstance = new TheClass();
theInstance.theMethod(123);

<call name="theMethod">
  <target>
    <type ref="TheClass"/>
    <reference name="theInstance"/>
  </target>
  <param>
    <type ref="java:int"/>
    <constant>
      <type ref="java:int"/>
      <value>123</value>
    </constant>
  </param>
</call>

Example 2: o:XML type function call

Example of a dynamically typed function call.


<o:set theInstance="TheType()"/>
<o:do select="$theInstance.theFunction(123)"/>

<call name="theFunction">
  <target>
    <reference name="theInstance"/>
  </target>
  <param>
    <constant>
      <type ref="o:Number"/>
      <value>123</value>
    </constant>
  </param>
</call>

Example 3: Java static method call


TheClass.theMethod();

<call name="theMethod">
  <type ref="TheClass"/>
</call>

Example 4: Java class field reference


TheClass theInstance = new TheClass();
theInstance.theField;

<reference name="theField">
  <reference name="theInstance"/>
</reference>

Example 5: Java static class field reference


TheClass.theField;

<reference name="theField">
  <type ref="TheClass"/>
</reference>

Project Status

This page should be seen as a mission statement and a project outline, rather than as describing a finished product. Work has begun, but nothing is quite ready to be published yet. In the meantime, please join the discussion on the mailing list.