TOC PREV NEXT INDEX DOC LIST MASTER INDEX



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:

For more information, click on a topic:


Resources in Package Statements

The 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 loop statements:

For_Loop_Parameter_Specification Is_Reverse_Loop_Parameter Loop_Kind Loop_Parameter_Range Loop_Simple_Name Loop_Statements While_Condition
Processing block statements:

Block_Body_Statements Block_Exception_Handlers Block_Simple_Name Declarative_Items
Processing exit statements

Exit_Condition Exit_Loop_Name Loop_Exited

Processing return statements:

Return_Expression
Processing goto statements:

Destination_Statement Goto_Label

Processing procedure and entry call statements:
Called_Name Called_Procedure Family_Index

Processing parameter associations:
Actual_Parameter Call_Parameters Formal_Parameter

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 Statements

Package 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

Ada statements are defined by the following syntax:

Ada83 LRM 5.1, Ada95 LRM 5.1 

sequence_of_statements ::=
  statement {statement}

 statement ::= {label} simple_statement
  | {label} compound_statement

 simple_statement ::= null_statement
  | assignment_statement
  | procedure_call_statement
  | exit_statement
  | return_statement
  | goto_statement
  | entry_cal
  | raise_statement
  | code_statement

 compound_statement ::= null_statement
   if_statement
  | case_statement
  | loop_statement
  | block_statement
  | accept_statement
  | select_statement

 label ::= <<label_simple_name>>    

 null_statement ::= null;

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:

Ada83 LRM 9.7, Ada95 LRM 9.7

 select_statement ::= selective_wait
  | conditional_entry_call | timed_entry_call

The 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:

Ada83 LRM 5.1, Ada95 LRM 5.1 

statement ::= {label} simple_statement
  | {label} compound_statement

 label ::= <<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:

Ada83 LRM 5.2, Ada95 LRM 5.2

 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:

Ada83 LRM 5.3, Ada95 LRM 5.3 

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 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:

Ada83 LRM 5.4, Ada95 LRM 5.4 

case_statement ::=
  case expression is
   case_statement_alternative
   {case_statement_alternative}
  end case;

 case_statement_alternative ::=
  when choice {| choice } =>
   sequence_of_statements

The components and related information can be obtained by calling the subprograms in the following table:
Information Desired
Call to Use
expression
Case_Expression
case_statement-
_alternative

Case_Statement_Alternatives
sequence_of_statements
Case_Statement_Alternative-_Statements
choice list
Case_Statement_Alternative-_Choices
Whether a choice is when others
Is_When_Others

Processing Loop Statements

Loop statements are defined by the following syntax:

Ada83 LRM 5.5, Ada95 LRM 5.5 

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_range

The components and related information can be obtained by calling the subprograms in the following table:
Information Desired
Call to Use
loop_simple_name
Loop_Simple_Name
condition
While_Condition
identifier
For_Loop_Parameter-
_Specification

sequence_of_statements
Loop_Statements
discrete_range
Loop_Parameter_Range
The kind of loop
Loop_Kind
Whether the loop is in reverse order
Is_Reverse_Loop_Parameter

Processing Block Statements

Block statements are defined by the following syntax:

Ada83 LRM 5.6, Ada95 LRM 5.6

 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:
Information Desired
Call to Use
block_simple_name
Block_Simple_Name
declarative_part list
Declarative_Items
sequence_of_statements
Block_Body_Statements
exception_handler list
Block_Exception_Handlers

Processing Exit Statements

Exit statements are defined by the following syntax:

Ada83 LRM 5.7, Ada95 LRM 5.7

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:

Ada83 LRM 5.8, Ada95 LRM 6.5 

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:

Ada83 LRM 5.9, Ada95 LRM 5.8 

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:

Ada83 LRM 6.4, Ada95 LRM 6.4 

procedure_call_statement ::=
  procedure_name [actual_parameter_part];

Ada83 LRM 9.5, Ada95 LRM 9.5 

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_name

Called_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:

