separate (Find_Unit.Build_Ada_Compilation_Unit)
procedure Generic_Unit (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 generic. We must first of all find the keyword generic.   =
    -- We will then search for the beginning of the generic        =
    -- specification part, keeping a look out for formal generic   =
    -- subprogram parameters. If a syntax error is detected, then  =
    -- we will raise Build_Syntax_Error.                           =
    -- The grammar :                                               =
    --     <Generic_Unit> =                                        =
    --         'GENERIC' * {'WITH' <Generic_Parm_Declaration> * }  =
    --         <Generic_Unit_Spec>                                 =
    --                                                             =
    -- 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
    Found_Generic_Spec : Boolean := False;
    -- Set to true when the start of the generic specification
    -- is found
    Peek_Token : Token_Package.Token;
    -- This token will be gotten later by Get_Next_Signicant_Token

begin
    -- Generic_Unit

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

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

    case Token_Package.Value_Of (Current_Token) is
        when Token_Package.Generic_Token =>
            Compilation_Unit.Add_Token_To_Compilation_Unit
               (Token_To_Add => Current_Token, Unit_To_Add_To => Current_Unit);
        when others =>
            raise Build_Syntax_Error;
    end case;

    Search_For_Spec:
        loop
            Peek_Next_Significant_Token (Significant_Token => Peek_Token);

            case Token_Package.Value_Of (Peek_Token) is
                when Token_Package.With_Token =>

                    -- Found a formal generic subprogram parameter

                    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);
                    Generic_Parm_Declaration (Current_Unit => Current_Unit);
                when Token_Package.Procedure_Token |
                     Token_Package.Function_Token |
                     Token_Package.Package_Token =>

                    -- Found the start of generic specification

                    Found_Generic_Spec := True;
                when others =>
                    Get_Next_Significant_Token
                       (Significant_Token => Current_Token,
                        Current_Unit => Current_Unit);

                    if Token_Package.Class_Of (Current_Token) =
                       Token_Package.End_Of_File then
                        raise Build_Syntax_Error;
                    else
                        Compilation_Unit.Add_Token_To_Compilation_Unit
                           (Token_To_Add => Current_Token,
                            Unit_To_Add_To => Current_Unit);
                    end if;

            end case;

            exit Search_For_Spec when Found_Generic_Spec;
        end loop Search_For_Spec;

    Generic_Unit_Spec (Current_Unit => Current_Unit);

end Generic_Unit;