MPS 2024.1 Help

Base Language

The BaseLanguage is an MPS' counterpart to Java, since it shares with Java almost the same set of constructs. BaseLanguage is the most common target of code generation in MPS and the most extensively extended language at the same time.

In order to simplify integration with Java, it is possible to specify the classpath for all modules in MPS. Classes found on the classpath will then be automatically imported into @java_stub models and so can be used directly in programs that use the BaseLanguage.

The frequently extended concepts of MPS include:

  • Expression. Constructs, which are evaluated to some results like 1, "abc", etc.

  • Statement. Constructs, which can be contained on a method level like if/while/synchronized statement.

  • Type. Types of variables, like int, double.

  • IOperation. Constructs, which can be placed after a dot like in node.parent. The parent element is a IOperation here.

  • AbstractCreator. Constructs, which can be used to instantiate various elements.

Although, BaseLanguage was originally created using the Java 6 specification, it now includes features like try with resources, catch multiple exceptions, local variable type inference, default and private interface methods or the diamond operator from later Java versions. No additional language import is required to use these features since they are part of BaseLanguage itself. To provide compatibility with build processes requiring certain java language level, each solution can be configured in the Java tab of the module properties dialog to prohibit language feature not compatible with required language level.

Java_compatibility.png
Last modified: 11 February 2024