separate (Find_Unit.Build_Ada_Compilation_Unit)
procedure Package_Spec (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  =
    -- a package specification. This procedure will parse any      =
    -- nested compilation unit, while searching for the end of the =
    -- package specification. If the end is found, then another    =
    -- subprogram End_Unit will finnish off the parsing. If a      =
    -- syntax error is found, then the exception Build_Syntax_Error=
    -- will be raised.                                             =
    -- The grammar :                                               =
    --     <Package_Spec> =                                        =
    --         * {<Declaration> *} <End_Unit>                      =
    --                                                             =
    -- 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
    Peek_Token : Token_Package.Token;
    -- A token that will later be gotten by
    -- Get_Next_Significant_Token
    End_Found : Boolean := False;
    -- Set to true when the end of package specification is found

begin
    -- Package_Spec

    -- Set the peek back to the beginning

    Token_Package.Set_Peek_Back;

    -- Parse tokens until the end of the package specification
    -- is found. Any nested compilation units will cause the
    -- subprogram End_Unit to be invoked

    Search_For_End:
        loop

            -- Peek at the next significant token

            Peek_Next_Significant_Token (Significant_Token => Peek_Token);

            -- Is there a nested compilation unit ?

            case Token_Package.Value_Of (Peek_Token) is
                when Token_Package.Package_Token | Token_Package.Generic_Token |
                     Token_Package.Task_Token | Token_Package.Procedure_Token |
                     Token_Package.Function_Token =>
                    Declaration (Current_Unit => Current_Unit);
                when Token_Package.End_Token =>

                    -- See if this is really the end of compilation unit or
                    -- just a 'end record'

                    Peek_Next_Significant_Token
                       (Significant_Token => Peek_Token);

                    if Token_Package.Value_Of (Peek_Token) =
                       Token_Package.Semicolon_Token or
                       Token_Package.Class_Of (Peek_Token) =
                          Token_Package.Identifier then
                        End_Found := True;
                    else
                        -- Not the end of the compilation unit yet
                        Get_Next_Significant_Token
                           (Significant_Token => Current_Token,
                            Current_Unit => Current_Unit);
                        Compilation_Unit.Add_Token_To_Compilation_Unit
                           (Token_To_Add => Current_Token,
                            Unit_To_Add_To => Current_Unit);
                    end if;

                when others =>
                    -- Just get the next significant token
                    Get_Next_Significant_Token
                       (Significant_Token => Current_Token,
                        Current_Unit => Current_Unit);
                    Compilation_Unit.Add_Token_To_Compilation_Unit
                       (Token_To_Add => Current_Token,
                        Unit_To_Add_To => Current_Unit);
            end case;

            if Token_Package.Class_Of (Current_Token) =
               Token_Package.End_Of_File then
                raise Build_Syntax_Error;
            end if;

            exit Search_For_End when End_Found;
        end loop Search_For_End;

    End_Unit (Current_Unit => Current_Unit);

end Package_Spec;