separate (Find_Unit.Build_Ada_Compilation_Unit)
procedure Begin_Statement (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 the statement section of a block. We must first see =
    -- the keyword 'Begin'. Next we will search for either the end =
    -- of the block, an accept statement, or a nested block        =
    -- statement (a nested compilation unit which will be cause a  =
    -- recursion in the grammar). The exception Build_Syntax_Error =
    -- will be raised if 'Begin' is not the first keyword found.   =
    -- Grammar :                                                   =
    --         <Begin_Statement> =                                 =
    --            'BEGIN' * {<Statement> * }                       =
    --                                                             =
    -- Written  by  GER  with  help  from  b2  and  JM             =
    -- May 1985  EVB Software Engineering Inc.                     =
    --==============================================================

    Current_Token : Token_Package.Token;
    -- Holds the current token
    Peek_Token : Token_Package.Token;
    End_Found : Boolean := False;
    -- Set to true when the end of the block is found

begin
    -- Begin_Statement

    -- Parse the "BEGIN" token

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

    if Token_Package.Value_Of (Current_Token) = Token_Package.Begin_Token then
        Compilation_Unit.Add_Token_To_Compilation_Unit
           (Token_To_Add => Current_Token, Unit_To_Add_To => Current_Unit);
    else
        -- Not the start of the statement block
        raise Build_Syntax_Error;
    end if;

    -- Repeatly get significant tokens until end of compilation unit

    Look_For_End_Of_Compilation_Unit:
        loop

            -- Peek at the next token in case it is the end, accept,
            -- or a block statement. If the loop is executed more than
            -- one time, then the peek is always set back to the beginning
            -- at this point in time.

            Peek_Next_Significant_Token (Significant_Token => Peek_Token);

            case Token_Package.Value_Of (Peek_Token) is
                when Token_Package.Declare_Token | Token_Package.Begin_Token |
                     Token_Package.Accept_Token =>
                    Statement (Current_Unit => Current_Unit);
                when Token_Package.End_Token =>

                    -- Make sure the end is not 'end if', 'end select', ...

                    Peek_Next_Significant_Token
                       (Significant_Token => Peek_Token);

                    if Token_Package.Value_Of (Peek_Token) =
                       Token_Package.Semicolon_Token then
                        End_Found := True;

                    elsif (Token_Package.Class_Of (Peek_Token) =
                           Token_Package.Identifier) or
                          (Token_Package.Class_Of (Peek_Token) =
                           Token_Package.Standard_String_Literal) or
                          (Token_Package.Class_Of (Peek_Token) =
                           Token_Package.Alternate_String_Literal) then
                        End_Found := True;

                    else
                        -- Not the end of the compilation unit
                        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 =>

                    -- Make sure there isn't a nested named block

                    if Token_Package.Class_Of (Peek_Token) =
                       Token_Package.Identifier then

                        -- Peek ahead twice to see if this is a named block

                        Peek_Next_Significant_Token
                           (Significant_Token => Peek_Token);
                        Peek_Next_Significant_Token
                           (Significant_Token => Peek_Token);

                        if Token_Package.Value_Of (Peek_Token) =
                           Token_Package.Declare_Token or
                           Token_Package.Value_Of (Peek_Token) =
                              Token_Package.Begin_Token then
                            Statement (Current_Unit => Current_Unit);
                        else
                            -- Not a nested named block statement
                            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 if;

                    else
                        -- Not a nested named block statement
                        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 if;

            end case;

            exit Look_For_End_Of_Compilation_Unit when End_Found;
        end loop Look_For_End_Of_Compilation_Unit;

end Begin_Statement;