TiogaTreeOps.mesa; Written by McGregor, February 1983
edited by McGregor, May 11, 1983 3:55 pm
edited by Paxton, July 26, 1983 11:08 am
DIRECTORY
TiogaNode;
TiogaTreeOps: CEDAR DEFINITIONS = BEGIN
Ref: TYPE = TiogaNode.Ref;
RefBranchNode: TYPE = TiogaNode.RefBranchNode;
TreeLoc: TYPE = RECORD [node: Ref, where: TiogaNode.Offset];
nullLoc: TreeLoc = [NIL, TiogaNode.NodeItself];
TreeSpan: TYPE = RECORD [start, end: TreeLoc ← nullLoc];
nullSpan: TreeSpan = [nullLoc, nullLoc];
BranchLoc: TYPE = RECORD [node: RefBranchNode, where: TiogaNode.Offset];
nullBranchLoc: BranchLoc = [NIL, TiogaNode.NodeItself];
BranchSpan: TYPE = RECORD [start, end: BranchLoc ← nullBranchLoc];
nullBranchSpan: BranchSpan = [nullBranchLoc, nullBranchLoc];
Tree traversal
You probably want to use the routines in TiogaPathOps instead of these. These routines ignore template applications -- they are used by the tree editing routines that work within a single tree.
Parent: PROC [n: Ref] RETURNS [Ref]; -- do you really want TiogaPathOps instead?
Root: PROC [n: Ref] RETURNS [RefBranchNode]; -- do you really want TiogaPathOps instead?
Next: PROC [n: Ref] RETURNS [Ref]; -- do you really want TiogaPathOps instead?
Contents: PROC [n: Ref] RETURNS [Ref] ; -- do you really want TiogaPathOps instead?
BranchChild: PROC [n: RefBranchNode] RETURNS [RefBranchNode] ; -- do you really want TiogaPathOps instead?
FirstSibling: PROC [n: Ref, parent: Ref ← NIL] RETURNS [sib: Ref];
LastSibling: PROC [n: Ref] RETURNS [sib: Ref];
Previous: PROC [n: Ref, parent: Ref ← NIL] RETURNS [sib: Ref];
LastWithin: PROC [n: Ref] RETURNS [Ref];
ContainingStatement: PROC [n: Ref] RETURNS [RefBranchNode];
Forward and Backward in Tree
StepForwardNode: PROC [node: Ref] RETURNS [nxt: Ref];
Forward: PROC [node: RefBranchNode] RETURNS [nx: RefBranchNode, levelDelta: INTEGER];
StepBackwardNode: PROC [node: Ref, parent: Ref ← NIL] RETURNS [back, backparent: Ref];
Backward: PROC [node: RefBranchNode, parent: Ref ← NIL]
RETURNS [back: RefBranchNode, backparent: Ref, levelDelta: INTEGER];
Miscellaneous
LastBranchWithin: PROC [n: RefBranchNode] RETURNS [RefBranchNode];
Level: PROC [n: Ref] RETURNS [INTEGER];
MakeTreeLoc: PROC [n: Ref] RETURNS [TreeLoc];
MakeTreeSpan: PROC [first, last: Ref] RETURNS [TreeSpan];
MakeBranchLoc: PROC [n: RefBranchNode] RETURNS [BranchLoc];
MakeBranchSpan: PROC [first, last: RefBranchNode] RETURNS [BranchSpan];
BackLoc: PROC [loc: TreeLoc] RETURNS [new: TreeLoc];
ForwardLoc: PROC [loc: TreeLoc] RETURNS [new: TreeLoc];
END.