-- PPTreeOps.Mesa
-- Russ Atkinson, June 8, 1982 3:15 pm

DIRECTORY
PPLeaves USING [Leaf, HTIndex, ISEIndex],
PPTree;

PPTreeOps: CEDAR DEFINITIONS =
BEGIN OPEN Tree: PPTree, PPLeaves;

-- tree construction interface

Initialize: PROC;
Reset: PROC;
Finalize: PROC;

PushTree: PROC [v: Tree.Link];
PopTree: PROC RETURNS [Tree.Link];

InsertTree: PROC [Tree.Link, NAT];
ExtractTree: PROC [NAT] RETURNS [Tree.Link];

MakeNode: PROC [name: Tree.NodeName, count: INTEGER] RETURNS [Tree.Link];
MakeList: PROC [size: INTEGER] RETURNS [Tree.Link];

PushNode: PROC [name: Tree.NodeName, count: INTEGER];
PushList: PROC [size: INTEGER];
PushProperList: PROC [size: INTEGER];
PushHash: PROC [hti: Leaf] = INLINE {PushTree[hti]};  -- HTIndex
PushSe: PROC [sei: ISEIndex] = INLINE {PushTree[sei]}; -- ISEIndex
PushLit: PROC [lti: Leaf] = INLINE {PushTree[lti]};  -- LTIndex
PushStringLit: PROC [sti: Leaf] = INLINE {PushTree[sti]}; -- STIndex

SetInfo: PROC [info: CARDINAL];
SetAttr: PROC [which: Tree.AttrId, value: BOOL];

FreeTree: PROC [t: Tree.Link] RETURNS [Tree.Link] = INLINE {RETURN [Tree.Null]};

-- tree attributes

GetHash: PROC [t: Tree.Link] RETURNS [HTIndex];
GetNode: PROC [t: Tree.Link] RETURNS [Tree.Handle];
GetSe: PROC [t: Tree.Link] RETURNS [ISEIndex];

NSons: PROC [t: Tree.Link] RETURNS [NAT];

NthSon: PROC [t: Tree.Link, n: Tree.SonId] RETURNS [Tree.Link];

OpName: PROC [t: Tree.Link] RETURNS [Tree.NodeName];

-- tree manipulation

ScanSons: PROC [root: Tree.Link, action: Tree.Scan];
UpdateLeaves: PROC [root: Tree.Link, map: Tree.Map] RETURNS [v: Tree.Link];

-- list testing

ListLength: PROC [t: Tree.Link] RETURNS [NAT];
ListHead: PROC [t: Tree.Link] RETURNS [Tree.Link];
ListTail: PROC [t: Tree.Link] RETURNS [Tree.Link];

-- list manipulation

ScanList: PROC [root: Tree.Link, action: Tree.Scan];
SearchList: PROC [root: Tree.Link, test: Tree.Test];
ReverseScanList: PROC [root: Tree.Link, action: Tree.Scan];
UpdateList: PROC [root: Tree.Link, map: Tree.Map] RETURNS [Tree.Link];
ReverseUpdateList: PROC [root: Tree.Link, map: Tree.Map] RETURNS [Tree.Link];


-- cross-table tree copying

CopyTree: PROC [root: Tree.Id, map: Tree.Map] RETURNS [v: Tree.Link];
IdentityMap: Tree.Map;

END.