Lady Ada

Ada '83 Language Reference Manual

Copyright 1980, 1982, 1983 owned by the United States Government. Direct reproduction and usage requests to the Ada Information Clearinghouse.

5.1. Simple and Compound Statements - Sequences of Statements


A statement is either simple or compound. A simple statement encloses no other statement. A compound statement can enclose simple statements and other compound statements.

    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_call_statement
       | delay_statement      | abort_statement
       | raise_statement      | code_statement 

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

    label ::= <<label_simple_name>> 

    null_statement ::= null;   

A statement is said to be labeled by the label name of any label of the statement. A label name, and similarly a loop or block name, is implicitly declared at the end of the declarative part of the innermost block statement, subprogram body, package body, task body, or generic body that encloses the labeled statement, the named loop statement, or the named block statement, as the case may be. For a block statement without a declarative part, an implicit declarative part (and preceding declare) is assumed.

The implicit declarations for different label names, loop names, and block names occur in the same order as the beginnings of the corresponding labeled statements, loop statements, and block statements. Distinct identifiers must be used for all label, loop, and block names that are implicitly declared within the body of a program unit, including within block statements enclosed by this body, but excluding within other enclosed program units (a program unit is either a subprogram, a package, a task unit, or a generic unit).

Execution of a null statement has no other effect than to pass to the next action.

The execution of a sequence of statements consists of the execution of the individual statements in succession until the sequence is completed, or a transfer of control takes place. A transfer of control is caused either by the execution of an exit, return, or goto statement; by the selection of a terminate alternative; by the raising of an exception; or (indirectly) by the execution of an abort statement.

Examples of labeled statements:

    <<HERE>> <<ICI>> <<AQUI>> <<HIER>> null; 

    <<AFTER>> X := 1;


The scope of a declaration starts at the place of the declaration itself (see 8.2). In the case of a label, loop, or block name, it follows from this rule that the scope of the implicit declaration starts before the first explicit occurrence of the corresponding name, since this occurrence is either in a statement label, a loop statement, a block statement, or a goto statement. An implicit declaration in a block statement may hide a declaration given in an outer program unit or block statement (according to the usual rules of hiding explained in section 8.3).

References: abort statement, accept statement, assignment statement, block name, block statement, case statement, code statement, declaration, declarative part, delay statement, entry call statement, exception, exit statement, generic body, generic unit, goto statement, hiding, identifier, if statement, implicit declaration, loop name, loop statement, package, package body, procedure call statement, program unit, raise statement, raising of exceptions, return statement, scope, select statement, simple name, subprogram, subprogram body, task, task body, task unit, terminate alternative, terminated task.

Rationale references: 2.2 Textual Structure, 3.7 Statements

Style Guide references: 5.6.1 Nesting


[Ada Information Clearinghouse]

Address any questions or comments to