Go to the previous, next section.

The Syntax of Type Strings

The C-like type string is built using a set of base types.

Base Types

The allowed base types are void, char, short, int, int16, int32, int64, long, unsigned, unsigned16, unsigned32, unsigned64, float, float64 and double.

The type modifers const and volatile can be applied to any of the types.

      type_node * tn = block::parse_type("const int");




Composite types can be created for pointers, arrays, functions, structures and unions.

Pointer Types

A pointer type is given by a `*' following the base type.
      type_node * tn = block::parse_type("const char  *");



Array Types

An array type is given by specifying the dimensions with their sizes delimited by square-brackets to the right of the base type. For example a two dimension array (100x100) of character strings is defined by:
      type_node * tn = block::parse_type("char  * [100][100]");



Function Types

A function type is given by a base type followed by a list of argument types within parentheses. For example, a function type with three arguments (constant character string, integer, integer) that returns an integer is defined by:
      type_node * tn = block::parse_type("int (const char *, int, int)");



Structure and Union Types

For structure and union types, both the type of the field and the name of the field have to be specified. The name field can be any alpha-numeric string. For example a structure with two doubles is:
      type_node * tn = block::parse_type(" struct { double real;
                                                    double imag }");




Using Existing Type Structures

Existing types can be manipulated by either giving an existing type node as an argument to the parse_type call or by providing the type id in the string. For example,
        type_node * t1;
        type_node * t2;
        type_node * r;
        r = block::parse_type("%% * (%34, %%)", t1, t2);



The type node r will be of a function type of a function that returns a value of the type given by the type node t1. This function type has two arguments; the type with id number 34 is the first argument and the type given by type node t2 is the second argument.

Most of the combinations of the base types that are valid in C can be used within the builder type system. See section Defining Variables and Generating New Type Definitions for exact definitions for the parse_type() function.

Go to the previous, next section.