Annotated King Reference Manual/Declarations

This page is work in progress.

Syntax
declarative_part ::= declarative_item {declarative_item} declarative_item ::= basic_declarative_item | body basic_declarative_item ::= basic_declaration | aspect_clause basic_declaration ::= null_declaration | type_declaration | subtype_declaration | object_declaration | named_value_declaration | subprogram_declaration | statement_procedure_declaration | expression_function_declaration | module_declaration | renaming_declaration | macro_declaration | macro_expansion defining_program_unit_name ::= [parent_unit_name.] defining_identifier

Rationale
Inside basic_declaration, defining_program_unit_name shall be only an identifier.

The mention of parent_unit_name may appear only at library level. It is provided here as some declarations apply at library level.

Discussion
-

Syntax
null_declaration ::= null;

Rationale
-

Discussion
-

Type Declarations
See section Types.

Syntax
subtype_declaration ::= subtype defining_identifier is subtype_indication [aspect_specification]; subtype_indication ::= subtype_mark [constraint] subtype_mark ::= subtype_name

constraint ::= scalar_constraint | composite_constraint scalar_constraint ::= range_constraint range_constraint ::= range range_specification range_specification ::= range_attribute_reference | simple_expression .. simple_expression range_attribute_reference ::= prefix 'range_attribute_designator range_attribute_designator ::= range composite_constraint ::= discriminant_constraint discriminant_constraint ::= (discriminant_association {, discriminant_association}) discriminant_association ::= discriminant_selector_name => expression

Rationale
-

Discussion
-

Syntax
object_declaration ::= defining_identifier : [constant] subtype_indication [is expression] [aspect_specification];

Rationale
-

Discussion
-

Syntax
named_value_declaration ::= defining_identifier = static_expression;

Rationale
-

Discussion
-

Syntax
subprogram_declaration ::= subprogram_specification [aspect_specification]; subprogram_specification ::= procedure_specification | function_specification procedure_specification ::= defining_program_unit_name : procedure parameter_profile function_specification ::= defining_designator : function parameter_and_result_profile defining_designator ::= defining_program_unit_name | defining_operator_symbol operator_symbol ::= string_literal parameter_profile ::= [formal_part] parameter_and_result_profile ::= [formal_part] return subtype_mark formal_part ::= (parameter_specification {; parameter_specification}) parameter_specification ::= defining_identifier : parameter_mode subtype_mark [<- default_expression] parameter_mode ::= in | in out | out

Rationale
-

Discussion
-

Syntax
statement_procedure_declaration ::= simple_statement_procedure | declare_statement_procedure simple_statement_procedure ::= procedure_specification [aspect_specification] is (simple_statement); declare_statement_procedure ::= procedure_specification [aspect_specification] is (declare declare_declaration {declare_declaration}           begin simple_statement); declare_declaration ::= subtype_declaration | object_declaration | named_value_declaration

Rationale
Inner declared objects can only be constant declarations.

Discussion
-

Syntax
expression_function_declaration ::= function_specification [aspect_specification] is (expression);

Rationale
-

Discussion
-

Syntax
module_declaration ::= module_specification; module_specification ::= defining_program_unit_name : module [aspect_specification] is {basic_declarative_item} [parent_unit_name.]identifier : end module

Rationale
-

Discussion
-

Syntax
renaming_declaration ::= object_renaming_declaration | module_renaming_declaration | subprogram_renaming_declaration | macro_renaming_declaration object_renaming_declaration ::= defining_identifier : [constant] subtype_mark renames object_name [aspect_specification]; module_renaming_declaration ::= defining_program_unit_name : module renames module_name [aspect_specification]; subprogram_renaming_declaration ::= subprogram_specification renames callable_entity_name [aspect_specification]; macro_renaming_declaration ::= defining_program_unit_name : macro module renames macro_module_name [aspect_specification];

Rationale
The subtype of renaming object must be the same as for the renamed object.

Renaming a constant object shall include the reserved word constant, on the contrary variable object shall not.

Use a new name value for renaming a named value. Use a new subtype name for renaming a subtype.

Discussion
-

Syntax
macro_declaration ::= macro_module_declaration macro_module_declaration ::= defining_program_unit_name : macro_formal_part module_specification; macro_formal_part ::= macro macro_formal_parameter_declaration {macro_formal_parameter_declaration} macro_formal_parameter_declaration ::= formal_object_declaration | formal_type_declaration | formal_subprogram_declaration formal_object_declaration ::= defining_identifier : constant subtype_mark [<- default_expression] [aspect_specification]; formal_type_declaration ::= formal_complete_type_declaration formal_complete_type_declaration ::= type defining_identifier[discriminant_part] is formal_type_definition [or use default_subtype_mark] [aspect_specification]; formal_type_definition ::= formal_hidden_type_definition | formal_map_type_definition | formal_sequence_type_definition | formal_set_type_definition | formal_discrete_type_definition | formal_signed_integer_type_definition | formal_floating_point_definition | formal_ordinary_fixed_point_definition | formal_any_numeric_definition formal_hidden_type_definition ::= hidden [(<>)] [with <-] formal_map_type_definition ::= map_type_definition formal_sequence_type_definition ::= sequence_type_definition formal_set_type_definition ::= set_type_definition formal_discrete_type_definition ::= [range] (<>) formal_signed_integer_type_definition ::= range <> formal_floating_point_definition ::= digits <> formal_ordinary_fixed_point_definition ::= delta <> formal_any_numeric_definition ::= delta digits [range] <> formal_subprogram_declaration ::= formal_concrete_subprogram_declaration formal_concrete_subprogram_declaration ::= subprogram_specification [is subprogram_default][aspect_specification]; | statement_procedure_declaration | expression_function_declaration subprogram_default ::= default_name | <>

Rationale
-

Discussion
-

Syntax
macro_expansion ::= defining_program_unit_name : module is new macro_module_name [macro_actual_part] [aspect_specification]; macro_actual_part ::= (macro_association {, macro_association}) macro_association ::= macro_formal_parameter_selector_name => explicit_macro_actual_parameter explicit_macro_actual_parameter ::= expression | subprogram_name | subtype_mark

Rationale
-

Discussion
-