I think I have a better idea of what you're trying to do now. Below is the content of a message I sent to this list the other day. I think you might find the technique relevant to what you are doing. i.e. Create a DSL which refers to an enumeration which you define. That way, you get drop-down menus in the DSL sentences. That makes life easy for your users. From there you are able to take the value from the enum and use it in the generated code. Note that in the code below, it is taking the value of "unit" from the enumeration and using that as the field being matched in the code.

The rest is from my previous email...


I just couldn't find any examples of the DRL syntax for 'creating' a value like that in the LHS. A quick test with a contrived little example shows me that the following works:

rule "Warn when my meal is too large"
when
    $meal: Meal($calories: calories > 1000)
    $unit: String() from "calories"
then
    insert(new MealTooBigWarning("That meal is bigger than your 1000 " + $unit + " limit."));
end

So, based on that I'm able to write a DSL like this:

[when][]I am given a meal of more than "{sizeLimit}" "{unit}" = $meal: Meal($size: {unit} > {sizeLimit}); $sizeLimit: Integer() from {sizeLimit}; $unit: String() from "{unit}"
[then][]Warn that the meal is too big = insertLogical(new MealTooBigWarning("That meal is bigger than your " + $sizeLimit + " " + $unit + " meal limit."));

Which means that I can write DSLR like this:

rule "Warn when my meal has too many calories"
when
    I am given a meal of more than "1000" "calories"
then
    Warn that the meal is too big
end

which gives me:

That meal is bigger than your 1000 calories meal limit.

Or this:

rule "Warn when my meal has too many diet club points"
when
    I am given a meal of more than "11" "dietClubPoints"
then
    Warn that the meal is too big
end

which gives me:

That meal is bigger than your 11 dietClubPoints meal limit.

So I can define an enumeration:

'MealSize.units': ['calories=calories', 'dietClubPoints=diet club points']

So that in Guvnor, I have a single sentence with a drop-down menu containing the options "calories" and "diet club points". That keeps things nice and clean for the users.