compilation_unit ::=
context_clause library_unit | context_clause secondary_unit
subprogram_declaration | package_declaration
| generic_declaration | generic_instantiation
| subprogram_body
with_clause ::=
with
unit_simple_name {, unit_simple_name};
with
TEXT_IO, REAL_OPERATIONS; use
REAL_OPERATIONS;
procedure
QUADRATIC_EQUATION is
A, B, C, D : REAL;
use
REAL_IO, -- achieves direct visibility of GET and PUT
-- for REAL
TEXT_IO, -- achieves direct visibility of PUT for strings
-- and of NEW_LINE
REAL_FUNCTIONS; -- achieves direct visibility of SQRT
begin
GET(A); GET(B); GET(C);
D := B**2 - 4.0*A*C;
if
D < 0.0 then
PUT("Imaginary Roots.");
else
PUT("Real Roots : X1 = ");
PUT((-B - SQRT(D))/(2.0*A)); PUT(" X2 = ");
PUT((-B + SQRT(D))/(2.0*A));
end if
;
NEW_LINE;
end
QUADRATIC_EQUATION;
procedure
PROCESSOR is
constant
:= 20;
TOTAL : INTEGER := 0; package
STOCK is
LIMIT : constant
:= 1
TABLE : array
(1 .. LIMIT) of INTEGER;
procedure
RESTART;
end
STOCK;
package body
STOCK is
procedure
RESTART is
begin
for
N in
1 .. LIMIT loop
TABLE(N) := N;
end loop
;
end
;
begin
RESTART;
end
STOCK;
procedure
UPDATE(X : INTEGER) is
use
STOCK;
begin
...
TABLE(X) := TABLE(X) + SMALL;
...
end
UPDATE;
begin
...
STOCK.RESTART; -- reinitializes TABLE
...
end
PROCESSOR;
package
STOCK is
LIMIT : constant
:= 1
TABLE : array
(1 .. LIMIT) of
INTEGER;
procedure
RESTART;
end
STOCK;
package body
STOCK is
procedure
RESTART is
begin
for
N in
1 .. LIMIT loop
TABLE(N) := N;
end loop
;
end
;
begin
RESTART;
end
STOCK;
with
STOCK;
procedure
PROCESSOR is
SMALL :
constant
:= 20;
TOTAL : INTEGER := 0; procedure
UPDATE(X : INTEGER) is
use
STOCK;
begin
...
TABLE(X) := TABLE(X) + SMALL;
...
end
UPDATE;
begin
...
STOCK.RESTART; -- reinitializes TABLE
...
end
PROCESSOR;