with Reserved_Words;
separate (Token_Package)
procedure Build (New_Token : out Token; Previous_Token : in Token) is
    --==============================================================
    -- This procedure builds a New_Token from the standard input. ==
    --==============================================================

    Current_State : State := Start;
    Current_Token : Token;
    Present_Buffer : Buffer_Value;

begin
    -- Build

    Build_Token:
        loop

            Receive_Symbol (Current_State => Current_State,
                            Current_Token => Current_Token,
                            Previous_Token => Previous_Token,
                            Present_Buffer => Present_Buffer);

            exit Build_Token when Current_State = Stop;

            -- get the next character
            Source_Io.Get (Item => Current_Character);

        end loop Build_Token;

    case Current_Token.Content.Class is

        when Identifier .. Character_Literal =>
            Current_Token.Content.String_Value :=
               (Length => Present_Buffer.Length,
                Content => Present_Buffer.Content (1 .. Present_Buffer.Length));

        when others =>
            null;

    end case;

    -- check whether identifier is an Ada keyword or not
    if Current_Token.Content.Class = Identifier and
       Reserved_Words.Is_Keyword (Value_Of (Current_Token)) then

        -- found a keyword
        Label (This_Token => New_Token, With_This_Class => Keyword);
        New_Token.Content.String_Value := Current_Token.Content.String_Value;

    else

        New_Token := Current_Token;

    end if;


end Build;