Как использовать not () в правиле dslr? - PullRequest
2 голосов
/ 07 февраля 2020

Я хочу express правило, подобное

rule "R"
when
    a: A()
    c: C(a.timestamp<timestamp)

    not(B(a.timestamp<timestamp && timestamp<c.timestamp))
then
    // error no B between A and C
end

, но используя DSL

, как я могу express not?

rule "R"
when
    there is an A a
    there is a C c
      - with timestamp greater than a.timestamp

    there is NOT a B
      - with id between a.timestamp and b.timestamp
then
    // error no B between A and C
end
[condition][]there is an A {a}={a}: A()
[condition][]there is a C {c}={c}: C()
[condition][]there is NOT a B=not(B())
[condition][]- with timestamp greater than {timestamp}=timestamp > {timestamp}
[condition][]- with timestamp between {lower} and {upper}={lower}<timestamp && timestamp<{upper}

1 Ответ

1 голос
/ 27 февраля 2020

rdslr

rule "R"
when
    There is an A
    There is a C
      - with timestamp greater than $A.timestamp
    There is a B
      - not with timestamp between $A.timestamp and $C.timestamp
then
    // error no B between A and C
end

dsl

[when]There (is( an?)?|are) {entityType}s?( that)? = ${entityType}: {entityType}()
[when]with timestamp greater than {timestamp}=(timestamp > {timestamp})
[when]with timestamp between {lower} and {upper}=({lower} < timestamp && timestamp < {upper})

[when]{prefix}?\s*(?<![\w])not(?! (in|matches|contains|memberOf|soundslike|str))(\s+an?)?(?![\w])\s*\({suffix}? = {prefix} false == (true && {suffix}
[when]{prefix}?\s*(?<![\w])not(?! (in|matches|contains|memberOf|soundslike|str))(\s+an?)?(?![\w])\s*{suffix}? = {prefix} !{suffix}
[when](?<![^\(,])\s*- = 
...