【问题标题】:Can you use DSL in a Drools decision table?你可以在 Drools 决策表中使用 DSL 吗?
【发布时间】:2017-05-16 18:56:14
【问题描述】:

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

我为我的决策表创建了一个 .dsl 文件,但每当我尝试在决策表中使用“别名”时,都会出现 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})\};

例如,如果我在决策表中使用别名“有一个客户”,我会得到:

Line 8:8 mismatched input 'is' in rule

【问题讨论】:

    标签: drools


    【解决方案1】:

    这是不可能的。

    决策表解析器对标题中的预期内容做出了明确的假设,其中带括号的模式是一种“地标”,下面列中的值将被插入其中。

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

    我看不出将 DSL 与决策表相结合的好处。尽管两者的目的都是为了让非程序员更容易编写规则,但决策表强调了简单规则(由程序员编写)可以通过不同的文字日期重复的想法,而 DSL 方法是作为语法糖提供的,用于编写无需掌握 DRL 语法即可使用多种不同的规则。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-05
      • 2023-03-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多