|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: B T
Length: 2320 (0x910)
Types: TextFile
Names: »B«
└─⟦bfaa708f6⟧ Bits:30000531 8mm tape, Rational 1000, INSIGHT 1_3_0
└─⟦c51948655⟧ »DATA«
└─⟦266b31e86⟧
└─⟦this⟧
function Next_Token_Scanner return String is
-- global parameters: Buffer, Buffer_Index
Token_Start : Natural;
Next_Char : Character;
Quote : constant Character := '"';
begin
while Buffer_Index <= Buffer'Last and then Buffer (Buffer_Index) = ' ' loop
Buffer_Index := Buffer_Index + 1;
end loop;
Token_Start := Buffer_Index;
if Buffer_Index > Buffer'Last then
return "";
end if;
if Buffer (Buffer_Index) = Quote then
-- quoted string token; look for ending Quote
Buffer_Index := Buffer_Index + 1; -- point to 1st string char
Token_Start := Buffer_Index;
while Buffer_Index <= Buffer'Last loop
Next_Char := Buffer (Buffer_Index);
Buffer_Index := Buffer_Index + 1;
if Next_Char = Quote then
-- if 2 quotes in a row; treat as one quote
-- single quote; end of token
if Buffer_Index > Buffer'Last or else
Buffer (Buffer_Index) /= Quote then
-- Just one quote. Done
return Buffer (Token_Start .. Buffer_Index - 1);
else
-- Got 2 quotes!
-- Shift array left 1. Leave Buffer_Index
-- at char past double-"
Buffer (Buffer_Index .. Buffer'Last - 1) :=
Buffer (Buffer_Index + 1 .. Buffer'Last);
end if;
end if;
end loop;
-- open but no matching quote
return Buffer (Token_Start .. Buffer'Last);
else
while Buffer_Index <= Buffer'Last loop
-- regular case; just eat chars till delimiter
Next_Char := Buffer (Buffer_Index);
Buffer_Index := Buffer_Index + 1;
case Next_Char is
when '!' .. '~' => -- all printing characters
null;
when others =>
exit;
end case;
end loop;
if Buffer_Index > Buffer'Last then
return Buffer (Token_Start .. Buffer'Last);
else
return Buffer (Token_Start .. Buffer_Index -
2); -- delim + incremented again
end if;
end if;
end Next_Token_Scanner;