【发布时间】:2020-07-29 15:54:36
【问题描述】:
我是 Xtext 的新手,我想用它来为 drools 规则生成一些代码。我有以下问题,我不知道如何编写方言以在 Order() 前面加上 $order。如果有人能告诉我如何处理这个例子,我将不胜感激。
这是我迄今为止尝试过的
Model:
declarations+=Declaration*;
Declaration:
Rule;
State:
name=ID
;
Rule:
'rule' ruleDescription=STRING
'@specification'specificationDescription=STRING
'ruleflow-group' ruleflowDescription=STRING
'when' when=[State|QualifiedName]
'then' then=[State|QualifiedName];
QualifiedName: ID ('.' ID)*;
DolarSign: ('$' ID)*;
这里是规则的代码:
rule "apply 10% discount to all items over US$ 100,00 in an order"
@specification "101"
ruleflow-group "All"
when
$order : Order(appliedBefore == null)
Order($name : /customer/name) from $order
$item : OrderItem( value > 100 ) from $order.items
then
System.out.println("10% applied" + $name);
end
【问题讨论】: