separate (Compilation_Unit.Produce_Metrics)
procedure Exception_Handler
             (Current_Compilation_Unit : in out Ada_Compilation_Unit;
              Program_Unit : in Program_Unit_State_Machine;
              Halstead : in Halstead_State_Machine;
              Loc : in Loc_State_Machine;
              Mccabe : in Mccabe_State_Machine) is

    --=================================================================
    -- EXCEPTION that occurs in the executable part of a program unit
    -- counts as one Halstead operand count.

    -- Exception_Handler ::=
    --      "EXCEPTION"
    --         $ 2nd token = "OTHERS" $
    --         1. Last_Exception_Choice
    --         2. Exception_Choice { Exception_Choice }
    --            [ Last_Exception_Choice ]
    --=================================================================

    No_More_Choices : Boolean := False;
    Current_Token : Token_Package.Token;

begin
    -- Exception_Handler

    Get_Next_Token (Out_Token => Current_Token,
                    From => Current_Compilation_Unit,
                    Current_Loc => Loc);

    if "/=" (Token_Package.Value_Of (Current_Token),
             Token_Package.Exception_Token) then
        raise Syntax_Error;
    end if;

    -- increment Halstead EXCEPTION operator count
    Halstead.Store_Operator ((Kind => Halstead_Operator.Exception_Halstead));

    -- increment McCabe PI
    Mccabe.Change_Pi;

    if Token_Package.Value_Of
          (Peek (From => Current_Compilation_Unit, Offset => 2)) =
       Token_Package.Others_Token then

        Last_Exception_Choice
           (Current_Compilation_Unit => Current_Compilation_Unit,
            Program_Unit => Program_Unit,
            Halstead => Halstead,
            Loc => Loc,
            Mccabe => Mccabe);

    else

        Process_Choices:
            -- repeat for every Choice
            loop

                Exception_Choice
                   (Current_Compilation_Unit => Current_Compilation_Unit,
                    Program_Unit => Program_Unit,
                    Halstead => Halstead,
                    Loc => Loc,
                    Mccabe => Mccabe);

                if Token_Package.Value_Of
                      (Peek (From => Current_Compilation_Unit)) =
                   Token_Package.When_Token then

                    if Token_Package.Value_Of
                          (Peek (From => Current_Compilation_Unit,
                                 Offset => 2)) = Token_Package.Others_Token then

                        Last_Exception_Choice (Current_Compilation_Unit =>
                                                  Current_Compilation_Unit,
                                               Program_Unit => Program_Unit,
                                               Halstead => Halstead,
                                               Loc => Loc,
                                               Mccabe => Mccabe);
                        No_More_Choices := True;

                    end if;

                else

                    No_More_Choices := True;

                end if;

                exit Process_Choices when No_More_Choices;

            end loop Process_Choices;

    end if;

end Exception_Handler;