![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Package Statements Package Statements provides access to Ada statement labels, statements, exception handlers, machine-code insertions, and parameter associations. These components are defined by the following Ada constructs:
- Statement labels (Ada83 LRM 5.1, Ada95 LRM 5.1)
- Assignment statements (Ada83 LRM 5.2, Ada95 LRM 5.2)
- If statements (Ada83 LRM 5.3, Ada95 LRM 5.3)
- Case statements (Ada83 LRM 5.4, Ada95 LRM 5.4)
- Loop statements (Ada83 LRM 5.5, Ada95 LRM 5.5)
- Block statements (Ada83 LRM 5.6, Ada95 LRM 5.6)
- Exit statements (Ada83 LRM 5.7, Ada95 LRM 5.7)
- Return statements (Ada83 LRM 5.8, Ada95 LRM 6.5)
- Goto statements (Ada83 LRM 5.9, Ada95 LRM 5.8)
- Accept statements (Ada83 LRM 9.5, Ada95 LRM 9.5)
- Select statements (Ada83 LRM 9.7, Ada95 LRM 9.7)
- Abort statements (Ada83 LRM 9.10, Ada95 LRM 9.10)
- Exception handlers and raise statements (Ada83 LRM 11.2, Ada95 LRM 11.2 and
Ada83 LRM 11.3, Ada95 LRM 11.3)- Machine-code insertions (Ada83 LRM 13.8, Ada95 LRM 13.8)
- Parameter associations (Ada83 LRM 6.4, Ada95 LRM 6.4)
For more information, click on a topic:
Resources in Package StatementsThe subprograms in package Statements fall into several functional groups, as shown below.
To see detailed referenced information, click on the name of a subprogram:
Determining statement kind:
Kind
Processing labeled statements:
Is_Labeled Label_Names
Processing assignment statements:
Assignment_Expression Object_Assigned_To
Processing if statements:
Arm_Statements Condition_Expression If_Statement_Arm_Kind If_Statement_Arms
Processing case statements:
Case_Expression Case_Statement_Alternative_Choices Case_Statement_Alternative_Statements Case_Statement_Alternatives
Processing accept statements:
Accept_Body_Statements
Accept_Entry_Simple_Name
Accept_Parameters
Accepted_Entry
Processing delay statements:
Delay_Expression
Processing select statements:
Arm_Select_Alternative
Else_Statements
Entry_Call_Statements
Guard
Is_Guarded
Select_Alternative_Kind
Select_Alternative_Statements
Select_Statement_Arm_Kind
Select_Statement_Arms
Timed_Entry_Call_Or_Statements
Processing abort statements:
Aborted_Tasks
Processing exception handlers and raise statements:
Exception_Choices
Handler_Statements
Is_Others_Handler
Raised_Exception
Processing machine-code insertions:
Qualified_Expression
Key Concepts for Package StatementsPackage Statements provides subprograms to extract information about Ada statements as they are described in the LRM. The following sections show the LRM syntax for statements and how to use package statements to extract information.
Click on a topic for more information:
- "Determining Statement Kind"
- "Processing Labeled Statements"
- "Processing Assignment Statements"
- "Processing If Statements"
- "Processing Case Statements"
- "Processing Loop Statements"
- "Processing Block Statements"
- "Processing Exit Statements"
- "Processing Return Statements"
- "Processing Goto Statements"
- "Processing Procedure- and Entry-Call Statements"
- "Processing Parameter Associations"
- "Processing Accept Statements"
- "Processing Delay Statements"
- "Processing Select Statements"
- "Processing Selective Waits"
- "Processing Conditional Entry Calls"
- "Processing Timed Entry Calls"
- "Processing Abort Statements"
- "Processing Exception Handlers and Raise Statements"
- "Processing Machine-Code Insertions"
Determining Statement Kind
Ada statements are defined by the following syntax:
sequence_of_statements ::=
statement {statement}statement ::= {label} simple_statement
| {label} compound_statementsimple_statement ::= null_statement
| assignment_statement
| procedure_call_statement
| exit_statement
| return_statement
| goto_statement
| entry_cal
| raise_statement
| code_statementcompound_statement ::= null_statement
if_statement
| case_statement
| loop_statement
| block_statement
| accept_statement
| select_statementlabel ::= <<label_simple_name>>
ASIS maintains the concept of a sequence of statements but does not distinguish between simple statements and compound statements. All statements are described by an element kinds of A_Statement with a subkind of Statements.Statement_Kind except for the select statement. Because of the select statement's complexity, it is defined in terms of its components:
select_statement ::= selective_wait
| conditional_entry_call | timed_entry_callThe correspondence between statements and Statement_Kinds is given in the description of the Statement_Kinds type. You can determine an element's Statement_Kind with the Kind function.
Processing Labeled Statements
Labeled statements are defined by the following syntax:
statement ::= {label} simple_statement
| {label} compound_statementlabel ::= <<label_simple_name>>
The components and related information can be obtained by calling the subprograms in the following table:
Information Desired Call to Use
label_simple_name list Label_Names
Whether a statement has a label Is_Labeled
Processing Assignment Statements
Assignment statements are defined by the following syntax:
assignment_statement ::=
variable_name ::= expression;The components can be obtained by calling the subprograms in the following table:
Information Desired Call to Use
variable_name Object_Assigned_To
expression Assignment_Expression
Processing If Statements
If statements are defined by the following syntax:
if_statement ::=
if condition then
sequence_of_statements
{elsif condition then
sequence_of_statements}
[else
sequence_of_statements]
end if;If statement processing is based on the concept of arms. Arm kinds of if statement are defined by the If_Statement_Arm_Kinds enumeration and can be obtained by calling the If_Statement_Arm_Kind function. An arm can be one of:
- The condition and sequence of statements following the if reserved word
- The condition and sequence of statements following an elsif reserved word
- The sequence of statements following the else reserved word
The components and related information can be obtained by calling the subprograms in the following table:
Information Desired Call to Use
condition Condition_Expression
sequence_of_statements Arm_Statements
if_statement arm list If_Statement_Arms
The kind of an arm If_Statement_Arm_Kind
Processing Case Statements
Case statements are defined by the following syntax:
case_statement ::=
case expression is
case_statement_alternative
{case_statement_alternative}
end case;
case_statement_alternative ::=
when choice {| choice } =>
sequence_of_statementsThe components and related information can be obtained by calling the subprograms in the following table:
Processing Loop Statements
Loop statements are defined by the following syntax:
loop_statement ::=
[loop_simple_name:]
[iteration_scheme] loop
sequence_of_statements
end loop [loop_simple_name];
iteration_scheme ::= while condition
| for loop_parameter_specification
loop_parameter_specification ::=
identifier in [reverse] discrete_rangeThe components and related information can be obtained by calling the subprograms in the following table:
Processing Block Statements
Block statements are defined by the following syntax:
block_statement ::=
[block_simple_name:]
[declare
declarative_part]
begin
sequence_of_statements
[exception
exception_handler
{exception_handler}]
end [block_simple_name];The components and related information can be obtained by calling the subprograms in the following table:
Processing Exit Statements
Exit statements are defined by the following syntax:
exit_statement ::=
exit [loop_name] [when condition];The components and related information can be obtained by calling the subprograms in the following table:
Information Desired Call to Use
loop_name Exit_Loop_Name
condition Exit_Condition
The loop statement being exited Loop_Exited
Processing Return Statements
Return statements are defined by the following syntax:
return_statement ::= return [expression];
The component can be obtained by calling the subprogram in the following table:
Information Desired Call to Use
expression Return_Expression
Processing Goto Statements
Goto statements are defined by the following syntax:
goto_statement ::= goto label_name;
The components and related information can be obtained by calling the subprograms in the following table:
Information Desired Call to Use
label_name Goto_Label
The target statement of the goto statement Destination_Statement
Processing Procedure- and Entry-Call Statements
Procedure- and entry-call statements are defined by the following syntax:
procedure_call_statement ::=
procedure_name [actual_parameter_part];entry_call_statement ::=
entry_name [actual_parameter_part];The entry name can include an entry index if a family of entries is defined. See "Processing Accept Statements" for more information.
The components and related information can be obtained by calling the subprograms in the following table:
Information Desired Call to Use
procedure_name
entry_nameCalled_Name
entry_index Family_Index
The declaration of the called procedure or entry Called_Procedure
Processing Parameter Associations
Parameter associations are defined by the following syntax:
actual_parameter_part ::=
(parameter_association
{, parameter_association})
parameter_association ::=
[formal_parameter =>] actual_parameter
formal_parameter ::= parameter_simple_nameThe components and related information can be obtained by calling the subprograms in the following table:
Information Desired Call to Use
parameter_association list Call_Parameters
formal_parameter Formal_Parameter
actual_parameter Actual_Parameter
parameter_simple_name Expressions.Name
Processing Accept Statements
Accept statements are defined by the following syntax:
accept_statement ::=
accept entry_simple_name [(entry_index)]
[formal_part]
[do
sequence_of_statements
end [entry_simple_name]];The components and related information can be obtained by calling the subprograms in the following table:
Processing Delay Statements
Delay statements are defined by the following syntax:
delay_statement ::= delay simple_expression;
The component can be obtained by calling the subprogram in the following table:
Information Desired Call to Use
delay_simple_expression Delay_Expression
Processing Select Statements
Select statements are partially defined by the following syntax:
select_statement ::= selective_wait
| conditional_entry_call | timed_entry_callAda83 LRM 9.7.1, Ada95 LRM 9.7.1
selective_wait ::=
select
select_alternative
{or
select_alternative}Ada83 LRM 9.7.2, Ada95 LRM 9.7.3
conditional_entry_call :=
select
entry_call_statement
[sequence_of_statements]
else
sequence_of_statements
end select;Ada83 LRM 9.7.3, Ada95 LRM 9.7.2
timed_entry_call ::=
select
entry_call_statement
[sequence_of_statements]
or
delay_alternative
end select;Select-statement processing is based on the concept of arms. Select-statement arms are defined by the Select_Statement_Arm_Kinds enumeration and can be obtained with the Select-_Statement_Arm_Kind function. An arm can be one of:
- The select alternative following the reserved word select or or in a selective wait
- The entry-call statement and optional sequence of statements in a conditional entry call or timed entry call
- The sequence of statements following the reserved word else in the selective wait or conditional entry call
- The delay alternative following the reserved word or in a timed entry call
The three forms of the select statement are described separately. The form of select statement being processed is identified by the Select_Statement_Arm_Kinds type according to the following table:
You can obtain the Select_Statement_Arm_Kinds type for a specific select arm with the Select_Statement_Arm_Kind function.
Processing Selective Waits
Selective-wait select statements are defined by the following syntax:
Ada83 LRM 9.7.1, Ada95 LRM 9.7.1
selective_wait ::=
select
select_alternative
{or
select_alternative}
[else
sequence_of_statements]
end select;
select_alternative ::=
[when condition =>]
selective_wait_alternative
selective_wait_alternative ::=
accept_alternative
| delay_alternative
| terminate_alternative
accept_alternative ::=
accept_statement
[sequence_of_statements]
delay_alternative ::=
delay_statement
[sequence_of_statements]
terminate_alternative ::= terminate;The components and related information can be obtained by calling the subprograms in the following table:
Processing Conditional Entry Calls
Conditional entry-call select statements are defined by the following syntax:
Ada83 LRM 9.7.2, Ada95 LRM 9.7.3
conditional_entry_call :=
select
entry_call_statement
[sequence_of_statements]
else
sequence_of_statements
end select;The components and related information can be obtained by calling the subprograms in the following table:
Processing Timed Entry Calls
Timed entry-call select statements are defined by the following syntax:
Ada83 LRM 9.7.3, Ada95 LRM 9.7.2
timed_entry_call ::=
select
entry_call_statement
[sequence_of_statements]
or
delay_alternative
end select;delay_alternative ::=
delay_statement
[sequence_of_statements]The components and related information can be obtained by calling the subprograms in the following table:
Processing Abort Statements
Abort statements are defined by the following syntax:
Ada83 LRM 9.10, Ada95 LRM 9.10
abort_statement ::=
abort task_name {, task_name};The task names can be obtained by calling the subprogram in the following table:
Information Desired Call to Use
task_name list Aborted_Tasks
Processing Exception Handlers and Raise
StatementsException handlers and raise statements are defined by the following syntax:
Ada83 LRM 11.2, Ada95 LRM 11.2
exception_handler ::=
when exception_choice {| exception_choice} =>
sequence_of_statements
exception_choice ::= exception_name | othersAda83 LRM 11.3, Ada95 LRM 11.3
raise_statement ::= raise [exception_name];
The components and related information can be obtained by calling the subprograms in the following table:
Processing Machine-Code Insertions
Machine-code insertions are defined by the following syntax:
Ada83 LRM 13.8, Ada95 LRM 13.8
code_statement ::= type_mark'record_aggregate;
The components can be obtained by calling the subprograms in the following table:
Information Desired Call to Use
code_statement Qualified_Expression
type_mark Expressions.Type_Mark
record_aggregate Expressions.Converted_Or_Qualified_Expression
Function Aborted_Tasks
function Aborted_Tasks (Statement : in Asis.Statement) return Asis.Expression_List;Expanded Name Asis.Statements.Aborted_Tasks
Returns a list of expressions representing the task names in the specified abort statement.
Description
Abort statements are defined by the following syntax:
Ada83 LRM 9.10, Ada95 LRM 9.10
abort_statement ::=
abort task_name {, task_name};This function returns a list containing expressions that represent the task names for the specified abort statement. The task names are returned in the order specified in the source code.
Use the functions in the package Expressions to further analyze the returned expressions.
Parameters
Statement : in Asis.Statement;Specifies the statement that should be queried. The statement must be of the following kinds:
Element_Kinds Statement_Kinds
A_Statement An_Abort_Statement
return Asis.Expression_List;The returned list contains elements of the following kind:
Element_Kinds
An_Expression
Errors
Asis_Inappropriate_Element is raised and Environment.Status is set to Value_Error if a parameter references a library variable that is no longer open, or a parameter is specified that is not appropriate for the query.
Examples
Cross-References
- "Processing Abort Statements"
- package Expressions, "Processing Expressions"
- Ada83 LRM 9.10, Ada95 LRM 9.10
Function Accept_Body_Statements
function Accept_Body_Statements (Statement : in Asis.Statement; Include_Pragmas : in Boolean := False) return Asis.Statement_List;Expanded Name Asis.Statements.Accept_Body_Statements
Returns a list of all statements and, optionally, pragmas present in the specified accept statement.
Description
Accept statements are partially defined by the following syntax:
accept_statement ::=
accept entry_simple_name [(entry_index)]
[formal_part]
[do
sequence_of_statements
end [entry_simple_name]];This function returns the sequence of statements for the specified accept statement.
Statements and pragmas are returned in their order of appearance in the source code. A_Pragma elements do not appear in the list unless Include_Pragmas has been specified as True.
Element_Kinds Calls to Use
A_Pragma Elements.
Argument_Associations
Is_Predefined
Name
Pragma_Kind
A_Statement Statements.
(most subprograms)
Parameters
Statement : in Asis.Statement;Specifies the statement that should be queried. The statement must be of the following kinds:
Element_Kinds Statement_Kinds
A_Statement An_Accept_Statement
Include_Pragmas : in Boolean := False;Specifies whether pragma definitions should be included in the returned list.
return Asis.Statement_List;The returned list contains elements of the following kinds:
Element_Kinds
A_Pragma
A_Statement
Errors
Asis_Inappropriate_Element is raised and Environment.Status is set to Value_Error if a parameter references a library variable that is no longer open, or a parameter is specified that is not appropriate for the query.
Examples
Cross-References
- function Accept_Entry_Simple_Name
- function Accept_Parameters
- function Accepted_Entry
- function Family_Index
- "Processing Accept Statements"
- Ada83 LRM 9.5, Ada95 LRM 9.5
Rational Software Corporation
http://www.rational.com support@rational.com techpubs@rational.com Copyright © 1993-2001, Rational Software Corporation. All rights reserved. |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |