In the original Perl version of the integration (Version 1.0), the Perl β€œeval” function was used to evaluate a generalized expression used in the xx_POLL_TRIGGER property. Since Perl is no longer used or required, a substitute expression evaluation method is provided. We describe the expression evaluation syntax and semantics here.

An expression consists of one or more terms separated by infix operators:

<expression> = []*

A term is a literal or a a replaceable variable or a term preceded by a prefix operator or a parenthesized expression. A term may also be an expression surrounded by parentheses:

<term> = <literal> | <replaceable variable>  | ( <expression> ) | <prefix op>*<term>

A literal is a string literal or a number literal:

<literal> = β€œ<inside quote string>” | <inside quote string> | <floating point number>

where <inside quote string> follows the usual rules for quoted strings. Infix operators include both Boolean and arithmetic operators:

<infix op> = + | - | β€œ*” | / | β€œ&&” |  β€œ||” | . | eq | ne | gt | ge | lt | le | β€œ==”

Only one prefix operator, the boolean NOT, is currently supported:

<prefix op> = !

Rules of Evaluation

Evaluation proceeds left to right, in order of infix precedence, with parenthesized expressions evaluated before the containing term is evaluated. When mixing arithmetic and Boolean values, Boolean expressions are converted to 1.0 for true and 0.0 for false. Any non-zero arithmetic value is equivalent to true in a Boolean expression. All arithmetic computation uses floating point. The infix precedence is assigned to make the higher-valued operations more tightly binding. The values are as follows:

  • 7 – for the prefix β€œnot” operator (!)
  • 6 – for multiplication and division (* and /)
  • 5 – for the string concatenation operation (.)
  • 3 – for plus, minus and the relational operators (+, -, eq, ne, gt, ge, lt, le, ==)
  • 1 – for the Boolean operators (||, &&)

Hence, an expression like:

a + b ge (c+e)*2 || !d == e

would be evaluated in the following order:

	!d
	(c+e)
	*2
	a + b
	ge
	== e
	||

Expression Examples

(__priority__ le 1) || ( __status__ eq β€œfixed”) 5/9 * ( __temperature__ - 32) gt 0