如何在 dslr 规则中使用 not()?
How to use not() in a dslr rule?
我想表达这样的规则
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
如何表达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}
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*- =
我想表达这样的规则
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
如何表达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}
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*- =