DIRECTORY Tioga; TextNode: CEDAR DEFINITIONS ~ BEGIN Node: TYPE ~ Tioga.Node; Location: TYPE = Tioga.Location; NodeItself: INT = Tioga.NodeItself; nullLocation: Location = Tioga.nullLocation; Span: TYPE = Tioga.Span; nullSpan: Span = Tioga.nullSpan; MaxLen: INT = INT.LAST; Ref, RefTextNode: TYPE = Node; -- for compatibility Offset: TYPE = INT; -- for compatibility MakeNodeLoc: PROC [n: Node] RETURNS [Location] ~ INLINE { RETURN[[n, NodeItself]] }; MakeNodeSpan: PROC [first, last: Node] RETURNS [Span] ~ INLINE { RETURN[[MakeNodeLoc[first], MakeNodeLoc[last]]] }; NarrowToTextNode: PROC [n: Node] RETURNS [Node] ~ INLINE { RETURN[n] }; -- for compatibility NewTextNode: PROC RETURNS [Node]; Parent: PROC [n: Node] RETURNS [Node]; Root: PROC [n: Node] RETURNS [Node]; Next: PROC [n: Node] RETURNS [Node]; Previous: PROC [n: Node, parent: Node ฌ NIL] RETURNS [nx: Node]; Forward: PROC [node: Node] RETURNS [nx: Node, levelDelta: INTEGER]; Backward: PROC [node: Node, parent: Node ฌ NIL] RETURNS [back, backparent: Node, levelDelta: INTEGER]; StepForward: PROC [node: Node] RETURNS [Node]; StepBackward: PROC [node: Node, parent: Node ฌ NIL] RETURNS [Node]; Level: PROC [node: Node] RETURNS [level: INTEGER]; ForwardClipped: PROC [node: Node, maxLevel: INTEGER, nodeLevel: INTEGER ฌ 0] RETURNS [nx: Node, nxLevel: INTEGER]; BackwardClipped: PROC [node: Node, maxLevel: INTEGER, parent: Node ฌ NIL, nodeLevel: INTEGER ฌ 0] RETURNS [back, backparent: Node, backLevel: INTEGER]; LocRelative: PROC [location: Location, count: INT, break: NAT ฌ 1, skipCommentNodes: BOOL ฌ FALSE] RETURNS [Location]; LocWithin: PROC [n: Node, count: INT, break: NAT ฌ 1, skipCommentNodes: BOOL ฌ FALSE] RETURNS [Location]; LocOffset: PROC [loc1, loc2: Location, break: NAT ฌ 1, skipCommentNodes: BOOL ฌ FALSE] RETURNS [count: INT]; BadArgs: ERROR; LocNumber: PROC [at: Location, break: NAT ฌ 1, skipCommentNodes: BOOL ฌ FALSE] RETURNS [count: INT]; FirstSibling: PROC [n: Node] RETURNS [Node]; LastSibling: PROC [n: Node] RETURNS [Node]; LastWithin: PROC [n: Node] RETURNS [Node]; LastLocWithin: PROC [n: Node] RETURNS [Location]; FirstChild: PROC [n: Node] RETURNS [Node]; LastChild: PROC [n: Node] RETURNS [Node]; NthChild: PROC [n: Node, location: INT ฌ 0] RETURNS [child: Node]; NthSibling: PROC [n: Node, cnt: INT ฌ 0] RETURNS [Node]; CountChildren: PROC [n: Node] RETURNS [count: INT]; CountFollowing: PROC [n: Node] RETURNS [count: INT]; CountToParent: PROC [n: Node] RETURNS [count: INT, parent: Node]; CountToChild: PROC [parent, child: Node] RETURNS [count: INT]; EndPos: PROC [n: Node] RETURNS [INT]; DestroyTree: PROC [root: Node]; END. ฎ TextNode.mesa Copyright ำ 1985, 1986, 1991 by Xerox Corporation. All rights reserved. written by Bill Paxton. December 1980 last written by Paxton. December 21, 1982 9:46 am Last Edited by: Maxwell, January 5, 1983 12:37 pm Rick Beach, March 27, 1985 1:08:21 pm PST Michael Plass, October 4, 1989 1:09:19 am PDT Doug Wyatt, February 27, 1992 2:51 pm PST returns next sibling of n returns NIL if n is last sibling returns previous sibling of n returns NIL if n is first sibling runs faster if can supply parent returns next node in standard tree walk order levelDelta is level(node)-level(nx), where level is depth in tree levelDelta = 0 if nx and node are siblings levelDelta = 1 if nx is child of node levelDelta < 0 if do Parent* and Next to reach nx from node for backing through tree runs faster if can supply parent levelDelta same as for Forward returns next node in standard tree walk order returns preceding node in standard tree walk order Level[Root[x]] == 0; Level[FirstChild[n]]=Level[n]+1 like Forward, but limits how deep will go in tree if pass nodeLevel=0, correct value will be computed nxLevel = Level[nx] <= MAX[maxLevel,Level[node]] like Backward, but limits how deep will go in tree backLevel = Level[back] <= MAX[maxLevel,Level[node]] count is interpreted as a character offset from given location returns location corresponding to count adds in break at the end of each text subnode if skipCommentNodes is true, then ignores them in walking the tree returns character offset of location2 relative to location1 loc1 and loc2 can be in same node but loc2 must not be in node before loc1 or get ERROR BadArgs if skipCommentNodes is true, then ignores them in walking the tree returns character offset of location relative to root returns the last node within the branch i.e., goes to last child of last child of last child ... until no child returns the last location within the branch sets all REFs in the tree to NIL สย–(cedarcode) style•NewlineDelimiter ™codešœ ™ Kšœ ฯeœ=™HKšœ%™%Kšœ1™1K™1K™)K™-K™)—K˜šฯk ˜ Kšœ˜—K˜Kšฯnœžœž œž˜#˜Kšœžœ˜Kšœ žœ˜ Kšœ žœ˜#Kšœ,˜,Kšœžœ˜Kšœ ˜ Kšœžœžœžœ˜Kšœžœ ฯc˜3Kšœžœžœ ˜(K˜šŸ œžœ žœ ˜.Kšœžœžœ˜%K™—šŸ œžœžœ˜5Kšœžœžœ,˜=K˜—šŸœžœ žœ˜/Kšœžœžœ ˜,K˜—šŸ œžœžœ˜!K˜—šŸœžœ žœ˜&K˜—šŸœžœ žœ˜$K˜—šŸœžœ žœ˜$Kšœ™Kšœžœ™ K˜—šŸœžœžœžœ ˜@Kšœ™Kšœžœ™!Kšœ ™ K˜—šŸœžœžœžœ˜CKšœ-™-šœA™AKšœ*™*Kšœ%™%Kšœ;™;K˜——šŸœžœžœ˜/Kšžœ&žœ˜6Kšœ™Kšœ ™ Kšœ™K˜—šŸ œžœžœ˜.Kšœ-™-K˜—šŸ œžœžœžœ˜CKšœ2™2K˜—K˜šŸœžœžœ žœ˜2Kšœ4™4K˜—š Ÿœžœžœ žœžœžœ˜rKšœ1™1Kšœ4™4Kšœžœ™0K˜—šŸœžœžœžœžœžœ%žœ˜˜Kšœ2™2Kšœžœ™4K˜—K˜šŸ œžœžœ žœžœžœžœ ˜wKšœ>™>Kšœ5™5Kšœ-™-KšœB™BK˜—šŸ œžœžœ žœžœžœžœ ˜iK˜—šŸ œžœžœžœžœžœ žœ˜lKšœ;™;Kšœ!™!Kšœ0žœ™=KšœB™BK˜—šŸœžœ˜K˜—šŸ œžœžœžœžœžœ žœ˜dKšœ5™5K˜—K˜šŸ œžœ žœ˜,K˜—šŸ œžœ žœ˜+K˜—šŸ œžœ žœ˜*Kšœ'™'KšœG™GK˜—šŸ œžœ žœ ˜1Kšœ+™+K˜—K˜šŸ œžœ žœ˜*K˜—šŸ œžœ žœ˜)K˜—šŸœžœžœžœ˜BK˜—šŸ œžœžœžœ˜8K˜—K˜šŸ œžœ žœ žœ˜3K˜—šŸœžœ žœ žœ˜4K˜—šŸ œžœ žœ žœ˜AK˜—šŸ œžœžœ žœ˜>K˜—K˜šŸœžœ žœžœ˜%K™—K™šŸ œžœ˜Kšœ žœž™ K™——K˜Kšžœ˜—…— pเ