Ada83 LRM 6.4, Ada95 LRM 6.4 

actual_parameter_part ::=
  (parameter_association
   {, parameter_association})

 parameter_association ::=
  [formal_parameter =>] actual_parameter

 formal_parameter ::= parameter_simple_name

The 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:

Ada83 LRM 9.5, Ada95 LRM 9.5

 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:
Information Desired
Call to Use
entry_simple_name
Accept_Entry_Simple_Name
entry_index
Family_Index
formal_part list
Accept_Parameters
sequence_of_statements
Accept_Body_Statements
The declaration of the entry
Accepted_Entry

Processing Delay Statements

Delay statements are defined by the following syntax:

Ada83 LRM 9.6, Ada95 LRM 9.6

 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:

Ada83 LRM 9.7, Ada95 LRM 9.7 

select_statement ::= selective_wait
  | conditional_entry_call | timed_entry_call

Ada83 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 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:
Select_Statement_Arm_Kinds
select_statement
A_Conditional_Entry_Call-_Else_Arm
A_Conditional_Entry_Call-_Select_Arm

conditional_entry_call
A_Selective_Wait_Else_Arm
A_Selective_Wait_Or_Arm
A_Selective_Wait_Select_Arm

selective_wait
A_Timed_Entry_Call_Or_Arm
A_Timed_Entry_Call_Select_Arm

timed_entry_call

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:
Information Desired
Call to Use
select_alternative
Arm_Select_Alternative
condition
Guard
accept_alternative
delay_alternative

Select_Alternative_Statements
sequence_of_statements (for the else alternative)
Else_Statements
selective_wait arm list
Select_Statement_Arms
The kind of an arm
Select_Statement_Arm_Kind
The kind of the selective-
_wait_alternative

Select_Alternative_Kind
Whether the select-
_alternative
contains a when condition guard

Is_Guarded

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:
Information Desired
Call to Use
entry_call_statement and the following sequence-_of_statements
Entry_Call_Statements
sequence_of_statements (for the else alternative)
Else_Statements
conditional_entry_call arm list
Select_Statement_Arms
The kind of an arm
Select_Statement_Arm_Kind

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:
Information Desired
Call to Use
entry_call_statement and the following sequence-_of_statements
Entry_Call_Statements
delay_alternative
Timed_Entry_Call_Or_Statements
timed_entry_call arm list
Select_Statement_Arms
The kind of an arm
Select_Statement_Arm_Kind

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
Statements

Exception 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 | others

Ada83 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:
Information Desired
Call to Use
exception_choice list
Exception_Choices
sequence_of_statements
Handler_Statements
exception_name (from raise_statement)
Raised_Exception
exception_name (from exception_choice)
Type_Definitions.Choice-_Simple_Expression to obtain the expression and then Expressions.Name
What exception handlers exist in a block statement or in the body of a subprogram, package, task unit, or generic unit
Block_Exception_Handlers
Whether an exception-_choice is when others
Is_Others_Handler

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

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

Specifies the statement that should be queried. The statement must be of the following kinds:
Element_Kinds
Statement_Kinds
A_Statement
An_Abort_Statement

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

Related concepts:


Function Accept_Body_Statements

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:

Ada83 LRM 9.5, Ada95 LRM 9.5 

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.

For further analysis:
Element_Kinds
Calls to Use
A_Pragma
Elements.
Argument_Associations
Is_Predefined
Name
Pragma_Kind

A_Statement
Statements.
(most subprograms)

Parameters

Specifies the statement that should be queried. The statement must be of the following kinds:
Element_Kinds
Statement_Kinds
A_Statement
An_Accept_Statement

Specifies whether pragma definitions should be included in the returned 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

Related subprograms:

Related concepts:


Rational Software Corporation  http://www.rational.com
support@rational.com
techpubs@rational.com
Copyright © 1993-2001, Rational Software Corporation. All rights reserved.
TOC PREV NEXT INDEX DOC LIST MASTER INDEX TECHNOTES APEX TIPS