Category : Miscellaneous Language Source Code
Archive   : ADABRIEF.ZIP
Filename : ADAPKG1
basic_declaration object_declaration number_declaration identifier_list
basic_declaration ::=
object_declaration | number_declaration
| type_declaration | subtype_declaration
| subprogram_declaration | package_declaration
| task_declaration | generic_declaration
| exception_declaration | generic_instantiation
| renaming_declaration | deferred_constant_declaration
object_declaration ::=
identifier_list : [constant] subtype_indication [:= expression];
| identifier_list : [constant] constrained_array_definition [:= expression];
number_declaration ::=
identifier_list : constant := universal_static_expression;
PgDn => next page
identifier_list ::= identifier {, identifier}
Example:
-- the multiple object declaration
JOHN, PAUL : PERSON_NAME := new PERSON(SEX => M); -- see 3.8.1
-- equivalent to two single object declarations in the order given
JOHN : PERSON_NAME := new PERSON(SEX => M);
PAUL : PERSON_NAME := new PERSON(SEX => M);
Examples of variable declarations:
COUNT, SUM : INTEGER;
SIZE : INTEGER range 0 .. 10_000 := 0;
SORTED : BOOLEAN := FALSE;
COLOR_TABLE : array(1 .. N) of COLOR;
OPTION : BIT_VECTOR(1 .. 10) := (others => TRUE);
PgUp => previous page PgDn => next page
Examples of constant declarations:
LIMIT : constant INTEGER := 10_000;
LOW_LIMIT : constant INTEGER := LIMIT/10;
TOLERANCE : constant REAL := DISPERSION(1.15);
Examples of number declarations:
PI : constant := 3.14159_26536; -- a real number
TWO_PI : constant := 2.0*PI; -- a real number
MAX : constant := 500; -- an integer number
POWER_16 : constant := 2**16; -- the integer 65_536
ONE, UN, EINS : constant := 1; -- three different names for 1
PgUp => previous page
type_declaration full_type_declaration type_definition
type_declaration ::= full_type_declaration
| incomplete_type_declaration | private_type_declaration
full_type_declaration ::=
type identifier [discriminant_part] is type_definition;
type_definition ::=
enumeration_type_definition | integer_type_definition
| real_type_definition | array_type_definition
| record_type_definition | access_type_definition
| derived_type_definition
PgDn => next page
Examples of type definitions:
(WHITE, RED, YELLOW, GREEN, BLUE, BROWN, BLACK)
range1 .. 72
array(1 .. 10) of INTEGER
Examples of type declarations:
type COLOR is (WHITE, RED, YELLOW, GREEN, BLUE, BROWN, BLACK);
type COLUMN is range 1 .. 72;
type TABLE is array(1 .. 10) of INTEGER;
PgUp => previous page
subtype_declaration subtype_indication type_mark constraint
subtype_declaration ::=
subtype identifier is subtype_indication;
subtype_indication ::= type_mark [constraint]
type_mark ::= type_name | subtype_name
constraint ::=
range_constraint | floating_point_constraint
| fixed_point_constraint | index_constraint | discriminant_constraint
PgDn => next page
Examples of subtype declarations:
subtype RAINBOW is COLOR range RED .. BLUE; -- see 3.3.1
subtype RED_BLUE is RAINBOW;
subtype INT is INTEGER;
subtype SMALL_INT is INTEGER range -10 .. 10;
subtype UP_TO_K is COLUMN range 1 .. K; -- see 3.3.1
subtype SQUARE is MATRIX(1 .. 10, 1 .. 10); -- see 3.6
subtype MALE is PERSON(SEX => M); -- see 3.8
PgUp => previous page
range_constraint range
range_constraint ::= range range
range ::= range_attribute
| simple_expression .. simple_expression
enumeration_type_definition enumeration_literal_specification enumeration_literal
enumeration_type_definition ::=
(enumeration_literal_specification
{,enumeration_literal_specification})
enumeration_literal_specification ::= enumeration_literal
enumeration_literal ::= identifier | character_literal
Examples:
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);
PgDn => next page
Examples:
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;
Example:
type ROMAN_DIGIT is ('I', 'V', 'X', 'L', 'C', 'D', 'M');
PgUp => previous page
integer_type_definition
integer_type_definition ::= range_constraint
Examples:
type PAGE_NUM is range 1 .. 2_000;
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;
real_type_definition floating_point_constraint floating_accuracy_definition
real_type_definition ::=
floating_point_constraint | fixed_point_constraint
floating_point_constraint ::=
floating_accuracy_definition [range_constraint]
floating_accuracy_definition ::= digits static_simple_expression
Examples:
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
fixed_point_constraint fixed_accuracy_definition
fixed_point_constraint ::=
fixed_accuracy_definition [range_constraint]
fixed_accuracy_definition ::= delta static_simple_expression
Examples:
type VOLT is delta 0.125 range 0.0 .. 255.0;
subtype ROUGH_VOLTAGE is VOLT delta 1.0; -- same range as VOLT
-- A pure fraction which requires all available space in a word
-- on two's complement machine can be declared as type FRACTION:
DEL : constant := 1.0/2**(WORD_LENGTH - 1);
type FRACTION is delta DEL range -1.0 .. 1.0 - DEL;
array_type_definition unconstrained_array_definition constrained_array_definition index_subtype_definition index_constraint discrete_range
array_type_definition ::=
unconstrained_array_definition | constrained_array_definition
unconstrained_array_definition ::=
array(index_subtype_definition {, index_subtype_definition}) of
component_subtype_indication
constrained_array_definition ::=
array index_constraint of component_subtype_indication
index_subtype_definition ::= type_mark range <>
index_constraint ::= (discrete_range {, discrete_range})
discrete_range ::= discrete_subtype_indication | range
PgDn => next page
Examples of type declarations with unconstrained array definitions:
type VECTOR is array(INTEGER range <>) of REAL;
type MATRIX is array(INTEGER range <>, INTEGER range <>) of REAL;
type BIT_VECTOR is array(INTEGER range <>) of BOOLEAN;
type ROMAN is array(POSITIVE range <>) of ROMAN_DIGIT;
Examples of type declarations with constrained array definitions:
type TABLE is array(1 .. 10) of INTEGER;
type SCHEDULE is array(DAY) of BOOLEAN;
type LINE is array(1 .. MAX_LINE_SIZE) of CHARACTER;
Examples of object declarations with constrained array definitions:
GRID : array(1 .. 80, 1 .. 100) of BOOLEAN;
MIX : array(COLOR range RED .. GREEN) of BOOLEAN;
PAGE : array(1 .. 50) of LINE; -- an array of arrays
PgUp => previous page PgDn => next page
Examples of array declarations including an index constraint:
BOARD : MATRIX(1 .. 8, 1 .. 8); -- see 3.6
RECTANGLE : MATRIX(1 .. 20, 1 .. 30);
INVERSE : MATRIX(1 .. N, 1 .. N); -- N need not be static
FILTER : BIT_VECTOR(0 .. 31);
Example of array declaration with a constrained array subtype:
MY_SCHEDULE : SCHEDULE; -- arrays of type SCHEDULE have same bounds
Example of record type with a component that is an array:
type VAR_LINE(LENGTH : INTEGER) is
record
IMAGE : STRING(1 .. LENGTH);
end record;
NULL_LINE : VAR_LINE(0); -- NULL_LINE.IMAGE is a null array
PgUp => previous page PgDn => next page
POSITIVE:
subtype POSITIVE is INTEGER range 1 .. INTEGER'LAST;
type STRING is array(POSITIVE range <>) of CHARACTER;
Examples:
STARS : STRING(1 .. 120) := (1 .. 120 => '*' );
QUESTION : constant STRING := "HOW MANY CHARACTERS?";
-- QUESTION'FIRST = 1, QUESTION'LAST = 20 (the number of characters)
3 - 63
ASK_TWICE : constant STRING := QUESTION & QUESTION;
NINETY_SIX : constant ROMAN := "XCVI"; -- see 3.6
PgUp => previous page
record_type_definition component_list component_declaration component_subtype_definition
record_type_definition ::=
record
component_list
end record
component_list ::=
component_declaration {component_declaration}
| {component_declaration} variant_part
| null;
component_declaration ::=
identifier_list : component_subtype_definition [:= expression];
component_subtype_definition ::= subtype_indication
PgDn => next page
Examples of record type declarations:
type DATE is
record
DAY : INTEGER range 1 .. 31;
MONTH : MONTH_NAME;
YEAR : INTEGER range 0 .. 4000;
end record;
type COMPLEX is
record
RE : REAL := 0.0;
IM : REAL := 0.0;
end record;
Examples of record variables:
TOMORROW, YESTERDAY : DATE;
A, B, C : COMPLEX;
-- both components of A, B, and C are implicitly initialized to zero
PgUp => previous page
discriminant_part discriminant_specification
discriminant_part ::=
(discriminant_specification {; discriminant_specification})
discriminant_specification ::=
identifier_list : type_mark [:= expression]
Examples:
type BUFFER(SIZE : BUFFER_SIZE := 100) is -- see 3.5.4
record
POS : BUFFER_SIZE := 0;
VALUE : STRING(1 .. SIZE);
end record;
type SQUARE(SIDE : INTEGER) is
record
MAT : MATRIX(1 .. SIDE, 1 .. SIDE); -- see 3.6
end record;
PgDn => next page
type DOUBLE_SQUARE(NUMBER : INTEGER) is
record
LEFT : SQUARE(NUMBER);
RIGHT : SQUARE(NUMBER);
end record;
type ITEM(NUMBER : POSITIVE) is
record
CONTENT : INTEGER;
-- no component depends on the discriminant
end record;
PgUp => previous page
discriminant_constraint discriminant_association
discriminant_constraint ::=
(discriminant_association {, discriminant_association})
discriminant_association ::=
[discriminant_simple_name
{| discriminant_simple_name} =>] expression
Examples (using types declared in the previous section):
LARGE : BUFFER(200); -- constrained, always 200 characters
-- (explicit discriminant value)
MESSAGE : BUFFER; -- unconstrained, initially 100 characters
-- (default discriminant value)
BASIS : SQUARE(5); -- constrained, always 5 by 5
ILLEGAL : SQUARE; -- illegal, a SQUARE must be constrained
variant_part variant choice
variant_part ::=
case discriminant_simple_name is
variant
{variant}
end case;
variant ::=
when choice {| choice} =>
component_list
choice ::= simple_expression
| discrete_range | others | component_simple_name
PgDn => next page
Example of record type with a variant part:
type DEVICE is (PRINTER, DISK, DRUM);
type STATE is (OPEN, CLOSED);
type PERIPHERAL(UNIT : DEVICE := DISK) is
record
STATUS : STATE;
case UNIT is
when PRINTER =>
LINE_COUNT : INTEGER range 1 .. PAGE_SIZE;
when others =>
3 - 75
CYLINDER : CYLINDER_INDEX;
TRACK : TRACK_NUMBER;
end case;
end record;
PgUp => previous page PgDn => next page
Examples of record subtypes:
subtype DRUM_UNIT is PERIPHERAL(DRUM);
subtype DISK_UNIT is PERIPHERAL(DISK);
Examples of constrained record variables:
WRITER : PERIPHERAL(UNIT => PRINTER);
ARCHIVE : DISK_UNIT;
PgUp => previous page
access_type_definition
access_type_definition ::= access subtype_indication
Examples:
type FRAME is access MATRIX; -- see 3.6
type BUFFER_NAME is access BUFFER; -- see 3.7.1
incomplete_type_declaration
incomplete_type_declaration ::= type identifier [discriminant_part];
Example of a recursive type:
type CELL; -- incomplete type declaration
type LINK is access CELL;
type CELL is
record
VALUE : INTEGER;
SUCC : LINK;
PRED : LINK;
end record;
HEAD : LINK := new CELL'(0, null, null);
NEXT : LINK := HEAD.SUCC;
PgDn => next page
Examples of mutually dependent access types:
type PERSON(SEX : GENDER); -- incomplete type declaration
type CAR; -- incomplete type declaration
type PERSON_NAME is access PERSON;
type CAR_NAME is access CAR;
type CAR is
record
NUMBER : INTEGER;
OWNER : PERSON_NAME;
end record;
PgUp => previous page PgDn => next page
type PERSON(SEX : GENDER) is
record
NAME : STRING(1 .. 20);
BIRTH : DATE;
AGE : INTEGER range 0 .. 130;
VEHICLE : CAR_NAME;
case SEX is
when M => WIFE : PERSON_NAME(SEX => F);
when F => HUSBAND : PERSON_NAME(SEX => M);
end case;
end record;
MY_CAR, YOUR_CAR, NEXT_CAR : CAR_NAME;
-- implicitly initialized with null value
PgUp => previous page
declarative_part basic_declarative_item later_declarative_item body proper_body
declarative_part ::=
{basic_declarative_item} {later_declarative_item}
basic_declarative_item ::= basic_declaration
| representation_clause | use_clause
later_declarative_item ::= body
| subprogram_declaration | package_declaration
| task_declaration | generic_declaration
| use_clause | generic_instantiation
body ::= proper_body | body_stub
proper_body ::= subprogram_body | package_body | task_body
graphic_character basic_graphic_character basic_character
graphic_character ::= basic_graphic_character
| lower_case_letter | other_special_character
basic_graphic_character ::=
upper_case_letter | digit
| special_character | space_character
basic_character ::=
basic_graphic_character | format_effector
the categories of basic graphic characters:
(a) upper case letters
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
(b) digits
0 1 2 3 4 5 6 7 8 9
PgDn => next page
(c) special characters
" # & ' ( ) * + , - . / : ; < = > _ |
(d) the space character
Format effectors are the ISO (and ASCII) characters called
horizontal tabulation, vertical tabulation, carriage return,
line feed, and form feed.
(e) lower case letters
a b c d e f g h i j k l m n o p q r s t u v w x y z
(f) other special characters
³ $ % ? @ [ \ ] ª ` { }
PgUp => previous page PgDn => next page
symbol name symbol name
" quotation > greater than
# sharp _ underline
& ampersand | vertical bar
' apostrophe ! exclamation mark
( left parenthesis $ dollar
) right parenthesis % percent
* star, multiply ? question mark
+ plus @ commercial at
, comma [ left square bracket
- hyphen, minus \ back-slash
. dot, point, period ] right square bracket
/ slash, divide ª circumflex
: colon ` grave accent
; semicolon { left brace
< less than } right brace
= equal ~ tilde
PgUp => previous page
delimiter
A delimiter is either one of the following special characters (in the
basic character set)
& ' ( ) * + , - . / : ; < = > |
or one of the following compound delimiters each composed of two
adjacent special characters
=> .. ** := /= >= <= << >> <>
PgDn => next page
The following names are used when referring to compound delimiters:
delimiter name
=> arrow
.. double dot
** double star, exponentiate
:= assignment (pronounced: "becomes")
/= inequality (pronounced: "not equal")
>= greater than or equal
<= less than or equal
<< left label bracket
>> right label bracket
<> box
References: character literal 2.5, comment 2.7, compilation 10.1,
format effector 2.1, identifier 2.3, numeric literal 2.4, reserved word
2.9, space character 2.1, special character 2.1, string literal 2.6
PgUp => previous page
identifier letter_or_digit letter
identifier ::=
letter {[underline] letter_or_digit}
letter_or_digit ::= letter | digit
letter ::= upper_case_letter | lower_case_letter
Examples:
COUNT X get_symbol Ethelyn Marion
SNOBOL_4 X1 PageCount STORE_NEXT_ITEM
numeric_literal
numeric_literal ::= decimal_literal | based_literal
References: literal 4.2, universal_integer type 3.5.4,
universal_real type 3.5.6
decimal_literal integer exponent
decimal_literal ::= integer [.integer] [exponent]
integer ::= digit {[underline] digit}
exponent ::= E [+] integer | E - integer
Examples:
12 0 1E6 123_456 -- integer literals
12.0 0.0 0.456 3.14159_26 -- real literals
1.34E-12 1.0E+6 -- real literals with exponent
References: digit 2.1, lower case letter 2.1, numeric literal
2.4, separator 2.2, space character 2.1, upper case letter 2.1
based_literal base based_integer extended_digit
based_literal ::=
base # based_integer [.based_integer] # [exponent]
base ::= integer
based_integer ::=
extended_digit {[underline] extended_digit}
extended_digit ::= digit | letter
Examples:
2#1111_1111# 16#FF# 016#0FF# -- integer of value 255
16#E#E1 2#1110_0000# -- integer of value 224
16#F.FF#E+2 2#1.1111_1111_111#E11 -- real of value 4095.0
References: digit 2.1, exponent 2.4.1, letter 2.3, lower case letter
2.1, numeric literal 2.4, upper case letter 2.1
character_literal
character_literal ::= 'graphic_character'
Examples:
'A' '*' ''' ' '
References: character type 3.5.2, graphic character 2.1,
literal 4.2, space character 2.1
string_literal
string_literal ::= "{graphic_character}"
Examples:
"Message of the day:"
"" -- an empty string literal
" " "A" """" -- three string literals of length 1
"Characters such as $, %, and } are allowed in string literals"
"FIRST PART OF A SEQUENCE OF CHARACTERS " &
"THAT CONTINUES ON THE NEXT LINE"
"sequence that includes the" & ASCII.ACK & "control character"
References: ascii predefined package C, catenation operation
4.5.3, character value 3.5.2, constant 3.2.1, declaration 3.1,
end of a line 2.2, graphic character 2.1, lexical element 2.2
comment
A comment starts with two adjacent hyphens and extends up to
the end of the line.
Examples:
-- the last sentence above echoes the Algol 68 report
end; -- processing of LINE is complete
-- a long comment may be split onto
-- two or more consecutive lines
---------------- the first two hyphens start the comment
References: end of a line 2.2, illegal 1.6, legal 1.6,
space character 2.1, 2.8 Pragmas
pragma
A pragma is used to convey information to the compiler.
pragma ::=
pragma identifier [(argument_association {, argument_association})];
argument_association ::=
[argument_identifier =>] name
| [argument_identifier =>] expression
Examples:
pragma LIST(OFF);
pragma OPTIMIZE(TIME);
pragma INLINE(SETMASK);
pragma SUPPRESS(RANGE_CHECK, ON => INDEX);
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/