|
|
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: 3444 (0xd74)
Types: TextFile
Names: »B«
└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11
└─⟦129cab021⟧ »DATA«
└─⟦this⟧
with Bounded_String;
with Error_Broadcaster;
with Lex;
with Object;
with Bloc;
with Bloc_Class;
with Value;
with Unparser;
package body Primary is
type Node_Structure is
record
Rule : Natural range 0 .. 3 := 0;
Ident : Object.Message;
Bl : Bloc.Node := Bloc.Empty_Node;
Val : Value.Node := Value.Empty_Node;
Obj : Object.Reference := Object.Void_Reference;
end record;
procedure Parse (N : in out Node; Error : out Boolean) is
Failed : Boolean := False;
begin
N := new Node_Structure;
case Lex.Get_Token is
when Lex.Open_Bracket =>
N.Rule := 0;
N.Obj := Object.Create (Lex.Get_Token, Lex.Get_Value);
Bloc.Parse (N.Bl, Failed);
when Lex.Integer =>
N.Rule := 1;
N.Obj := Object.Create (Lex.Get_Token, Lex.Get_Value);
Lex.Next_Token;
when Lex.Tiny_String =>
N.Rule := 1;
N.Obj := Object.Create (Lex.Get_Token, Lex.Get_Value);
Lex.Next_Token;
when Lex.Identifier =>
N.Rule := 2;
Bounded_String.Copy (N.Ident, Lex.Get_Value);
Lex.Next_Token;
when Lex.Open_Parenthesis =>
N.Rule := 3;
Lex.Next_Token;
Value.Parse (N.Val, Failed);
if Lex.Token'Pos (Lex.Get_Token) =
Lex.Token'Pos (Lex.Close_Parenthesis) then
Lex.Next_Token;
else
raise Error_Broadcaster.Parenthesis_Is_Missing;
end if;
when Lex.Avec | Lex.Binary_Message | Lex.Key_Word |
Lex.L_End | Lex.Ok | Lex.Pour | Lex.Prendre |
Lex.Renvoyer | Lex.Special | Lex.Close_Parenthesis |
Lex.Unknown | Lex.Dot | Lex.Close_Bracket =>
raise Error_Broadcaster.Unexpected_Token;
end case;
Error := Failed;
end Parse;
procedure Unparse (N : in out Node) is
begin
case N.Rule is
when 0 =>
Bloc.Unparse (N.Bl);
when 1 =>
Unparser.Put (N.Obj.Identity);
when 2 =>
Unparser.Put (Bounded_String.Image (N.Ident));
Unparser.Put (" ");
when 3 =>
Unparser.Put ("(");
Value.Unparse (N.Val);
Unparser.Put (") ");
end case;
end Unparse;
function Is_First (T : Lex.Token) return Boolean is
use Lex;
begin
return T = Lex.Integer or else T = Lex.Tiny_String or else
T = Lex.Identifier or else
T = Lex.Open_Parenthesis or else Bloc.Is_First (T);
end Is_First;
function Interpret (N : Node;
Inherited : Object.Reference := Object.Void_Reference)
return Object.Reference is
Result : Object.Reference;
begin
case N.Rule is
when 0 =>
Result := N.Obj;
when 1 =>
Result := N.Obj;
when 2 =>
Result := Bloc_Class.Get (N.Ident);
when 3 =>
Result := Value.Interpret (N.Val, Result);
end case;
return Result;
end Interpret;
end Primary;