|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 9216 (0x2400)
Types: Ada Source
Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Automate, seg_042ce0, separate Lex
└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
└─⟦cfc2e13cd⟧ »Space Info Vol 2«
└─⟦this⟧
separate (Lex)
------------------------------------------------------------------------
-- <UNIT> AUTOMATE
------------------------------------------------------------------------
--
-- <DESCRIPTION> This package defines operations for lexicaly
-- parsing characters from a stream.
--
-- <AUTHOR> Barthe Raphael, Beck Didier, Kempe Laurent
-- <VERSION> 1.0
-- <DATE> 12-Jan-95
-- <MODIFY> 12-Jan-95
--
-- <PKG USED> Bounded_String, Token_Pkg
--
------------------------------------------------------------------------
package body Automate is
type States is (St_Normal, St_Str, St_Str_End, St_Minus,
St_Comment, St_Ident, St_Integer);
subtype End_Of_Line_Character is Character range Ascii.Lf .. Ascii.Cr;
Currentvalue : Bounded_String.Variable_String (128);
function Get return Bounded_String.Variable_String is
--------------------------------------------------------------------------------
-- <SUBPROGRAM>
-- <UNIT> Get
--
-- <DESCRIPTION> Return the string read during the lexical analyse.
--
-- <EXCEPTIONS> Nothing
--
--------------------------------------------------------------------------------
begin
return Currentvalue;
end Get;
function Start return Token is
--------------------------------------------------------------------------------
-- <SUBPROGRAM>
-- <UNIT> Next
--
-- <DESCRIPTION> Read the next lexical word from the stream.
--
-- <EXCEPTIONS> Nothing
--
--------------------------------------------------------------------------------
C : Character;
State : States := St_Normal;
begin
Bounded_String.Free (Currentvalue);
if not File.Atend then
State := St_Normal;
loop
if not File.Atend then
File.Next (Thefile);
C := File.Getvalue;
else
C := Ascii.Eot;
end if;
case State is
when St_Normal =>
case C is
when Ascii.Eot =>
return T_Eof;
when Ascii.Cr | ' ' =>
null;
when '"' =>
State := St_Str;
when '=' =>
return T_Equ;
when '+' =>
return T_Add;
when '*' =>
return T_Mul;
when '/' =>
return T_Div;
when '(' =>
return T_Obracket;
when ')' =>
return T_Cbracket;
when '-' =>
State := St_Minus;
when ',' =>
return T_Comma;
when ':' =>
return T_Colon;
when 'a' .. 'z' | 'A' .. 'Z' =>
Bounded_String.Append (Currentvalue, C);
State := St_Ident;
when '0' .. '9' =>
Bounded_String.Append (Currentvalue, C);
State := St_Integer;
when others =>
return T_Unk;
end case;
when St_Ident =>
case C is
when 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' =>
Bounded_String.Append (Currentvalue, C);
when others =>
File.Unget;
return T_Ident;
end case;
when St_Str =>
if C = '"' then
State := St_Str_End;
else
Bounded_String.Append (Currentvalue, C);
end if;
when St_Str_End =>
return T_String;
when St_Integer =>
case C is
when '0' .. '9' =>
Bounded_String.Append (Currentvalue, C);
when others =>
File.Unget;
return T_Integer;
end case;
when St_Minus =>
if (C = '-') then
State := St_Comment;
else
File.Unget;
return T_Sub;
end if;
when St_Comment =>
if C in End_Of_Line_Character then
State := St_Normal;
end if;
end case;
end loop;
else
return T_Eof;
end if;
end Start;
end Automate;
-------------------------------------------------
-- PROGRAMME DE TEST DE L'ANALYSEUR SYNTAXIQUE --
-------------------------------------------------
-- NOM : TEST_LEX
-- Packages necessaires : LEX, TEXT_IO, Bounded_String, Token_Pkg
nblk1=8
nid=0
hdr6=10
[0x00] rec0=1c rec1=00 rec2=01 rec3=056
[0x01] rec0=01 rec1=00 rec2=07 rec3=00c
[0x02] rec0=23 rec1=00 rec2=02 rec3=01a
[0x03] rec0=19 rec1=00 rec2=03 rec3=028
[0x04] rec0=06 rec1=00 rec2=08 rec3=060
[0x05] rec0=16 rec1=00 rec2=04 rec3=02e
[0x06] rec0=1a rec1=00 rec2=05 rec3=052
[0x07] rec0=12 rec1=00 rec2=06 rec3=000
tail 0x21743953e863080413c77 0x42a00088462060003