# Using Expressions in Extractor Scripts

A number of instruction entries in the script text can include an <expression>. An integer expression is an expression containing integer variables, integer literal, the unary operator -, and the binary arithmetic operators +, -, * and / (addition, subtraction, multiplication and division). The usual rules regarding precedence and associatively apply, for example, multiple operators have higher precedence than additive operators do and all operators are left associative. Parentheses, such as ( ) are used in the usual manner to specify precedence explicitly. Division is integer only, for example, the expression 3/2 has the value 1.

Example:

Assuming the variable A has the value 7, the following expressions all evaluate to 11:

2*A+2-4-1 2*A-3 (2*A)-3 2*(A-2)+1

An integer expression is described by the following BNF grammar:

expression ::= expression '+' term | expression '-' term | term

term ::= term '*' factor | term '/' factor | factor

factor ::= intvariable | intconstant | '-' factor | '(' expression ')'

intvariable a variable name as described for VAR

intconstant an integer literal between 0 and 2147483647, i.e. 2**31 - 1.