XFA Specification
Chapter 23, FormCalc Specification
Grammar and Syntax
812
Simple Expressions
66 Expression ::= SimpleExpression | ...
67 SimpleExpression ::= LogicalOrExpression
The above grammar for a SimpleExpression
67
Operator Precedence
Operator precedence rules behave as expected. Enumerating all the
FormCalc
operators in order, from
high precedence to lowest precedence yields:
= (unary) - + not * / + - < <= > >= lt le gt ge == <> eq ne & and | or
For example:
Simple expression
10 * 3 + 5 * 4
0 and 1 or 2 > 1
Evaluates to …
50
1
Numeric operations on non-numeric operands
When performing numeric operations involving non-numeric operands, the non-numeric operands are
first promoted to numbers; if the non-numeric operand can be fully converted to a numeric value then
that is its value; otherwise its value is zero (0). When promoting null-valued operands to numbers, their
value is always zero.
Simple expression
(5 - "abc") * 3
"100" / 10
5 + null + 3
Evaluates to …
15
1
8
Explanation
"abc"
converts to 0
"100"
converts to 100
null
converts to 0
Boolean operations on non-Boolean operands
When performing boolean operations on non-boolean operands, the non-boolean operands are first
promoted to booleans; if the non-boolean operand can be fully converted to a nonzero value then its
value is true (1); otherwise its value is false (0). Null-valued operands are converted to false (0). For
example:
Simple expression
"abc" | 2
false | true = true
if ("abc") then 10 else 20 endif
Evaluates to … Explanation
true (1)
true (1)
20
"abc"
converts to false.
"abc"
converts to false, and 2 converts
to true.
String operations on non-string operands
When performing string operations on non-string operands, the non-string operands are first promoted to
strings by using their value as a string. When promoting null-valued operands to strings, their value is