8.11 EXIT

...
ENTITY e IS
    ...
BEGIN
    ...
END e ;

...
ARCHITECTURE a OF e IS
    ...
BEGIN
    ...
END a ;

...
CONFIGURATION c
        OF e IS
    ...
    ...
    ...
END

...
PACKAGE pkg IS
    ...
    ...
    ...
END pkg ;


exit_statement ::=
[ label : ]
exit [ loop _label ] [ when condition ] ;

..
PACKAGE BODY pck
        IS
    ...
    ...
    ...
END pck ;

...
b: BLOCK IS
    ...
BEGIN
    ...
END BLOCK b ;

FUNCTION f (...)
    RETURN r IS
    ...
BEGIN
    ...
END f ;

PROCEDURE p (...) IS
    ...
BEGIN
    ...
END p ;

p : PROCESS
    ...
BEGIN
    ...
END PROCESS p ;

8.11.1 Further definitions

label ::= identifier

condition ::= boolean _expression

8.11.2 Examples

LOOP
   EXIT WHEN value = 0 ;
   tab( value ) := value REM 2 ;
   value := value / 2 ;
END LOOP ;


In both cases the loops are left with
the EXIT -statement if value = 0 .


In the first example this is achieved by a conditional
NEXT -statement, whereas in the second example an
unconditional NEXT -statement has been integrated
into an IF -loop.

LOOP
   IF value = 0 THEN
      EXIT ;
   END IF ;
   tab( value ) := value REM 2 ;
   value := value / 2 ;
END LOOP ;
lbl_1 : FOR i IN 10 DOWNTO 2 LOOP
   lbl_2 : FOR j IN 0 TO i LOOP
      EXIT lbl_2 WHEN i = j ;
      table ( i, j ) := i + j - 7 ;
   END LOOP lbl_2 ;
END LOOP lbl_1 ;



These are two examples of chained FOR -loops which
are need to calculate the values of the elements of a
two-dimensional array.



In the first example the inner loop is left if i = j .
In the second example the outer loop is left if i = j .

lbl_1 : FOR i IN 10 DOWNTO 2 LOOP
   lbl_2 : FOR j IN 0 TO i LOOP
      EXIT lbl_1 WHEN i = j ;
      table ( i, j ) := i + j - 7 ;
   END LOOP lbl_2 ;
END LOOP lbl_1 ;