SLE WS 2012/13 Assignment 3


Implement a DSL through embedding


Implement a DSL by embedding. Options for DSLs are listed. Options for technologies are listed as well. Other options may be Ok, subject to confirmation. It is important that, indeed, embedding is chosen as implementation style. That is, the DSL must be implemented by essentially extending syntax and semantics of a host language.

Please make a proposal within the first week of the assignment by sending an email to softlang@uni-koblenz. Your proposal is either confirmed (if it is clear and original), or rejected (if it is not suitable or you had about the same idea as in some previously received proposal), or conditionally accepted (subject to processing some feedback and resubmitting the proposal for confirmation).

DSL options

Graph representation

We seek a DSL for graph representation which is embedded into the host language in a way that the graphs are available as data structures of the host language. The DSL thus makes it easy to describe graphs, but it is reasonable to assume that any host language can easily represent graphs. Consider the following illustration of the intended domain-specific notation:

// DSL
graph f42 {
  a -> b
  b -> c
  b -> d

Reverse polish notation

Based on the arithmetic expression syntax of the host language, which presumably relies on prefix and infix operators, implement a DSL for arithmetic expressions that instead supports postfix operators in the sense of reverse polish notation (RPN). Consider the following Java expression and its DSL counterpart:

// DSL
1 x +
// Java
1+ x

Implicit constructors

Based on the constructor invocation syntax of the OO host language, implement a DSL for object construction that is more concise because the "new" keyword can be omitted. Consider the following Java expression and its DSL counterpart:

// DSL
  Employee("Bar", 88)
// Java
new Department(
  new Employee("Foo",42), 
  new Employee("Bar", 88)

(This option does not make much sense for a non-OO language like Haskell.)

Technology options

  • SugarJ (Modest Java background is assumed.)
  • Converge (Modest Python background is assumed.)
  • SugarHaskell (Modest Haskell background is assumed.)
  • Haskell quasiquoting (More than modest Haskell background is assumed.)
  • Helvetia (More than modest Smalltalk background is assumed.)

General logistics

See the course page for deadlines and conditions on successfully completing the assignments.