Commit e726276a authored by Bernhard Rumpe's avatar Bernhard Rumpe
Browse files

BR

parent f428308f
<h1>Compositional Language Engineering using<br>Generated, Extensible, Static Type-Safe Visitors</h1>
<p>Robert Heim, Pedram Mir Seyed Nazari, Bernhard Rumpe, and Andreas Wortmann</p>
<!--<h2>Publications</h2>-->
<h2>Abstract</h2>
<p>
Language workbenches usually produce infrastructure to represent models
as abstract syntax trees (AST) and employ analysis, transformation,
and code generation techniques largely based on visitors. The visitor
pattern and its derivatives suffer from the expression problem when it
comes to extensibility and reuse. Current approaches either forsake
static type safety, require features unavailable in popular
object-oriented languages (e.g., open classes), or rely on procedural
abstraction and thereby give up the object-oriented data encapsulation
(the AST) itself. Our approach to visitors exploits knowledge about the
AST structure under development and generation of statically type-safe
external visitor interfaces that support extensibility in two
dimensions: defining new operations by implementing the interface and
extending the underlying data structure, usually without requiring
adaptation of existing implemented visitors. We present a concept of
visitor development for language engineering that enables an adaptable
traversal and provides hook points for implementing concrete visitors.
This approach is applicable to single DSL implementation and to
language composition. It thus enables a transparent, easy to use, and
static type-safe solution for the typical use cases of language
analysis and transformation.
</p>
<h2>Supporting materials</h2>
<p>The Maven project in <a href="visitors.zip">visitors.zip</a>
demonstrates usage of the visitor infrastructure of the language workbench
<a href="http://www.monticore.de">MontiCore</a>.
It consists of three (simplified) languages:</p>
<ul>
<li><b>Classdiagram</b><br>Grammar: visitors.zip/visitors/src/main/grammars/de/monticore/visitors/CD.mc4</li>
<li><b>Automaton</b><br>Grammar: visitors.zip/visitors/src/main/grammars/de/monticore/visitors/Automaton.mc4</li>
<li><b>Classdiagram with embedded automata</b><br>Grammar: visitors.zip/tree/master/visitors/src/main/grammars/de/monticore/visitors/&shy;CDWithAutomaton.mc4</li>
</ul>
<h3>Requirements</h3>
<ul>
<li>Java 8 SDK</li>
<li>Maven 3+</li>
</ul>
<h3>Build</h3>
<p>Extract the visitor.zip. To build the project run <code>mvn clean install</code> from the visitor folder that contains the <code>pom.xml</code>. MontiCore generates files to folder <code>visitors/target/generated-sources/monticore/sourcecode</code>. Put this folder on the class path after building the project.</p>
<h3>Examples</h3>
<p>All languages define pretty printers:</p>
<ul>
<li><b>CDPrettyPrinter</b><br>visitors.zip/visitors/src/main/java/de/monticore/visitors/cd/CDPrettyPrinter.java</li>
<li><b>AutomatonPrettyPrinter</b><br>visitors.zip/visitors/src/main/java/de/monticore/visitors/automaton/AutomatonPrettyPrinter.java</li>
<li><b>CDWithAutomatonPrettyPrinter</b><br>visitors.zip/visitors/src/main/java/de/monticore/visitors/cdwithautomaton/&shy;CDWithAutomatonPrettyPrinter.java</li>
</ul>
<p>The pretty printer for classdiagrams with automata is composed of the other ones.
The CDWithAutomatonTest [1] demonstrates its usage and usage of a method counter [2].<br>
<br>
[1] visitors.zip/visitors/src/test/java/de/monticore/visitors/CDWithAutomatonTest.java<br>
[2] visitors.zip/visitors/src/main/java/de/monticore/visitors/cdwithautomaton/MethodCounter.java
</p>
<?php
$ROOT_PATH = "../../";
$TITLE = "SE@RWTH : Compositional Language Engineering using Generated, Extensible, Static Type-Safe Visitors";
include ($ROOT_PATH."layout/lib.php");
include ($ROOT_PATH."layout/header.php");
include ("content.php");
include ($ROOT_PATH."layout/footer.php");
?>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment