XDDL contains a simple exression evaluation engine for calculating lengths and sizes of fields, repeat counts, or nearly any place an integer value is required.
A common use of expressions is illustrated in this example:
<xddl>
<structure>
<field name="Record Size" length="8"/>
<record name="Data Record" length="{Record Size} * 8">
<repeat>
<field name="ByteCount" length="8"/>
<field name="Data" length="ByteCount * 8"/>
</repeat>
</record>
</structure>
</xddl>
expr.xddl
Here we see the length of the Data Record record is defined as {Record Size} * 8.
Curly braces must be used around Record Size because it has a space in
it. Otherwise, no curly braces are needed, as in the line with ByteCount * 8.
The other major operators: +, -, /, and ^ are also supported.
As is the question mark - colon operator.
The precedence rules are the same as the C/C++ languages, and parentheses can be used for grouping.