Using DSL Grammar

Using DSL grammar, you can combine different behaviours in intuitive ways to bring out a functionality while creating custom profiler rules.

The two dummy behaviours available in this framework are as follows:

  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 it 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 it other languages.

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

Let's expand our DSL to use or 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.