您可以在 Drools 决策 table 中使用 DSL 吗?

Can you use DSL in a Drools decision table?

我可以在 Drools 决策中使用领域特定语言 (DSL) table(.xls 文件)吗?

我为我的决定 table 创建了一个 .dsl 文件,但每当我尝试在决定 table 中使用 "alias" 时,我都会收到 Drools 语法错误。

    # Simple DSL example file

[keyword]avoid looping=no-loop true
[when]There is a Customer=$c:Customer()
[when]- with age between {low:\d*} and {high:\d*}=age >= {low}, age <= {high}
[when]- who is older than {low:\d*}=age > {low}
[when]- without a Category set=category == Customer.Category.NA
[then]Set Customer Category to {category:\w*}=modify($c)\{setCategory(Customer.Category.{category})\};

例如,如果我在决定 table 中使用别名 "There is a Customer",我会得到:

Line 8:8 mismatched input 'is' in rule

这是不可能的。

决策 table 解析器对 header 中的预期内容做出了坚定的假设,其中带括号的模式是一种 "landmark",下列中的值将用于被插入。

没有将决定 table 编译的结果传递给 DSL 扩展器的标准程序,尽管您可以通过捕获前者的输出并将其用作 DSLR 文件来解决这个问题。

我看不到将 DSL 与决策相结合的好处 table。虽然两者的目的都是为了让 non-programmers 的规则创作更容易,但决定 tables 强调了简单规则(由程序员编写)可以通过不同的文字日期重复的想法,而提供了 DSL 方法作为语法糖,无需掌握 DRL 语法即可编写大量不同的规则。