sequence_of_statements ::= statement {statement}
statement ::= {label} simple_statement | {label} compound_statement
simple_statement ::= null_statement | assignment_statement | exit_statement | goto_statement | procedure_call_statement | return_statement | entry_call_statement | requeue_statement | delay_statement | abort_statement | raise_statement | code_statement
compound_statement ::= if_statement | case_statement | loop_statement | block_statement | accept_statement | select_statement
null_statement ::= null;
label ::= <<label_statement_identifier>>
statement_identifier ::= direct_name
Name Resolution Rules
<<Here>> <<Ici>> <<Aqui>> <<Hier>> null;
<<After>> X := 1;
assignment_statement ::= variable_name := expression;
Value := Max_Value - 1; Shade := Blue;
Next_Frame(F)(M, N) := 2.5; -- see section Indexed Components U := Dot_Product(V, W); -- see section Subprogram Bodies
Writer := (Status => Open, Unit => Printer, Line_Count => 60); -- see section Variant Parts and Discrete Choices Next_Car.all := (72074, null); -- see section Incomplete Type Declarations
I, J : Integer range 1 .. 10 := 5; K : Integer range 1 .. 20 := 15; ...
I := J; -- identical ranges K := J; -- compatible ranges J := K; -- will raise Constraint_Error if K > 10
A : String(1 .. 31); B : String(3 .. 33); ...
A := B; -- same number of components
A(1 .. 9) := "tar sauce"; A(4 .. 12) := A(1 .. 9); -- A(1 .. 12) = "tartar sauce"NOTES
if_statement ::= if condition then sequence_of_statements {elsif condition then sequence_of_statements} [else sequence_of_statements] end if;
condition ::= boolean_expressionName Resolution Rules
if Month = December and Day = 31 then Month := January; Day := 1; Year := Year + 1; end if;
if Line_Too_Short then raise Layout_Error; elsif Line_Full then New_Line; Put(Item); else Put(Item); end if;
if My_Car.Owner.Vehicle /= My_Car then -- see section Incomplete Type Declarations Report ("Incorrect data"); end if;
case_statement ::= case expression is case_statement_alternative {case_statement_alternative} end case;
case_statement_alternative ::= when discrete_choice_list => sequence_of_statementsName Resolution Rules
case Sensor is when Elevation => Record_Elevation(Sensor_Value); when Azimuth => Record_Azimuth (Sensor_Value); when Distance => Record_Distance (Sensor_Value); when others => null; end case;
case Today is when Mon => Compute_Initial_Balance; when Fri => Compute_Closing_Balance; when Tue .. Thu => Generate_Report(Today); when Sat .. Sun => null; end case;
case Bin_Number(Count) is when 1 => Update_Bin(1); when 2 => Update_Bin(2); when 3 | 4 => Empty_Bin(1); Empty_Bin(2); when others => raise Error; end case;
loop_statement ::= [loop_statement_identifier:] [iteration_scheme] loop sequence_of_statements end loop [loop_identifier];
iteration_scheme ::= while condition | for loop_parameter_specification
loop_parameter_specification ::= defining_identifier in [reverse] discrete_subtype_definition
Static Semantics
for J in reverse 1 .. 0 for J in 0 .. 1Examples
loop Get(Current_Character); exit when Current_Character = '*'; end loop;
while Bid(N).Price < Cut_Off.Price loop Record_Bid(Bid(N).Price); N := N + 1; end loop;
for J in Buffer'Range loop -- works even with a null range if Buffer(J) /= Space then Put(Buffer(J)); end if; end loop;
Summation: while Next /= Head loop -- see section Incomplete Type Declarations Sum := Sum + Next.Value; Next := Next.Succ; end loop Summation;
block_statement ::= [block_statement_identifier:] [declare declarative_part] begin handled_sequence_of_statements end [block_identifier];
Static Semantics
Swap: declare Temp : Integer; begin Temp := V; V := U; U := Temp; end Swap;
exit_statement ::= exit [loop_name] [when condition];Name Resolution Rules
for N in 1 .. Max_Num_Items loop Get_New_Item(New_Item); Merge_Item(New_Item, Storage_File); exit when New_Item = Terminal_Item; end loop;
Main_Cycle: loop -- initial statements exit Main_Cycle when Found; -- final statements end loop Main_Cycle;
goto_statement ::= goto label_name;Name Resolution Rules
<<Sort>> for I in 1 .. N-1 loop if A(I) > A(I+1) then Exchange(A(I), A(I+1)); goto Sort; end if; end loop;
Go to the first, previous, next, last section, table of contents.