Home > Textual Syntax Specification
Introduction
In contrast to other tools on the market, concrete syntax specifications are built upon already designed metamodels (= abstract syntax). Moreover it is possible to define many concrete syntaxes for one and the same metamodel.
A metamodel, i.e. the structure of information, is the most important artefact in model-driven engineering projects as it is finally consumed by transformators. Thus it heavily influences model-to-model or model-to-text templates and should be designed with care (without covering the aspects of concrete syntaxes). On top of a well-designed metamodel, concrete syntax definitions are essential so that the framework can provide comfortable editors right away and you can model immediately without programming time-consuming implementations of model editors.
The purpose of this chapter is to explain how you can declaratively specify concrete textual syntaxes for well-designed metamodels. The actual text editor with features like syntax highlighting, folding, etc will be automatically provided by OOMEGA.
General Structure of Textual Syntax Specifications
First of all we’d like to present the general structure of textual syntax specifications.
- A textual syntax has a name. That name will be finally used to name the respective Eclipse editor tab.
- A textual syntax contains a set of textual syntax definitions. Each textual syntax definition describes the portion of the textual syntax that is related to a specific class of your metamodel.
- These class-related textual syntax definitions contain vectors of template elements; those are instances of the following classes:
- Include Super is a template element that leads to inclusion of the super class' textual syntax definition.
- Option is similar to the Java abbreviatory if-then-else notation: (condition ? then case : else case). Dependent on the object state a different syntax might apply.
- Non Terminals are meant to include the textual representation of linked objects. Non terminals possibly come along with a starting, prefix, suffix, infix and/or ending.
- Terminals are further distinguished: "Proper Terminals" are strings that do not contain any whitespace characters, i.e. new lines, spaces, tabs or backspaces. "Whitespace Terminals" are spaces and/or new lines.
Next chapter: M2L Text Editor