|
|
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: 3166 (0xc5e)
Types: TextFile
Names: »B«
└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11
└─⟦129cab021⟧ »DATA«
└─⟦this⟧
with Scanner;
with Object;
with Symbols;
with Value, Block;
with Class_Integer, Class_String, Class_Block;
with Bounded_String;
package body Primary is
type Node_Structure is
record
Rule : Natural range 0 .. 4 := 0;
Obj : Object.Reference := Object.Void_Reference;
Ident : Object.Unary;
Val : Value.Node := Value.Empty_Node;
Blk : Block.Node := Block.Get_Current_Node;
end record;
procedure Parse (N : in out Node; Error : out Boolean) is
Failed : Boolean := False;
begin
N := new Node_Structure;
case Scanner.Get_Token is
when Scanner.Integer =>
N.Rule := 0;
N.Obj := Class_Integer.Value (Scanner.Get_Value);
Scanner.Next;
when Scanner.String =>
N.Rule := 1;
N.Obj := Class_String.Create (Scanner.Get_Value);
Scanner.Next;
when Scanner.Identifier =>
N.Rule := 2;
Object.Put (Scanner.Get_Value, N.Ident);
Scanner.Next;
when Scanner.Special =>
N.Rule := 3;
if Bounded_String.Image (Scanner.Get_Value) = "(" then
Scanner.Next;
Value.Parse (N.Val, Failed);
if not Failed and then
Bounded_String.Image (Scanner.Get_Value) = ")" then
Scanner.Next;
end if;
else
N.Rule := 4;
Block.Parse (N.Blk, Failed);
N.Obj := Class_Block.Create (Node => N.Blk);
end if;
when others =>
null;
end case;
Error := Failed;
end Parse;
function Is_First (T : Scanner.Token) return Boolean is
use Scanner;
begin
return T = Scanner.Integer or else T = Scanner.String or else
T = Scanner.Identifier or else
T = Scanner.Special or else Block.Is_First (T);
end Is_First;
function Interpret (N : Node) return Object.Reference is
Result : Object.Reference := Object.Void_Reference;
Success : Boolean := False;
Block_Node : Block.Node := N.Blk;
begin
case N.Rule is
when 0 =>
Result := N.Obj;
when 1 =>
Result := N.Obj;
when 2 =>
while not Block.Is_Nil (Block_Node) and not Success loop
Symbols.Get (Object_Named => Object.Get (N.Ident),
From => Block.Get_Table (Block_Node),
Into => Result,
Status => Success);
if not Success then
Block_Node := Block.Get_Parent (Block_Node);
end if;
end loop;
when 3 =>
Result := Value.Interpret (N.Val);
when 4 =>
Result := N.Obj;
end case;
return Result;
end Interpret;
end Primary;