It might seem ugly, but it has its uses.
Let's say for whatever reason you want direct access to the variables from outside the scope of the code and you create a sort of template that you parse.
override a with 5
override b with 10
set x = add a and b
$a = 0 // will get assigned at runtime
$b = 0 // will get assigned at runtime
$x = 0 // will get assigned at runtime
lexic = { /^override (.+) with (.+)/ -> override_func,
/^set (.+) = (\S+) (.+) and (.+)/ -> set_func }
dsl_data.read().eachLine { line -> lexic.find { key,value -> key.match(line) }(line) }
override_func (line){
line =~ /^override (.+) with (.+)/
$$1 = $2
}
set_func(line){
line =~ /^set (.+) = (\S+) (.+) and (.+)/
if($2 == "add"){ $$1 = $$3 + $$4 }
}
P.S.: This is a mix of groovy and perl, so don't worry about the syntax