Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The Grammar Node is the outer containing node for the grammar. It allows you to set default attribute values that are inherited by child Attribute Nodes, unless overridden by those child nodes. The Grammar Node may have any of the following attributes:

Attribute name

Description

Possible Values

Mandatory

Default

byteOrder

The order of bytes.

L (for little endian) or B (for big endian).

No

B

nibbleOrder

The order of individual nibbles (4 bits) within each byte.

L (for little endian) or B (for big endian).

No

B

stringType

The character set used to encode strings in the file.

A string representing the name of the character set.

No

None

complete

Whether this is a complete grammar. If the flag is set to T for true, if there are any bytes left over in the file once the grammar has completed (i.e. there are no further grammar nodes to process) then an error will be raised.

T for true or F for false.

No

T

...

The child nodes of a Repeat Node may repeat 0, 1, or more times. In addition to common attributes (see 3.1) Repeat Nodes may have the following attributes:

Attribute name

Description

Possible Values

Mandatory

Default

times

The number of times that the child nodes will repeat

Any of:

  • A number
  • A variable name, the variable holding the number of repeats – this variable must have been declared in the variables attribute of this or an ancestor node
  • An Expression inside curly braces which will calculate a whole number. The Expression may refer to Attribute Nodes which have been declared in the scriptVariables attribute of this or an ancestor node
    If this property is not set then the first attribute following the repeat node must contain a discriminator attribute. The repeat loop will stop once that discriminator value is encountered.

No

No limit

...

Sequence Nodes simply define a collection of child nodes. These can be used to define a set of child nodes as a template; or to define the start and end of a sequence of Attribute Nodes that have an overall length specified by another Attribute Node (for example, a Length Node - see 3.4.4) somewhere within the same node hierarchy.
In addition to common attributes (see 3.1) Sequence Nodes may have the following attributes:

Attribute name

Description

Possible Values

Mandatory

Default

length

The overall expected number of bytes for all Attribute Nodes that are descendants of this node. This is helpful if a group of fields in the file includes optional fields – setting the length helps the grammar to determine where this group of fields has ended, and the next field or group of fields begins.
See the example below.

Any of:

  • A number.
  • A variable name, the variable holding the overall number of bytes of Attribute Nodes – this variable must have been declared in the variables attribute of this or an ancestor node.
  • An Expression inside curly braces which will calculate a whole number. The Expression may refer to Attribute Nodes which have been declared in the scriptVariables attribute of this or an ancestor node.

No

None

...