separate (Find_Unit.Build_Ada_Compilation_Unit)
procedure Package_Unit_Tail (Current_Unit : in out
                                Compilation_Unit.Ada_Compilation_Unit) is
    --==============================================================
    -- This procedure builds the next part of the grammar for an   =
    -- Ada compilation unit. Based on the next token, we will      =
    -- complete different productions. At present, we are parsing  =
    -- either a package specification, package body, or a generic  =
    -- package instantiation. This procedure determines whether    =
    -- we are parsing a package body. This is done by checking to  =
    -- see if the next keyword is the keyword 'Body'. If a syntax  =
    -- error is found, then the exception Build_Syntax_Error will  =
    -- be raised.                                                  =
    -- The grammar :                                               =
    --     <Package_Unit_Tail> =                                   =
    --         'BODY' <id> 'IS' <Package_Body> |                   =
    --         <id> 'IS' <Package_Spec_Or_Instantiation>           =
    --                                                             =
    -- written  by  GER  with  help  from  b2  and  JM             =
    -- May 1985  at EVB Software Engineering                       =
    --==============================================================

    Current_Token : Token_Package.Token;
    -- the current token read from the ada source code file

begin
    -- Package_Unit_Tail

    -- Get the next significant token to see if it is 'Package'

    Get_Next_Significant_Token (Significant_Token => Current_Token,
                                Current_Unit => Current_Unit);

    case Token_Package.Value_Of (Current_Token) is
        when Token_Package.Body_Token =>

            -- Found the start of a package body

            Compilation_Unit.Add_Token_To_Compilation_Unit
               (Token_To_Add => Current_Token, Unit_To_Add_To => Current_Unit);

            -- Get the package name identifier

            Get_Next_Significant_Token (Significant_Token => Current_Token,
                                        Current_Unit => Current_Unit);

            if Token_Package.Class_Of (Current_Token) =
               Token_Package.Identifier then
                Compilation_Unit.Add_Token_To_Compilation_Unit
                   (Token_To_Add => Current_Token,
                    Unit_To_Add_To => Current_Unit);
            else
                -- Not the package name identifier
                raise Build_Syntax_Error;
            end if;

            -- Get the package body 'is'

            Get_Next_Significant_Token (Significant_Token => Current_Token,
                                        Current_Unit => Current_Unit);

            if Token_Package.Value_Of (Current_Token) =
               Token_Package.Is_Token then
                Compilation_Unit.Add_Token_To_Compilation_Unit
                   (Token_To_Add => Current_Token,
                    Unit_To_Add_To => Current_Unit);
            else
                -- Not the 'is' that goes with the package body
                raise Build_Syntax_Error;
            end if;

            Package_Body (Current_Unit => Current_Unit);
        when others =>

            if Token_Package.Class_Of (Current_Token) =
               Token_Package.Identifier then
                Compilation_Unit.Add_Token_To_Compilation_Unit
                   (Token_To_Add => Current_Token,
                    Unit_To_Add_To => Current_Unit);

                -- Get the keyword 'is'

                Get_Next_Significant_Token (Significant_Token => Current_Token,
                                            Current_Unit => Current_Unit);
                if Token_Package.Value_Of (Current_Token) =
                   Token_Package.Is_Token then
                    Compilation_Unit.Add_Token_To_Compilation_Unit
                       (Token_To_Add => Current_Token,
                        Unit_To_Add_To => Current_Unit);
                else
                    -- Not a package specification or instantiation
                    raise Build_Syntax_Error;
                end if;

            else
                -- Not a package, raise error
                raise Build_Syntax_Error;
            end if;

            Package_Spec_Or_Instantiation (Current_Unit => Current_Unit);
    end case;

end Package_Unit_Tail;