A metamodel is a model that precisely specifies the permitted structure and contents of other models. For a DSL, it defines which concepts an AST can contain and which typed properties may accompany each concept. section 15.3
A useful shorthand is “metamodel = structure = concepts + properties + types.” Extracting one from structured data is metamodeling, which resembles data modeling. An explicit metamodel helps constrain DSL content, but should not prevent the language from evolving. section 15.3 section 15.5
Implementation choices affect how precisely the metamodel can be expressed:
- JavaScript cannot make the implementation’s metamodel fully type-safe; TypeScript can partially define concept and property types, but constraints still require additional handling. section 15.3
- Ecore provides a facility for describing metamodels within the Eclipse Modeling Framework, whose Core EMF supports in-memory model persistence and XML/XMI serialization. section 15.4.3
Figure 15.3 A version of figure 1.20 visualizing the notion of a metamodel describing the model, which is the DSL content
Visualizes the metamodel as a model describing DSL content. section 15.3
Figure 15.4 A metamodel for DSL content representing a record type, borrowing the class diagram notation from UML
Shows a record-type DSL metamodel using UML class-diagram notation. section 15.3
