DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: B T

⟦c13eb5e0c⟧ TextFile

    Length: 3567 (0xdef)
    Types: TextFile
    Names: »B«

Derivation

└─⟦180fe333a⟧ Bits:30000405 8mm tape, Rational 1000, SW CATALOG, 10_20_0
└─⟦180fe333a⟧ Bits:30000537 8mm tape, Rational 1000, SW Catalog 10_20_0
    └─⟦5cb1d1d7f⟧ »DATA« 
        └─⟦3b1ee7bd8⟧ 
            └─⟦this⟧ 

TextFile

separate (Compilation_Unit)
function Seek (Origin : in Ada_Compilation_Unit; Offset : in Integer)
              return Ada_Compilation_Unit is

    --================================================================
    -- Seek allows a user to seek forward or backward from current  ==
    -- Origin (values of Offset determines direction of Seek). If   ==
    -- a user tries to seek to a non-existent token, exception      ==
    -- SYNTAX_ERROR will be raised.                                 ==
    -- Seek will return the location of the Nth significant token   ==
    -- in front of/behind the current token location denoted by     ==
    -- Origin (N = Offset).                                         ==
    --================================================================

    -- Destination points to the location of the nth token
    -- in front of/behind the current token (n is equal to
    -- Offset). Destination is initialized to Origin.
    Destination : New_List.List;

    --** changed 9/26/85 by J. Margono
    --** reason: see below
    -- Repetitions contains current number of iterations left
    -- left to be performed.
    Repetitions : Natural;

    --** changed 11/15/85 by J. Margono
    --** reason: efficiency
    Step : Integer;

begin
    -- Seek

    --** changed 11/13/85 by J. Margono
    --** reason: assignment is now allowed because List is of type PRIVATE
    -- copy the origin into Destination
    Destination := New_List.List (Origin);

    -- find where the last significant token is
    Find_Last_Significant_Token:
        loop

            -- move at least one token backward
            Destination := New_List.Seek (Origin => Destination, Offset => -1);

            case Token_Package.Class_Of (New_List.Content_Of (Destination)) is

                when Token_Package.Blank_Line |
                     Token_Package.Comment | Token_Package.New_Line =>
                    null; -- skip non-significant token

                when others =>
                    -- found a significant token
                    exit;

            end case;

        end loop Find_Last_Significant_Token;

    --** changed 9/26/85 by J. Margono
    --** reason: Seek(Origin,0) is now equal to Seek(Origin,1)
    -- determine number of repetitions and step
    if Offset = 0 then

        -- find the next significant token
        Repetitions := 1;
        Step := +1;

    elsif Offset > 0 then

        Repetitions := Offset;
        Step := +1;

    else
        -- Offset < 0

        Repetitions := (abs Offset) - 1;
        Step := -1;

    end if;

    Find_Destination:
        while Repetitions > 0 loop

            --** changed 11/13/85 by J. Margono
            --** reason: assignment is now allowed because List is
            --**         of type PRIVATE
            -- direction of seek is determined by Step (backward or forward)
            Destination := New_List.Seek
                              (Origin => Destination, Offset => Step);

            case Token_Package.Class_Of (New_List.Content_Of (Destination)) is

                when Token_Package.Blank_Line |
                     Token_Package.Comment | Token_Package.New_Line =>
                    null; -- skip non-significant token

                when others =>
                    -- found a significant token
                    Repetitions := Repetitions - 1;

            end case;

        end loop Find_Destination;

    return Ada_Compilation_Unit (Destination);

exception
    when New_List.Overflow =>
        raise Syntax_Error;

end Seek;