M. Bravenboer, R. de Groot, and E. Visser.
MetaBorg in Action: Examples of Domain-specific Language Embedding and Assimilation using Stratego/XT. In Proceedings of the
Summer School on Generative and Transformational Techniques in Software Engineering (GTTSE'05), Braga, Portugal, July 2005. (
pdf).
Abstract
General-purpose programming languages provide limited
facilities for expressing domain-specific concepts in a
natural manner. All domain concepts need to be captured using
the same generic syntactic and semantic constructs. Generative
programming methods and program transformation techniques can
be used to overcome this lack of abstraction in
general-purpose languages.
In this tutorial we describe the MetaBorg method for
embedding domain-specific languages, tailored syntactically
and semantically to the application domain at hand, in a
general-purpose language. MetaBorg is based on
Stratego/XT, a language and toolset for the implementation of
program transformation systems, which is used for the
definition of syntactic embeddings and assimilation of the
embedded constructs into the surrounding code.
We illustrate MetaBorg with three examples. JavaSwul is a
custom designed language for implementing graphical
user-interfaces, which provides high-level abstractions for
component composition and event-handling. JavaRegex is a
new embedding of regular expression matching and string
rewriting. JavaJava is an embedding of Java in Java for
generating Java code. For these cases we show how Java
programs in these domains become dramatically more readable,
and we give an impression of the implementation of the
language embeddings.
Links