1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
Types
-----
.. crowbar:element:: Type <- ConstType / PointerType / ArrayType / FunctionType / BasicType
.. crowbar:element:: ConstType <- 'const' BasicType
.. crowbar:element:: PointerType <- BasicType '*'
.. crowbar:element:: ArrayType <- BasicType '[' Expression ']'
.. crowbar:element:: FunctionType <- BasicType 'function' '(' FunctionTypeArgs? ')'
FunctionTypeArgs <- BasicType (',' BasicType)* ','?
.. todo:: define like any of these
.. crowbar:element:: BasicType <- 'void' / 'bool' / 'float32' / 'float64' / 'int8' / 'int16' / 'int32' / 'int64' / 'intaddr' / 'intmax' / 'intsize' / 'uint8' / 'uint16' / 'uint32' / 'uint64' / 'uintaddr' / 'uintmax' / 'uintsize' / 'struct' identifier / 'enum' identifier / 'union' identifier / '(' Type ')'
``void`` denotes the empty type.
``bool`` denotes the Boolean type, with two values: ``true`` and ``false``, represented as 1 and 0, respectively.
``float32`` and ``float64`` denote the binary32 and binary64 `IEEE 754 floating-point <https://en.wikipedia.org/wiki/IEEE_754>`_ types, respectively.
``int8``, ``int16``, ``int32``, and ``int64`` denote signed, two's-complement integers with sizes 8 bits, 16 bits, 32 bits, and 64 bits, respectively.
``uint8``, ``uint16``, ``uint32``, and ``uint64`` denote unsigned integers with sizes 8 bits, 16 bits, 32 bits, and 64 bits, respectively.
``intmax`` is a synonym for the largest signed integer type supported by the compiler.
``uintmax`` is a synonym for the largest unsigned integer type supported by the compiler.
``uintaddr`` is a synonym for an unsigned integer type large enough to hold any memory address valid on the compilation target; the specific type is implementation defined.
``intaddr`` is a synonym for a signed integer type at least as large as ``uintaddr``.
``uintsize`` is a synonym for an unsigned integer type large enough to hold any number of bytes which may be contiguously allocated on the compilation target; the specific type is implementation defined.
``intsize`` is a synonym for a signed integer type at least as large as ``uintsize``.
``struct``, ``enum``, or ``union`` followed by an identifier denotes the type with the given nature and name, which should be available in the compilation context when used.
Enclosing a :crowbar:ref:`Type` in parentheses does not have semantic significance, but allows for syntactic disambiguation of constructs that would otherwise be visually ambiguous.
Multi-byte integer types should be represented as either big endian or little endian based on the preference of the compilation target platform, i.e. endianness is implementation defined.
Compilers targeting less-than-64-bit CPUs *may* omit support for some explicitly sized basic types, but *it would be nice* if they provided software support for types not supported in hardware.
|