|
|
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: 3829 (0xef5)
Types: TextFile
Names: »B«
└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11
└─⟦129cab021⟧ »DATA«
└─⟦this⟧
with Bounded_String;
with Object;
with Msg_Report;
with Scanner;
with Symbol_Table;
with String_Utilities;
with Unparse_Report;
with Value;
package body Expression is
function Bs_Image (A_String : Scanner.B_String) return String
renames Bounded_String.Image;
procedure Bs_Copy (A_String : in out Scanner.B_String; A_Value : String)
renames Bounded_String.Copy;
function Su_Capitalize (A_String : String) return String
renames String_Utilities.Capitalize;
type Node_Structure is
record
Rule : Natural range 0 .. 1 := 0;
Valu : Value.Node := Value.Empty_Node;
Iden : Scanner.B_String;
Lign : Integer;
end record;
procedure Parse (N : in out Node; Error : out Boolean) is
use Scanner;
Failed : Boolean := False;
begin
Msg_Report.Information ("I enter in expression's parse");
N := new Node_Structure;
N.Lign := Scanner.Line_Number;
if (Scanner.Symbol = L_Pour) then
Scanner.Next;
if Scanner.Symbol = L_Identifier then
Bs_Copy (N.Iden, Scanner.Value);
Scanner.Next;
if Scanner.Symbol = L_Prendre then
Scanner.Next;
if Value.Is_First (Scanner.Symbol) then
Value.Parse (N.Valu, Failed);
else
Failed := True;
Msg_Report.Syntax_Error
("incorrect follow of PRENDRE : ");
end if;
else
Failed := True;
Msg_Report.Syntax_Error ("POUR expected, incorrect");
end if;
else
Failed := True;
Msg_Report.Syntax_Error ("incorrect follow of POUR : ");
end if;
else
N.Rule := 1;
Value.Parse (N.Valu, Failed);
end if;
Msg_Report.Information ("I leave expression's parse with failed = " &
Boolean'Image (Failed));
Error := Failed;
end Parse;
procedure Unparse (N : Node) is
begin
case N.Rule is
when 0 =>
Unparse_Report.Write ("POUR ");
Unparse_Report.Write (Su_Capitalize (Bs_Image (N.Iden)) & " ");
Unparse_Report.Write ("PRENDRE ");
Value.Unparse (N.Valu);
when 1 =>
Value.Unparse (N.Valu);
end case;
end Unparse;
function Is_First (T : Scanner.Token) return Boolean is
use Scanner;
begin
return T = L_Pour or else Value.Is_First (T);
end Is_First;
function Interpret (N : Node;
Inherited : Object.Reference := Object.Void_Reference)
return Object.Reference is
Result : Object.Reference;
begin
Msg_Report.Information ("I enter in expression's interpret");
Msg_Report.Set_Line_Number (N.Lign);
case N.Rule is
when 0 =>
Result := Value.Interpret (N.Valu);
if Symbol_Table.Is_Found (N.Iden) then
Symbol_Table.Set_Info (N.Iden, Result);
else
Symbol_Table.Insert (N.Iden, Result);
end if;
when 1 =>
Result := Value.Interpret (N.Valu);
end case;
Msg_Report.Information ("I leave expression's interpret with result :");
Msg_Report.Continue
("class = " & Object.Class'Image (Object.The_Class (Result)) &
" ident = " & Integer'Image (Object.Identificator (Result)));
return Result;
end Interpret;
end Expression;