The rec format supports the declaration of fields of the following escalar types: integer numbers, ranges and reals.
Signed integers are supported by using the integer
declaration:
%typedef: Id_t int
Given that declaration, Fields of type Id_t
must contain
integers, that may be negative. Hexadecimal values can be written
using the 0x
prefix, and octal values use an extra
0
. Valid examples are:
%type: Id Id_t Id: 100 Id: -23 Id: -0xFF Id: 020
Sometimes it is desirable to reduce the range of integers allowed in a field. That can be achieved by using a range type declaration:
%typedef: Percentage_t range 0 100
Note that it is possible to omit the minimum index in ranges. In that case it is implicitly zero:
%typedef: Percentage_t range 100
Hexadecimal and octal numbers can be used to specify the limits in a range. This helps to define scalar types whose natural base is not ten, like for example:
%typedef: Address_t range 0x0000 0xFFFF %typedef: Perms_t range 755
Real fields can be declared with the real
type specifier.
A wide range of real numbers can be represented this way, only limited
by the underlying floating point representation. For example:
%typedef: Longitude_t real
Examples of fields of type real:
%rec: Rectangle %typedef: Longitude_t real %type: Width Longitude_t %type: Height Longitude_t Width: 25.01 Height: 10