PrevTopNext

Example: DSL Translator

DSL definitions:
# simple phrases
[when]there is a car=$car: Car()
[then]print success=System.out.println("Success!");
# constraint
[when]- with colour green=colour == "green"

# Reuse through captures
[when]there is an? {thing}=${thing}: {thing}()
[when]- with colour {colour}=colour == "{colour}"
A DSLR rule: Expansion into a DRL rule:
rule "red bike"
when
    there is a bike
    - with colour red
then
    print success
end
rule "red bike"
when
    $bike: bike(colour == "red")

then
    System.out.println("Success!");
end

PrevTopNext