E. Visser. Meta-programming with concrete object syntax. In D. Batory, C. Consel, and W. Taha, editors, Generative Programming and Component Engineering (GPCE'02), volume 2487 of Lecture Notes in Computer Science, pages 299-315, Pittsburgh, PA, USA, October 2002. Springer-Verlag. Meta programs manipulate structured representations (abstract syntax) of programs. The distance between the concrete syntax meta-programmers use to reason about programs and the notation for abstract syntax manipulation provided by general purpose (meta-) programming languages is too great for many applications. In this paper it is shown how the syntax definition formalism SDF can be employed to fit a meta-programming language with concrete syntax notation for composing and analyzing object programs. As a case study, the addition of concrete syntax to the program transformation language Stratego is presented. The approach is then generalized to arbitrary meta-languages.
Stratego/XT is a language and toolset for constructing stand-alone program transformation systems. It combines the Stratego transformation language with the XT toolset of transformation components, providing a framework for constructing stand-alone program transformation systems. The Stratego language is based around a programming paradigm called strategic term rewriting. It provides rewrite rules for expressing basic transformation steps. The application of these rules can be controlled using strategies, a form of subroutines. The XT toolset provides reusable transformation components and declarative languages for deriving new components. Program transformations often operate by modifying the (AST). In Stratego it is also possible to specify transformations using concrete syntax. This allows programmers to express a transformation using the familiar (and often more concise) syntax of the object programming language, while it internally still operates on the AST.
Java-front is a package you can use to generate or transform Java code. It contains a handcrafted SDF grammar for Java, Stratego signatures generated from this grammar and a handcrafted pretty printer. * Modular and extensible syntax definition for Java * Full support for the new language features introduced in Java 5.0 * Heavily tested pretty-printer, which inserts parentheses where necessary! * Option to preserve comments * Conversion of abstract syntax tree to XML possible Available Versions of Java Java-front supports Java 5.0. The syntax definition closely follows the structure of the Java Language Specifcation, Third Edition (JLS3). All new features (generics, wildcards, varargs, static import, enums, foreach loop, annotations) are supported. The Java grammar in Java-front is able to parse and pretty-print all the Java sources in the GNU Classpath and the Java 2 SDK version 1.5.0 of Sun Microsystems. The results of the pretty-printer are verified.
Implementing web applications in an object-oriented language such as Java using state-of-the-art frameworks produces robust software, but involves a lot of boilerplate code. (DSLs) replace boilerplate code by high-level models, from which code can be generated. This tutorial shows how to find domain-specific abstractions based on patterns in existing (reference) programs and build domain-specific languages to capture these abstraction using several DSLs for DSL engineering: SDF for syntax definition and Stratego/XT for code generation. The approach is illustrated using the design and implementation of WebDSL, a domain-specific language for web applications, which provides abstractions for data models, page definitions, access control, workflow, and styling. * WebDSL: A Case Study in Domain-Specific Language Engineering * Code Generation by Model Transformation * Domain-Specific Language Engineering. A Case Study in Agile DSL Development