liveBook · Manning

Meta-DSL

As explained in Building User-Friendly DSLs

A meta-DSL is a domain-specific language for specifying aspects of another domain-specific language or its tooling.

A meta-DSL is a DSL used to specify another DSL, or particular aspects of one. Its domain is software-language specification: for example, a metamodel DSL can define the structure of DSL content. section 15.3

An explicit metamodel needs notation, which makes a meta-DSL useful when DSL structure should be specified strictly. That strictness can complicate a deliberately lenient AST, so it is not automatically worthwhile for a small, evolving DSL. section 15.3

Language workbenches commonly provide several specialized meta-DSLs rather than one general notation. Together they can specify structure, constraints, editors, type systems, behavior, and code generation for a DSL. section 15.4.1 section 15.4.2

Table 15.1 Aspects of a DSL implementation in MPS, with description and mapping to a key aspect from chapter 1 (where that exists)
MPS aspect name
Key aspect (ch. 1)
Role
structure
Structure
As in chapter 1.
editor
Notation
As in chapter 1.
constraints
n/a
Specifies to which reference properties scoping should be applied. (The MPS name is a bit misleading.)
behavior
n/a
Defines functions on concepts (among others implementing scoping) and “almost-ordinary” Java classes. MPS provides BaseLanguage, a variant of Java, to implement behavior and code logic within other meta-DSLs.
typesystem
(Part of constraints)
Defines a type system and implements all constraints. (Again, the MPS name is a bit misleading.)
intentions
n/a
Defines editor actions.
generator/BusinessDsl/ main
Meaning
Defines a main code generator for the BusinessDsl.

MPS separates a DSL implementation into aspects. The table maps its structure, editor, constraints, behavior, typesystem, intentions, and generator aspects to their roles. section 15.4.2

Defining a car-rental DSL in MPS

An MPS implementation places DSL content in a CarRentalCompany module and implementation aspects in a BusinessDsl module. Its structure aspect explicitly defines concepts such as Record Type, Attribute, and Type; editor definitions specify their notation. section 15.4.2

How Building User-Friendly DSLs covers it

How deep it goes
Defines meta-DSLs and explains their metamodel relationship, then demonstrates selected MPS implementation aspects without completing the DSL.
Examples
Uses UML class-diagram notation for a record-type metamodel and MPS definitions for Record Type, Attribute, and Rental.
What it assumes
Assumes no particular workbench, while identifying working knowledge of DSL implementation as preparation for using one.
What you can do after
Evaluate/understand when specialized meta-DSLs and explicit metamodels help implement a DSL, including their trade-offs.
How it connects
Connects meta-DSLs to metamodels, meta-metamodels, meta-circularity, language workbenches, ASTs, and code generation.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building User-Friendly DSLs. The section links point to the parts of the book it draws on.