First steps in creating an internal DSL with Groovy
Sten Anderson has a great post about creating an internal DSL with Groovy: A Text Adventure DSL in Groovy.The "domain" of this example DSL is old-school adventure games like King's Quest.
The post shows the different steps how to transform the following Java-like code...
game.look(); game.go("north"); game.take("dagger"); game.take("sword"); game.take("key"); game.take("axe");
... into the following statements:
look go north take dagger grab sword hold key yoink axe
Both of the above snippets are valid Groovy code that can be executed on the JVM!
To understand and learn about the implementation of internal DSLs I implemented this DSL example.
The project can be browsed and downloaded on my github account. The project is fully mavenized, and should easily be buildable and runnable with Maven.