Wiki

Clone wiki

data2l / help-formatlanguage

Data Format Definition

Data definition types

Void

Void An empty structure, useful for defining Alternatives

Basic types

Basic types Basic element represents basic types like Byte, String, DWord ...

Current version supports char, byte, word, dword, float, varinteger, string, and arrays of char, word, dword, float.

Number of basic types will be growing with every version. If you need to support any specific unordinary type pls contact Eccam for customization..

Array

Array Define simple or complicated arrays member of array can be any basic type

Alternative

Alternative Use when type selection is dependent on data in the structure. We could call is also a "switch". Imagine following structure.

struct AlternativeExample:
  DWORD numberOfRecords
  array TableOfVariableRecords:
        size: numberOfRecords
        struct VariableSizedRec: 
            byte recFlags
            alternative  alt:
                selector: 
                        if ((recflags & 3) >0) then 0 else 1 
                struct option_0_struct:
                    byte strLen
                    string  name:
                        size: strLen

                struct option_1_struct:
                    byte sizeOfPolygon
                    array Polygon
                        size: sizeOfPolygon
                        struct Vertice 
                          word X
                          word Y

Dependencies definition

Expression based dependencies are defined in a simple "functional" language - no side effects. no variables.

  • common operators - /, *, +,-, !=, ==, &&, ||, \<\<, >>

  • if-then-else if-then-else - example: if (1==1) then 0 else 1

  • [] indexed access [] - example: array[1].element - if element is marked as in_memory

  • actindexof actindexof(array) - actual index of a specific array

  • arraysizeof arraysizeof(array) - returns a number of elements of an array

  • offsetof offsetof(element) - offset in the file where the element was read from

  • sizeof sizeof(element) - static size of the element, can be determined on compile time

  • binsizeof binsizeof(element) - size of element checked with a specific file. Array for example will have a different.

  • stopparse stopparse() - stops parsing in first array above an element which was parsed. It's intended as a generic support for sentinel defined structures. Currently works only in Alternative type.

  • strindex strindex(string_element, "string const") - returns index where "string const" is first found. "string const" can contain variable special chars "\0", "\n" etc.

Example of dependency between elements

    offsetof(Header) + Header.Table1Size

Example calculates offset of Table2 which is located just after the Header and Table1. Attributes ==========

attribute In Data2l context we call attributes those basic elements which are not stored inside the structured file.

They are ment as kind of helper variables which make a structure easier to interpret.

Example - we want to calculate offset of variable sized records as a sum of their sizes.

struct DescriptionWithAtribute:
    word size
    array RecTable:
        inmemory struct Addressing:
            word recSize
            attribute dword cumulativeRecSize: 
                 init: if actindexof(RecTable) == 0 then 0
                       else RecTable[actindexof(RecTable) -1].CumulativeRecSize + RecTable[actindexof(RecTable) -1].recSize

        struct VarRec:
            offset: offsetof(RecTable) + arraysizeof(RecTable)*2 + Addressing.cumulativeRecSize
            string some_string:
                size: Addressing.recSize

Updated