Using DSL grammar

Using Domain-specific Language (DSL) grammar, you can combine different regex expressions in intuitive ways to bring out new functionality while creating custom profiler rules.

The two behaviors available in this framework are the following:

  1. falseIdentity - Always evaluates to false, regardless of the input.
  2. trueIdentity - Always evaluates to true, regardless of the input.

These two behaviors are used in the following examples and descriptions.

Binary AND operator

Keyword: AND

AND works the same way it does other languages. Hence following observations.

falseIdentity and trueIdentity == falseIdentity
falseIdentity and falseIdentity == falseIdentity
trueIdentity and trueIdentity == trueIdentity
trueIdentity and falseIdentity == falseIdentity

Here we are using == to show their equality.

Binary OR operator

The OR operator works the same way it does in other languages.

falseIdentity or trueIdentity == trueIdentity
falseIdentity or falseIdentity == falseIdentity
trueIdentity or trueIdentity == trueIdentity
trueIdentity or falseIdentity == trueIdentity

Expand DSL to use as follows.

val rule1= falseIdentity and trueIdentity and trueIdentity
val rule2= trueIdentity and trueIdentity and trueIdentity
val rule3=rule1 and rule2
rule3 or trueIdentity

The above expression evaluates to true.

Unary NOT operator

The NOT operator negates the value of a regex expression ( from TRUE to FALSE and vice versa).

not(falseIdentity) == trueIdentity
not(trueIdentity) == falseIdentity

Use the not operator as follows.

val rule1= falseIdentity and trueIdentity and trueIdentity
val rule2= trueIdentity and trueIdentity and trueIdentity
val rule3=rule1 and rule2
val rule4=rule3 or trueIdentity
rule4 and not(falseIdentity)

The above expression evaluates to true.