compilation ::= {compilation_unit}
compilation_unit ::= context_clause library_item | context_clause subunit
library_item ::= [private] library_unit_declaration | library_unit_body | [private] library_unit_renaming_declaration
library_unit_declaration ::= subprogram_declaration | package_declaration | generic_declaration | generic_instantiation
library_unit_renaming_declaration ::= package_renaming_declaration | generic_renaming_declaration | subprogram_renaming_declaration
library_unit_body ::= subprogram_body | package_body
parent_unit_name ::= name
package Rational_Numbers.IO is -- public child of Rational_Numbers, see section Package Specifications and Declarations procedure Put(R : in Rational); procedure Get(R : out Rational); end Rational_Numbers.IO;
private procedure Rational_Numbers.Reduce(R : in out Rational); -- private child of Rational_Numbers
with Rational_Numbers.Reduce; -- refer to a private child package body Rational_Numbers is ... end Rational_Numbers;
with Rational_Numbers.IO; use Rational_Numbers; with Ada.Text_io; -- see section Text Input-Output procedure Main is -- a root library procedure R : Rational; begin R := 5/3; -- construct a rational number, see section Package Specifications and Declarations Ada.Text_IO.Put("The answer is: "); IO.Put(R); Ada.Text_IO.New_Line; end Main;
with Rational_Numbers.IO; package Rational_IO renames Rational_Numbers.IO; -- a library unit renaming declaration
context_clause ::= {context_item}
context_item ::= with_clause | use_clause
with_clause ::= with library_unit_name {, library_unit_name};Name Resolution Rules
body_stub ::= subprogram_body_stub | package_body_stub | task_body_stub | protected_body_stub
subprogram_body_stub ::= subprogram_specification is separate;
package_body_stub ::= package body defining_identifier is separate;
task_body_stub ::= task body defining_identifier is separate;
protected_body_stub ::= protected body defining_identifier is separate;
subunit ::= separate (parent_unit_name) proper_bodyLegality Rules
Examples
package Parent is procedure Inner; end Parent;
with Ada.Text_IO; package body Parent is Variable : String := "Hello, there."; procedure Inner is begin Ada.Text_IO.Put_Line(Variable); end Inner; end Parent;
package body Parent is Variable : String := "Hello, there."; procedure Inner is separate; end Parent;
with Ada.Text_IO; separate(Parent) procedure Inner is begin Ada.Text_IO.Put_Line(Variable); end Inner;
task Environment_Task;
task body Environment_Task is ... (1) -- The environment declarative_part -- (that is, the sequence of library_items) goes here. begin ... (2) -- Call the main subprogram, if there is one. end Environment_Task;
pragma Preelaborate[(library_unit_name)];
Legality Rules
pragma Pure[(library_unit_name)];
pragma Elaborate(library_unit_name{, library_unit_name});
pragma Elaborate_All(library_unit_name{, library_unit_name});
pragma Elaborate_Body[(library_unit_name)];
Legality Rules
Go to the first, previous, next, last section, table of contents.