range
range
range ::= range_attribute
| simple_expression .. simple_expression
(enumeration_literal_specification
{, enumeration_literal_specification})
enumeration_literal_specification ::= enumeration_literal
type
DAY is
(MON, TUE, WED, THU, FRI, SAT, SUN);
type
SUIT is
(CLUBS, DIAMONDS, HEARTS, SPADES);
type
GENDER is
(M, F);
type
LEVEL is
(LOW, MEDIUM, URGENT);
type
COLOR is
(WHITE, RED, YELLOW, GREEN, BLUE, BROWN, BLACK);
type
LIGHT is
(RED, AMBER, GREEN); -- RED and GREEN are
-- overloaded
type
HEXA is
(`A', `B', `C', `D', `E', `F');
type
MIXED is
(`A', `B', `*', B, NONE, `?', `%');
subtype
WEEKDAY is
DAY range
MON .. FRI;
subtype
MAJOR is
SUIT range
HEARTS .. SPADES;
subtype
RAINBOW is
COLOR range
RED .. BLUE; -- the color RED,
-- not the light
type
ROMAN_DIGIT is
(`I', `V', `X', `L', `C', `D', `M');
type
T is range
L .. R;
type
integer_type is new
predefined_integer_type;
subtype
T is
integer_type
range
integer_type(L) .. integer_type(R);
type
PAGE_NUM is range
1 .. 2;
type
LINE_SIZE is range
1 .. MAX_LINE_SIZE;
subtype
SMALL_INT is
INTEGER range
-10 .. 10;
subtype
COLUMN_PTR is
LINE_SIZE range
1 .. 10;
subtype
BUFFER_SIZE is
INTEGER range
0 .. MAX;
not
, and the predefined logical operators. For integer types, operations include the predefined arithmetic operators: these are the binary and unary adding operators - and +, all multiplying operators, the unary operator abs
, and the exponentiating operator.
T'POS(T'SUCC(X)) = T'POS(X) + 1
T'POS(T'PRED(X)) = T'POS(X) - 1
T'POS(T'VAL(N)) = N
-- For the types and subtypes declared in section 3.5.1
-- we have:
-- COLOR'FIRST = WHITE, COLOR'LAST = BLACK
-- RAINBOW'FIRST = RED, RAINBOW'LAST = BLUE
-- COLOR'POS(BLUE) = RAINBOW'POS(BLUE) = 4
-- COLOR'VAL(0) = RAINBOW'VAL(0) = WHITE
floating_point_constraint | fixed_point_constraint
floating_accuracy_definition [range_constraint]
floating_accuracy_definition ::=
digits
static_simple_expression
sign * mantissa * (radix ** exponent)
type
T is digits
D [range
L .. R];
type
floating_point_type is new
predefined_floating_point_type;
subtype
T is
floating_point_type digits
D
[range
floating_point_type(L) .. floating_point_type(R)];
type
COEFFICIENT is digits
10 range
-1.0 .. 1.0;
type
REAL is digits
8;
type
MASS is digits
7 range
0.0 .. 1.0E35;
subtype
SHORT_COEFF is
COEFFICIENT digits
5;
-- a subtype with less accuracy
subtype
PROBABILITY is
REAL range
0.0 .. 1.0;
-- a subtype with a smaller range