Top Banner
TAXL-A simple Hierarchical Data Structure Manipulation System: SUE Rapor! No. 119 Juns 1m AEC GoRtract A'tOW3)4tb STANFORD LINEAR ACCELERATOR CENTER Stanford University Stanford, California
126

TAXL-A simple Hierarchical Data Structure Manipulation ...

Mar 16, 2023

Download

Documents

Khang Minh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: TAXL-A simple Hierarchical Data Structure Manipulation ...

TAXL-A simple Hierarchical Data Structure

Manipulation System:

S U E Rapor! No. 119

Juns 1m

AEC GoRtract A'tOW3)4tb

STANFORD LINEAR ACCELERATOR CENTER Stanford University Stanford, California

Page 2: TAXL-A simple Hierarchical Data Structure Manipulation ...

DISCLAIMER

This report was prepared as an account of work sponsored by an agency of the United States Government. Neither the United States Government nor any agency Thereof, nor any of their employees, makes any warranty, express or implied, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process disclosed, or represents that its use would not infringe privately owned rights. Reference herein to any specific commercial product, process, or service by trade name, trademark, manufacturer, or otherwise does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United States Government or any agency thereof. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or any agency thereof.

Page 3: TAXL-A simple Hierarchical Data Structure Manipulation ...

DISCLAIMER

Portions of this document may be illegible in electronic image products. Images are produced from the best available original document.

Page 4: TAXL-A simple Hierarchical Data Structure Manipulation ...

SLAC- 119 .UC-32 (MISC . )

TAXL-A SIMPLE. HIERARCHICAL. DATA STRUCTURE

MANIPULATION SYSTEM

SHELDON I. BECKER

STANFORDUNEARACCELERATORCENTER

'STANFORD UNIVERSITY

Stanford, California 943 05

PREPARED FOR THE U. S . ATOMIC ENERGY

COMMISSION UNDER CONTRACT NO. AT(04-3)-515

This report was prepared as an account of work sponsored by the Unlted Stales Government. Ncithet the United States nor the United States Atomic Energy Commission, nor any of their employees, nor any of their contractors, subcontractors, or their employees, makes any warranty, express or implied, or assumes any legal liability or responsibility for the accuracy, com- pleteness or usefulness of any information, apparatus, product or process disclosed, or represents that its use would not infringe privately owned rights. .

June 197 0

' [ .-.' ' .

'

j

i

Reproduced in the USA. Available f rom the clearinghouse fo r Federa l scikntific: a n d : ~ e c h n i c a l Information, Springfield, Virginia 2215 1. Price: Full size copy $3.00; microfiche copy $ .65 .

Page 5: TAXL-A simple Hierarchical Data Structure Manipulation ...

T H I S PAGE

WAS INTENTIONALLY

L E F T BLANK

Page 6: TAXL-A simple Hierarchical Data Structure Manipulation ...

TABLEOFCONTENTS

Chapter Page

I . . . INTRODUCTION . . . . : . . . . . . . . . . . . . . . . . . . 1

. . . a. THE NATURE AND ADDRESSING O F THE DATA STRUCTURE 6 . . . .

. A . The Data Btruc ture . . . . . . . . . . . . . . . . . . . . . 6

B . The Data Item . . . . . . . . . . . . . . . . . . . . . . . . 6

D . Total Range Specification . . . . . . . . . . . . . . . . . . . 17

. E . Subtree Context Specification . . . . . . . . . . . . . . . . 18 . . "

. . . . . . . . . . . . . . . . . . . . . . . 1 Condition I 18

2 . Condition 11 . . . . . . . . . . . . . . . . . . . . . . . 21

. . . . . . . . . . . . . . . . . . . . . . . . . 3 Condition 111 21

. . . . . . . . . . . . . . . . . . . . . . . . F . Conclusion 23 .

m . DESCRIPTION OF THE PRIMITIVES . . . . . . . . . . . . . . . 24

A . CREATE . . . . . . . . . . . . . . . . . . . . . . . . . . Zci

. . . . . . . . . . . . . . . . . . . . . . . . . . . B LABEL 28

. C . UNLABEL . . . . . . . . . . . . . . . . . . . . : . . 1 29

. . . . . . . . . . . . . . . . . . . . . . . . . . . D . COUNT 3 1

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . WRITE 32

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . F PUT 35

. . . . . . . . . . . . . . . . . . . . . . . . . . . . G . COPY 37

Page 7: TAXL-A simple Hierarchical Data Structure Manipulation ...

Chapter Page

. . . . . . . . . . . . . . . . . . . . . . . . . . . H . SEVER 41 . . .

I DELETE . . . . . . . . . . . . ' . . . . . . . . . . . . . . .44 .. .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . K . RESTORE 48 . . . . . . . . . . . . . . . . . . . . . . . . . . . L . Conclusion 49

. . . . . . . . . . . . . . . . . . . . IV THE TAxL/BASIC SYSTEM '50

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . A. . Syntax Analysis 52

. . . . . . . . . . . . . . . . . . . B . Command Classification 53

. . . . . . . . . . . . . . . I . C . Interface Belweeu TAX% and BASIC 5'1

. . . . . . . . D . Responses Following the Execution of Commands 63

. . . . . . . . . . . . . . . . . . . . . . . . . E . Conclusion 64

. . . . . . . . . . . . . . . . A . Node and Dictionary Formats 68

. . . . . . . . . . . . . . . B . he computation of Ranges ; . 69

. . . . . . . . . . . . . C . Reducing Range Computation Time 73

. . . . . . . . . . . . . . . . . . . . . . . D . Memory Usage 76

. . . . . . . . . . . . . . . . . E . Access Time ; . . . . . 80

. . . . . . . . . . . . . . . . . . . . . . . . G . System 'Measures 84

Page 8: TAXL-A simple Hierarchical Data Structure Manipulation ...

LIST OF TABLES

Page

1. The Primitives. . . . . . . . . . . . . . . . . . . . . . . . . . 25 . , . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . 2. Reserved Word List 27 . .

3. Command Classification. . . . . . . . . . . . . . . . . . . . . 54 . .

4. Storage Requirements for a Hypothetical Data Base . . . . . . . . . 81 . . . .

Page 9: TAXL-A simple Hierarchical Data Structure Manipulation ...

LIST OF FIGURES

. p e e

la. Directed multirooted multibranchi-ng tree . . . . . . . . . . . . . 7 . . : . , .

lb . Directed acyclic .graph . . . . . . . . . . . . . . . : . . . . . . 7 . . . .

2. A Personnel f i l e . . . . . . . . . . . . . . . . . . . . . . . . . . 10 . . c :

3 . Format of a node in'the data base . . . . . . . . . . . . . . . . . . 66

4. Format of an atom used as a label in the data base. . . . . . . . . 67

5 . A portion of a . data base demonstrating the utility of below

. . . . . . . . . . . . . . . . . . . . . . . . . . andabove. 75

Page 10: TAXL-A simple Hierarchical Data Structure Manipulation ...

CHAPTER I

The work described here attacks two problems: the lack of agreement on the

nature of certain aspects of nonnumeric computer processing, and the educational . .

bottleneck resulting from the large nuinbers of people who know little about com-

puters but who wish to see how . . they might be used in their work. , .

The first problem is a generic problem in the nature of nonnumeric processing.

The essence of numeric calculations and operations has been known for some time, . . . .

and the advent of high speed digital computers has solidifiedthese concepts. . . Almost . .

all general purpose digital computers have facilities for doing arithmetic, and . . . . . ,

depending on the size and cost of the machine, these facilities can be quite elaborate.

This should not be surprising since the first uses to which digital computers were . . . .

put were almost exclusively numerical calculations. . .

The notion that a general purpose digital computer can be a very general

symbol manipulator began to grow from the early days of computing and is now

an accepted notion throughout most of the computing community. As yet, however, . .

there has been very little agreement on what constitutes general symbolic manipu-

lation, i. e., nonnumeric calculation. This lack of agreement can be seen at the

hardware level by the fact that there has been no unanimous introduction of pieces . ,

of hardware to do nonnumeric processing, as opposed, for example, to the

existence of adders for numeric processing. On the software level, the great

variety of "list processingff languages such a s LISP (McCarthy [1962]), SNOBOL

(Griswold El9 68]), and L6 (Knowlton [1966]), and "associativeff languages like

LEAP (Feldman [1969]) and ASP (Lang [1968]) indicates that there a re certainly

divergent opinions on the nature of nonnumeric processing. One of the purposes

Page 11: TAXL-A simple Hierarchical Data Structure Manipulation ...

of this work, then, is to t ry to shed some light on a representation and subsequent

manipulation of nonnumeric data.

The second problem with which this work deals is related to the fact that

computers can be very useful tools in many areas, including both mathematical . .

sciences and nonscientific fields such a s history, government, sociblogy, , .

law, etc.

The phenomenal growth of accessibility to computers and the number of

people anxious to use computers have caused quite a bottleneckin the facilities

* for training these people. ~n t roduc to r~ programming courses in universities

and colleges a r e almost always overcrowded as students in the physical sciences

and, more and more often now, the social sciences realizc that computers mj,ght

be able to help them in their own fields. . ,

These immense numbers of people, who are eager and should learn how to

use and how not to use computers in their own work, require that new methods

of teaching and learning these skills be explored. The traditional university

course, for example, lasting from at least several weeks to a quarter o'r se-

mester is quickly becoming inadequate toserve the volume of people eager t; ' ..,

acquire the knowledge of some programming language which might be useful to

them. The length of time which is required for the computer novice to learn

many of the computer languages and systems, with their increasing generality

and complexity, is usually more than he and his instructor wish to spend.

Kemeny and Kurtz at' Dartmouth have attcmptcd to alleviate this problem by

designing and implementing an interactive computer language and system called . .

BASIC (Kemeny [1967]). ' The simplicity of the system and case with which the

language can be learned are evidenced by the fact that a very short formal lecture

session is usually all that is necessary for the novice to begin writing programs

Page 12: TAXL-A simple Hierarchical Data Structure Manipulation ...

- that a r e usef* to him. The interactive nature of the system allows the novice 'to

use the system at his leisure and to search for answers to questions which occur

to him about the system by experimentation. The great utility of this approach

to the training and teaching problem is attested to by the great number of BASIC

systems which have been adopted by many computation centers and the wide sup-

port and use these systems a r e receiving from their users.

There a r e a number of problems for which the BASIC language and system is

inadequate, but for these problems there a r e more general and more complex

languages and systems which the novice can learn and use. However, for a

great many common everyday problems, BASIC is entirely adequate, and the

ease with which i t can be so used bears strong evidence that .RASIC1s approach

to the computer education bottleneck is a good one.

This work, then, is an attempt to combine partial solutions to these two .. problems: to shed further light on the nature of one aspect of nonnumeric proces-

sing, and to aid in reducing the educational bottleneck in that area.

The vehicle for this study is the design and test implementation of a non- - .- ..'I

numeric data prdcessing capability suitable for inclusion with a BASIC' system.

It i s felt that such an addition would greatly enhance the already great appeal of

BASIC to those nonscientific users who already view BASIC a s a useful tool for

the solutions of their numeric problems.

In trying to follow one of the rules for the development of BASIC, which was

to find those few primitives which were not only basic and useful, but also of high

pedagogic value, i t was decided that the majority of current nonnumeric list-

processing languages were too much data-structure oriented rather than problem-

solving oriented, Hence, while these languages contain almost all the basic

primitives for list processing, they a re too Gfficult to use and of too little pedagogic

v a l ~ ~ e fo r those novice users for whom the nonnumeric capability i s intended.

Page 13: TAXL-A simple Hierarchical Data Structure Manipulation ...

As different in format and applicability as the existing nonnumeric lan-

guages are , there is a common motive that runs through all of them. In one

form o r another, all of these languages emphasize the relationships between

data as opposed to emphasizing the data themselves. In IPL (IPL [1961]) and

'LISP (McCarthy [1962]), for example, the sublist concept and associated mecha-

nisms for creating, manipulating, and destroying such sublists deals with the

relationships between not only atoms of data but also between other relationships.

Much the same can be said for the pointer structuring capabilities in ALGOL W

(Bauer [1969]) and in L6 (Knowlton [1966]), the basis for which was Wirth and

Hoarevs records and references(Wirth [1966]) and Rossts plex processing

(Ross [1961]). It certainly appears that the ability to specify relationships

which exi'st among data and to manipulate these relationships are at the heart of

nonnumeric processing.

Having ascertained the centrality of the concept of relationship specification

and manipulation to nonnumeric processing, we turn to finding those few primi-

tives which a re basic, useful, and of high pedagogic value. More explicitly, when

considering nonnumeric processing and the relationship concept, the problem is

to focus on some hopefully small subset of all possible relationships in order to

~implify both tho language and thc conccpta involved in teaching. 'To tl~s end, I

have chosen one type of relationship, the ----. hierarchical - relationship.' Webster

( Webstcr [1964') defines lrhierarchyfl a s "the arrangement of objects, elements,

o r values in a graduated series. " Notice that the emphasis is on the arrangement

of the objects rather than the objects themselves. The graduated nature of a

hierarchy as defined, -as wcll a s the intuitive feelings 'of what constitutes a '

hierarchy, implies the true generality uof this relationship: it exists o r can easily

be made to exist among data in a great many different kinds of data bases. In

addition, two relationships can be different in their meaning but still be hierarchical.

I

- 4 -

Page 14: TAXL-A simple Hierarchical Data Structure Manipulation ...

In other wofcls, RAB and RBC can both'be hierarchical relationships but

having different semantic content depending on the data, A,. B, and C. For example,

A could describe a.professor, B. could describe his secretary, and C could describe

her salary.' The exact nature of "the relationships is somewhat .subjec.tive and

might be interpreted slightly differently by 'different users once the data A, B,

and C a re known; noietheless, both relationships a r e hierarchical, 'and this fact

i s all that should be required.for the user to specify,. query, and manipulate the

relationships and the data. More will be said'about this and more examples wi l l

. : . . .

be given in later chapters..

Having limitedthe' type of relationship, i t remains to determine.:how..to specify

* that.this relationship exists 'or does'liot exist between data, how to'query the1data

base in terms-'of the relationships which.do or do not exist, and how to 'manipulate

these relationships and so indirectly the data. The manner in which these operations

should be specified should be simple and of high pedagogic and mnemonic.value in

order that the goals achieved in BASIC can be achieved here as well. Once these . . . . . . . . .

goals 'are met, the resulting system w i l l be able to serve a s both a data manage- . ..

ment system and an information retrieval system which is easy to,use and easy . . .

to learn. The following chapters discuss and explain one way that this can be done. . . . . . .

I

Page 15: TAXL-A simple Hierarchical Data Structure Manipulation ...

A. The Data Structure

The data structure type f i rs t chosen to represent the hierarchical relationships

discussed in the previous section was. a multirooted 'Adtibranching tree with the

a rcs of the t ree oriented away from the roots (see Fig. 1%). The nodes of the tree

contain the data items and a directed path from node X to node Y in the tree indi-

cates. that node X is . . in a hierarchically superior relationship . to . n0de.Y. , ,Stated

differently, node Y is within the hierarchical context of node X., If no .directed ~ . .

path exists between node X and a no.de Z , . then no hierarchical relationship exists

between..node. X .and node .Z, ,Notice. that node X?and .node Y do not.,have to be, ,

adjacent . to. . one another,.. i..,e., ,.other nodes .may exist along the path frqm node X:

to node Y. . . . . , . , . / .

. .For reasons of generality, the., multirooted multibranching tree ,data . . .structure

was .extended slightly t.0 directed acyc,lic graphs. This data structure.can he . ,

conveniently visualized as a multirooted multibranching t r ee , some of whose ,,

branches might have,grown together (see Fig. .lb). . The nodes..of the: directed

acyclic graph still contain the data items, and what was said previously about .. , .

the.-existence or nonexistence of a hierarchical relationship. between two nodes..

. still .holds. : . . , , .. . . . , " . . . . . I

. . . . . . . . . . . . . ,

B. The Data Item . . . . . I . . : . - < . .

'AS previously noted, each node of the graph contains a data item. A data . . . . . . . . . . . . . . . . , .

I . ' ' ' . .. item is any semantically meaningful labkl or bet of labels the user chooses. '

. . . . . . . . . . . . .

<label > : : = < identifier >'l( number >

<data item > : : = < label>l< label> <data .itern>

Page 16: TAXL-A simple Hierarchical Data Structure Manipulation ...

Directed multirooted multibranching tree.

(a)

Directed acyclic graph

(b)

FIG. 1.

Page 17: TAXL-A simple Hierarchical Data Structure Manipulation ...

where the syntactic classes <identifier > and <number> a re a s defined in the

Algol 60 report (Revised Report 1963). Duplicate labels may occur within a data

item.

In some complex retrieval systems, there is a syntactic distinction made

between the semantically different concepts of a category of some kind and a

particular instance of that category when referring to data items at nodes in a . .

data structure. For example, uUniversityff can be thought of,as a category of -.

which "Sta .nf~rd~~ and lfTexasfl a r e instances. The system doess.not distinguish

between labels which can denote categories and labels which can denote instances.

The distinction between the concepts of category and instance is fairly easy to

make for professionals in the computer field. However, for the potential user

of this system, these concepts and their distinction may appear to be somewhat

arbitrary and beside-the-point, complicating rather than simplifying the use of

the system. For this reason, there is no syntactic distinction made between

category and instance within data items in this system, and whatever semantic

distinction exists between the labels which make up a data item can remain com-

pletely within the mind of the user. " ~

Exn.mp1c.s

Stanford La~vyor J o n o ~ .

Stanford U*versity Uootor Lawyer Jones

27

age 27

salary ,

salary 375.60 dollars per month

C. The Range

One of the basic concepts in this system is the manner whereby a subset of

the set of all nodes in the graph, called a range, is referenced. Most of the

Page 18: TAXL-A simple Hierarchical Data Structure Manipulation ...

primitives operate on one or more subsets of nodes, o r ranges, and each refer-

ence to a range is accomplished according to a common set of rules. There is

a general principle, the Principle of Greater Specification, which applies when

specifying a range. This principle 'states that when more information i s given . \

to specify a range, the cardinality of the range, i. e. , the number of nodes ref-

erenced,cannot increase because of the added information; more usually, the

cardinality decreases. ' Simply stated, the more carefully a se t of nodes i s de- . .

scribed, the fewer nodes one i s describing since only those nodes which satisfy

all the descriptions a r e included in the range. As the different methods for - referencing a range a r e discussed, i twi l l be shown how the Principle.of Greater

' .. . ; Specification applies. It w i l l also be seen that each method i s a special case of

following methods. . .

1. Method I .' . . . . .

, . . . . . . . . . . .

The simplest way of specifying a range is by evoking a label. The set of nodes

which constitutes the range is then all those.nodes in the graph which have the . . a

. . .. ,

evoked label among the h b e l s which make up the data item for that node. . - , ... .. . . . , ' '

Examples (see Fig. 2) .. ' , . , . . : . .

Evoked Label ' . Node numbers in ;range . . . . . . . . . .. .

Student. .' . - , . { l ~ , 22, 23) . . ,

. ,

University

History

, . The nodes.in any range always form an unordered set.

Page 19: TAXL-A simple Hierarchical Data Structure Manipulation ...

Cll Cdtech Stanford University PI Texas lrdversity PI ' C41 -

Law School [51 School d Humanities c61 Administration . . School of ~ n g & e r i n ~ C81

and Sciences , .

Communication

Mechanical [121 Engineering Department

I Professor C nainman I-'

Professor ~ s s o c . provost['!

. Electrical Parker Professor o Engineering

I Forsythe Moees

Mickelson

Student Laurel ~231

Student Secretary [2 13 Sheldon Carla West Becker - S a k y

Note: Sdary Classified W r y . Wife I251 C261

$9 00.53 Susan Bracketed numbers b e ~ i d e each node are for identification pnrposes .only . -

and are not part of the data item at the node. ' 1594A2

FIG. 2--A Personnel file..

Page 20: TAXL-A simple Hierarchical Data Structure Manipulation ...

. . . .

2. Method II

noth her way of specifying a range ' isby evoking one or m&& labels. The set

of nodes which co&titutds the r&k is then the intersection of all those sets of

nodes (ranges) which would arise if 'each 'evoked label were evoked alone. he' . .

evoked labels canbe in anydrdkir. If only one label is evoked, it is seen that \ .

. . this method of specifying.a range is identical with Method I.

. . "~xamples (see Fig. 2)

Evoked Labels Node numbers in range ,

Professor Miller 1151

Provost ~ i l l e i ' { 1 6 I

ASSOC. P ~ O V O S ~ ' Miller (16 I Engineering Department

Chairman Miller

School of Humanities and Administration Sciences

Miller . Professor . . .

Student Sheldon Becker

Student Sheldon

Student Becker

Sheldon Becker

Student

Sheldon

Becker . , . . . . . . .

Notice that the Principle of Greater Specification holds here. The evoked

label flStudentff specifies a range consisting of three nodes (see Fig. 2); upon

greater specification, "Student Hardyff for example, the range is reduced to one

node.

- I1 -

Page 21: TAXL-A simple Hierarchical Data Structure Manipulation ...

There is an addition to Method I1 which can be used when the range which the

..user . . wishes to specify consists of. a set of nodes which. have precisely the set of

. . 'I .. . . , . .

labels. t h e user . evokes, and inprecisely , . the same order. , . I$ . the usiml .case, . the .

1'

range consists of the set . . . of nodes, which have .at least the. set of labels the user , . . e .

evokes, and in any order. The word "just", pccurring before the evoked labels .. . - ' . .

has pedagogic value in m*.ng it clear to the user. that :only. those nodes a r e sought _ . . , : . , .. .

which contain precisely the evoked set of labels. llPreciselyll or llexactlylf might . .

also be used. . ,

. . . ..

Examples (see Fig. 2) . .

Evwaliun

just Student

Node numbers in range

B . . .

just Student Hardy @?I . . . .

Student Hardy iz2t 3. Method 111 . . . .

A more complex and d e powerful method of specifying's range is by

hierarchical context. As was stated at the beginning of this chapter, iince the

data base is a directed acyclic graph, ' between any t.wo 1~6des in the grqih ,ox"ct.ly i . .

one of the following two relationships holds:

(1) there is no directed path between the twg nodes ' '

(2) there a rc one or more directed paths between the two hodes.

Node Y is said to be withi.n the hierarchical context of node X if one or more

directed paths exist from node X to n k e Y . If no directed path axintn h6tween

node X and node Y, then neither node is within the hierarchical context bf the

other node.. '~ ince : the .graph is.acyclic, node X may never be. within its own

hierarchical context. . . . .

Page 22: TAXL-A simple Hierarchical Data Structure Manipulation ...

Let the symbol I' > l 1 indicate that the hierarchical relationship holds, i. e. ,

X > Y means that node Y is within the hierarchical context of node X. X 3 Y means

that node Y is not within the hierarchical context of node X.

, Examples (see Fig. 2)

The hierarchical relation is nonreflexive, antisymmetric, and transitive.

The third method of range specification is accomplished by specifying two

ranges in order according to Method It. The range thus specified consists of all

those nodes in the first range which a r e within the hierarchical context of any

node in the second range. More precisely, if R1 and R2 are the two ranges

initially specified, then the range R within the hierarchical context of R1 with

respect to R2 i s defined by:

E R l ~ S x c R 3 x > y 2

In the preceding chapter, i t was stressed that simplicity for the user be a

primary goal. Reviewing the second method of specifying ranges, it can be seen

that the data base is being addressed directly in terms of label's which the user

has there (the ways in which this placement occurs will be described in the

next chapter). Since these labels a re purely the user's invention, they a re semantically

Page 23: TAXL-A simple Hierarchical Data Structure Manipulation ...

meaningful to him. By allowing him to use these labels to address the data base,

simplicity for him is thereby furthered.

Continuing in this spirit, the following manner of evoking ranges to be

specified by Method 111 i s suggested:

R1. within R2

where R and R2 a r e evocations of the two ranges by Method 11, in order. The 1

word llwithinll is used a s a delimiter, suggesting the hierarchical contextual

relationship. Depending on how the user visualizes the data. ,base, delimiters

such a s "inI1 or "underr1 might be .used.

Examples (see Fig. 2)

Evocation Node numbers in range

Student within Computer Science 1181

Student within Department 118, 22, 23) .

Professor within Stanford {13, 14, 151

13rofessor within Humanities School. {13, 14, 1.51

Professor within Communication {I3\

P r n f ~ s s o r within Administration fl

Miller within Stanford 11% 161

Miller within Administration 116 I Professnr MilS.er within Adrninistration

Provost within Administration {11, 16, 171

Provost within Provost {I% 171

A natural and useful extension of specifying ranges by context is to specify

a set of nodes - not within a given context. More precisely, if R1 and H2 a re the

two ranges initially specified, then the range R not within the hierarcl~ical context

Page 24: TAXL-A simple Hierarchical Data Structure Manipulation ...

of R 1 with respect to R 2 i s defined by:

The most natural extension for evoking ranges specified in this manner

is to use "not within1' a s the delimiter between the evocation of ranges R and R 2.

Examples (see Fig. 2)

. .... . Evocation Node numbers in range

. . Student not within Computer Science 122, 23)

Student not within Department fl

Professor not within Stanford 'B

Miller not within Adminisfration b5 1 Professor Miller not within

Administration

Provost not within Administration 0

' ' Provost not within Provost bll

4. Method N

As Method I1 is a generalization of Method I, so Method IV is a generalization

of Method III. In the preceding method, a first set of nodes is chosen by specifying

a second set of nodes a s context; the second set of nodes modifies the first set,

Method N allows a third context to be specified for the second set, a fourth context

to be specified for the third set, etc.

In the general case, n ranges R 1' R2, . . . , R in order. a r e ,specified by n

Method II; n 2 2. The ranges a r e associated in the foilowing manner:

Method 111 is first applied to the ordered pair of ranges Rn - and Rn. The

result of this application is a range, call i t Rn - n. , Method III is then applied /

Page 25: TAXL-A simple Hierarchical Data Structure Manipulation ...

to the ordered pair of ranges Rn - and Rn-l, n, resulting in a'range R n-2, n-1, n'

Method III is continually reapplied to successive pairs of ranges until i t i s finally

applied to the ordered pair of ranges R1 and R2 , 3 , . . . ,n-1,no The result of this

final application is either null o r a subset of the range specified by R1, a range

specified by successive hierarchical cokexts. ~ o t i c e that for n = 2, Method IV

becomes Method III, and for the degenerate case of n = 1, Method II.

The natural extension for evoking ranges by successive hierarchical context

is to evoke the n ranges by Method It, each evocation delimited by l1withinl1 or

"not within1':

R1 dl,2 :R2 d2,3 R3 ---- dn-l,n R n

where R is the evocation of the ith range by Method 11 and d. is either 1-1. i

llwithinll or "not within. " Examples (see Fig. 2)

Evocation

Secretary within Miller within

Node numbers 'in range

121) Administration

, . Secretnry within Miller within

Computer Science (19, 211

,.. . secretary within Miller not within

,' . ~ . d m i & s tration (19, 21)

Secretary within Miller not within

Cornp~~ter finicnnr: 1211 Student within Mechanical Engfneering

not within Humanities within stanford 422, 231

. . . .

Page 26: TAXL-A simple Hierarchical Data Structure Manipulation ...

Notice that the Principle of Greater Specification holds here. Also notice

that the data base is still being addressed in terms of labels which a r e semantically

meaningful to the user and in a manner which is very suggestive of the relationships

which the user visualizes as holding between his data.

D. Total Range Specification

Since Method I ' is a generalization of all the preceding methods, and the

distinction between the methods will often not be needed, the combination of al l

the methods, i. e. , Method IV, will henceforth be called the specification of a

range by hierarchical context. Observe, however, that the contexts which a r e

given a r e always hierarchically superior to 'the nodes which a r e being specified.

In terms of visualization of the data base a s drawn, for example, in Fig. 2, the

contexts a r e always ltaboveM the nodes which a r e being specified. Often, i t is

useful to be able to further qualify the nodes to be specified by looking at those

nodes "below" the nodes which a r e being specified, i. e . , those nodes which a r e

hierarchically inferior to the nodes being specified.

To specify a range then, a set of nodes is f i rs t specified by hierarchical

context. If i t is not desired to further qualify the nodes so chosen by hierarchical

context, then this set of nodes is the range. If it is desired to further qualify the

nodes thus chosen by hierarchical context by checking for some condition or

conditions which might exist in nodes hierarchically inferior to the nodes chosen

by hierarchical context, this specification, to be described shortly and to be

called specification by subtree context, is then given. It should be noted that

specification by subtree context is specification by predicate, a well known method

of naming sets. Specification by subtree context asks whether o r not some condition

holds within the subtrees of those nodes chosen by hierarchical context. Every

node chosen by hierarchical context whose subtree meets the condition (or

Page 27: TAXL-A simple Hierarchical Data Structure Manipulation ...

conditions) named by the subtree context specification is retained in the range;

all nodes which do n i t meet the condition (or conditions) named are discarded

from the range.

E. Subtree Context S~ecification

Three conditions have been chosen to be used in the subtree context speci-

fication. One condition checks for the existence of a node (specified by Method IV)

within the subtree. A second condition, which is a partial generalization of the

first , checks for the existence of a given number of nodes (specified by Method IV)

within the subtree. The third condition checks for the existence of a node, one

of whose labels is numeric ang tt!e value of which is compared to a given number,

within the subtree.

' Within the subtree context' specification, ,any of the three conditions can be

evoked, o r any combination of the three conditions separated by the logical con-

nectives AND and OR can be evoked. The unary logical operation N@T is built

into the conditions and need not be explicitly provided.

The evocation uf a range, therefore, conaists of a specification by hterarchical

context optionally followed by a specification by subtree context. If the latter is

present, the hierarchical and subtree specifications a r e separated by the delimiter

"wherever. . .

In BNF:

<range> : : = <hierarchical context specification> (

<hierarchical context specification>

wherever -subtree context specification>

1. Condition I

As stated previously, Condition I allows the user to check for the exis-

tence of a particular node, or hierarchical configuration of nodes, one of

Page 28: TAXL-A simple Hierarchical Data Structure Manipulation ...

which must be within the subtree *of the node chosen by hierarchical context.

Method Nc is used to specify a set N of nodes. Every node which is specified by

hierarchical context and which has within its proper subtree (i. e . , hierarchically

inferior to it) a t least one node in N is retained in the range. Every node which is

specified by hierarchical context but which does not have within i ts proper subtree

at least one node in N is not considered to be in the range.

What is required for Condition I, then, is a specification of a temporary

range N by Method IVY the nodes of which a re then sought within. the subtrees of

the nodes specified by hierarchical context. If the latter set of nodes is called

M, then the range is given by:

R,= x x ~ M ~ S y e N 3 x > y { I In the evocation of a range using any of the three conditions (which all use

Method IV to specify the set N), i t is necessary to make clear to the user that a

condition is sought, the result of which is essentially llyesll or "nof1, i. e . , a

predicate. To this end, the word "isl1 is inserted before the first occurrence .of

the word llwithinfl in the Method IV specification used in the subtree context condi-

tion. Observe that since Method II is a degenerate form of Method IV not involving

the use of the word "within, the above word insertion is not always able to be

dc~ne. (Bee the third ailel last example below. )

Examples (see Fig. 2)

Evocation Node numbers in range

Department within.Humanities

wherever Secretary Mickelson

: is within Professor Miller llol Provost wherever Carla West

i s within Provost 111. 161

Provost wherever Carla West {1.1, 161

Page 29: TAXL-A simple Hierarchical Data Structure Manipulation ...

Assoc. Provost wherever Carla West

is within Provost {I6\

Department within .Stanford wherever

Secretary is within Department jl@ \

Department within Stanford wherever

Secretary PI

Ranges including the negation of Condition I can also be specified. In this case,

every node which is specified by hierarchical context and whlch does not have

within i ts proper subtree at least one node in N is retained in the range. Every

node which is specified by hierarchical context which has within i ts proper subtree

a t least one node in N i s not considered to be in the range. More formally:

The evocation of a range using this form of Condition I is accomplished by

inserting the words "is not1' before the first occurrence of the word "within1' in

the Method IV specification in the subtree context condition. The meaning of the

word "not" following "is1' essentially has the meaning "it is not the case that . . . and should not be confused with the use of the word "not" first described in the-

discussion of Method III. For example, in the first example below,

N = 1211 - subtree context

M = 19, 101 -. hierarchical context

Examples (see Fig. 2)

Evocation

Department within Humanities

wherever Secretary Wc+st is not

within Professor within

Department

Department within Stanford

wherever Secretary i s not

within Department

- 20 -

Node numbers ill range .

Page 30: TAXL-A simple Hierarchical Data Structure Manipulation ...

2. ' .Condition. I1

Condition 11 allows the user .to check for the existence of a given 'number of

nodes 0f.a certain specification (by Method IV again) within the subtrees of those

nodes specified by hierarchical context. What is required then is a temporary \

range N specified by Method IV, a relational operator P(e. g. , =, # , > ), and a

number, q. Every node in M(i; e . , those nodes specified by hierarchical context)

which has within i ts subtree a number of nodes in N which stand in the given

relation P to the given number q is retained in the range. Any node in M which

does not have within i ts subtree a number of nodes in N which stands in the given . .

relation to the given number is not considered to be in the range. More formally,

if C is the set cardinality operator, P is the given relational operator, and q is

the given number, then

The evocation requires some word which denotes that a cardinality is being

considered; The word "countn has been chosen both because of i ts inherent

semantic content and because of i ts use in one of the primitives which is explained

in the next chapter.

Examples (see Fig. 2)

Evocation Nude numbers in range

Departlnenl wherever count

student i 3 {9, 10, 12, 20)

Department wherever count student

within Departn~ent = 2 .. 1121

3. Condition TtI

Condition 111 allows the user to check for the existence of a. node, at least'

one of whose labels is numeric and the value of which stands in a given relation

Page 31: TAXL-A simple Hierarchical Data Structure Manipulation ...

P to a given number q. This condition can be used, for example, to check the

values of ages o r salaries in a personnel file. .

As with the f i rs t two. conditions, a temporary range N is specified by Method Cr

IV. Every node in M (i. e . , those nodes specified by hierarchical context) which

has within i ts subtree a node in N which has at least one label which is numeric

: . . and whoge value stands in the given relation P to the given number q is retained

in the range. If a node has more than one numeric label, only the first will be

considered. Any node in M which does not have within i ts subtree a node in N

which has at least one label whichis numeric and whose value stands . in l11e given .

relation P to the given number q is not considered to be in the range. More

formally, if V is the value operator, i. e. , a function whose argument is a numeric

label and whose value is the value of the label, and if U is a predicate whose

argument is a label and whose value is true if and only if the label is numeric,

then' the range R i s defined by . .

: . ~xamples . (see Fig'. 2) . . ,

Evocation Node numbers in range

Studeiit within S ~ ~ I I I U L J w liesever

Salary > 250 (22, 23)

Student within Stanford wherever

Salary > 350.25 b3\ School wherever Salary within

- . d Professor ;. 1 0 U O

School wherever Salary within

Student > Y O 0

. . . .

Page 32: TAXL-A simple Hierarchical Data Structure Manipulation ...

. . F . Conclusion

It can now be seen that there a r e many ways to specifjr a range, and that the

Principle of Greater Specification applies within each of the methods and conditions

a s well a s over all of them. The user need only specify a s little context as is

required to choose those nodes toward which he wishes to draw attention. Greater

specification can only reduce the -number of nodes towards which he is drawing

, attention. In addition the data base is being addressed by labels which have semantic

content to the user, in conjunction with English language words and forms which

appear to have high semantic content with respect to the data base attention

focusing which occurs.

Thus far, no attempt has been made to explain how ranges a r e used once

they have been specified. The next chapter explains the use of the primitives

which build and manipulate the data base. These primitives operate on ranges

a s specified by the rules explained in this chapter.

Page 33: TAXL-A simple Hierarchical Data Structure Manipulation ...

CHqPTER 111

DESCRIPTION OF THE PRIMITIVES

The preceding chapter described methods whereby a range, i. e. , a set of

nodes in the data base, may be specified. Specifying a range simply focuses

attention on a particular set of nodes; no nodes a r e added or deleted from the

data base nor a r e any connections between nodes altered. In this chapter, a set

of primitives for adding and deleting nodes and altering connections between

nodes will be explained. Which nodes a r e , , affected by the primitives is determined

by specifying a s many ranges a s each prirqitive requires.

It was seen in the preceding chapter that attention is focused on a set of nodes

by citing labels which the user has specified and therefore have semantic content

for him along with English words which a re highly suggestive of the relationships

which exist among the user's data. Continuing in this vein of making the language

and system easy for the user to learn and use, i t w i l l be seen that each primitive

is easily identifiable by an English keyword whch is highly suggeutiire sf thc

effect the primitive has on the data base. Table 1 lists the primitives by their

keyword and gives lhe use sf each.

The primitives are, of course, not absolutely prlmlllve. There is a oontinuum

of primitiveness, and a choice of what part of the continuum irom tiihlch to chuuse

any system's primitives must be made. The choice depends on the use to which

the grimitives will be put. If the primitives a r e loo primitive, too many steps

will be necessary to do any useful work. 0 1 1 the other hand, if the primitives

a r e too general, the control over the structure being manipulated by the primitives

will not be fine enough. These considerations have been taken into account when

choosing the point along the conlinuum from which the primitives given in Table

1 were taken.

Page 34: TAXL-A simple Hierarchical Data Structure Manipulation ...

PRIMITIVE

' CREATE

LABEL

UNLABEL . .

WRITE

COUNT

PUT

COPY

SEVER

DELETE

SAVE

RESTORE

TABLE 1

THE PRIMITIVES

USE -

Creates new nodes in the data base

Adds labels to nodes in the data base

Removes labels from nodes in the data base

Writes part of the data ,base

Counts nodes in the data base

Builds relationships in the data base

Copies nodes and relatio~iships and builds relationships in the data base

Destroys relationships in the data base

Destroys nodes and relationships in the data base

Saves part of the data base in secondary storage

Restores part of the data base from secondary storage

Page 35: TAXL-A simple Hierarchical Data Structure Manipulation ...

A. CREATE

The CREATE primitive adds a new node to the data base by giving the set of

labels which the data item at the new node will contain. At least one label must - be given, and the labels occur within the new data item in the order in which they

a r e given. The syntax for the CREATE primitive is :

<create primitive > : : = CREATE <data items> , .

<data items > : : = <data item> I <data items> apd <data item>

\~ Nati.ce that more than one data Item may be created with one use of the CREATE

primitive by separating the labels of the data items to be created by the word

"and. l 1 The user may visualize thk new hqdes which a re created as existing

~~nat tached as new roots of the graph in the data base. No connections a re made

or altered nor a r e any already existing nodes within the data base altered.

By this time the reader should observe that certain words a re held in reserve

status and recognized by the system a s special delimiters, A complete list of

these reserved words is given in Table 2. It is often the case that a user may

want one or more of these words to pccur a s a labei wlthii one OF more &ah lle~irs.

Surrounding any word or set oT wurds , ~ i t l ~ i a a .: data item> with quote marks

causes the system not to treat any words within the quote marks as reserved UiOPds.

In this way, any word may be included as a label within a data item.

CREATE Stanford University

CREATE MI'I' and Caleech

CREATE "A. node containing all these words including the word createM

Page 36: TAXL-A simple Hierarchical Data Structure Manipulation ...

TABLE 2

RESERVED WORD LIST

BEFORE

BELOW

CREATE

DELETE

FROM

JUST

NOT

PUT

RESTORE

SAVE

SEVER

TQI

VALUE 1

WLIEREVER

WITHIN

WRITE

UNLABEL

See also Table 3 for the reserved words of BASIC.

All of the above words when not enclosed in quotes

should be considered delirnitkrs, including . . an "ehd

of line" character which denotes the.end of a command.

. . .

Page 37: TAXL-A simple Hierarchical Data Structure Manipulation ...

B. LABEL

The LA.BEL primitive allows the user to add new labels to already existing

nodes. What i s required i s the specification of a set of nodes to which the labels

will be added and the new set of labels. The set of nodes towhich the labels will

be added is given by specifying a range as described in the preceding chapter.

The syntax for the LABEL primitive is:

<label primitive > : : = LABEL < range> a s <data item>

The (data item> is the set of new labels. These new labels are added after

the last label which existed a t the node before the label primitive was evoked.

The new set of labels i s appended to every set of labels at all the nodes specified

by the range.

If i t is desired to insert a new set of labels at some point in the existing

data item other than after the last label in the data item, the following alternative . .

syntactic construction may be used:

<la.bel primitive> : : = LABEL <range> as <data item>

before <label>

The new set of labels given by the <data item> w i l l be inserted beforc the

already ocnl~rring: <label> in dl the nodes specified by the <range> . If the

already occurring <label> occurs more than once within some node in the

< range > , the new set of labels given by the Cdntu ltcr11;. w i l l be ii~serted bcborc

the f i r s t occurrence of the <label> . If the <label> does dot already occur

within some node in the <range> , the new set of labels is.added at- the elid of the "

, ,

existing set of labels at that node, a s in the previous construction.

Page 38: TAXL-A simple Hierarchical Data Structure Manipulation ...

Example (see ,Fig. 2)

Evocation:

LABEL Miller within St,anford a s William before Miller

Effect: / 61

Assoc. Provost

\ '

William Miller

Professor William ~151 . .I I

Evocation:

LABEL Engineering Department a s Electrical

Effect: I . . . . 1 . . .

1 Mechanical Engineering El21

Electrical c2 01 Engineering

Department Electrical \

Department Electrical ' /.

C. UNLABEL . . .

The UNLABEL primitive allows the user to remove .labels from existing nodes.

A.s in the LABEL primitive, a set of nodes, specified by a range, along with the

set of labels to be.removed must be evoked. The syntax for . . this primitive is:

<unlabel primitive> :.: = UNLABEL .= range> as <data item> , .

All the nodes in the <range> a re first identified, then all the labels in the

<data item> a re removed from each of these nodes. The labels in the <data item\

a r e removed one by one and do not have to occur in the same order as they occur

within the nodes in the <range> . Labels in the <data item> which do not already

Page 39: TAXL-A simple Hierarchical Data Structure Manipulation ...

exist at some node in the <range> cannot, of course, be removed. In addition,

the last label cannot be removed from a node, thereby leaving a null data item.

Observe that to completely relabel a node, the new labels should first be added

using the LABEL primitive, then the old labels removed by using the UNLABEL

primitive. If a label to be removed occurs more than once at some node in the

<range> , only the f i rs t occurrence of that label will be-removed. However, if

a label to be removed occurs twice for example, within some node in the <range>,

and that label occurs twice in the set of labels to be removed, then both o.ccurrences

will ,be removed. . .

Example (See Fig. 2) . . . .

UNLABEL Sheldon Becker as ~ k d e n t . . .

Effect:. . I

Sheldon Recker [l81 . ,

Evocation:

UNLABEL Secretary within Comput,er Science a s Secretary

Effect:

Grace Mickelson Carla West c2 11

UNLABEL Electrical Engineering Department as Department Engineering

Effect: I

Page 40: TAXL-A simple Hierarchical Data Structure Manipulation ...

Evocation:

. . . UNLABEL Salary Classified a s Salary Classified . . . .'

Effect : Illegal

The prec,eding three primitives add new unattached nodes to the data base and

add and delete labels from the data items at nodes. specified by a range, respectively.

The data base is altered by.the use.of. these primitives a t the data item level: no

relationships between data a r e .altered. . - ;.. .

, .The following two primitives ,are useful for query purposes . . . only. . ,The data

.. % base is not al teredin any way ,by the use .of these primitives. . Rather, an immediate

response is typed out a t the terminal.

D. COUNT . .

The COUNT primitive informs the user of the number of nodes'in a given

range, i. e . , the cardinality of the .range. The data base is not altered in any

way by the use of this primitive.

, The syntax for this primitive is:

<count primitive> : := COUNT <range> . . . . . , . . .

Example (see Fig. 2)

Evocation: . .

COUNT Student within Stanford . .

, ,. . . . Response: 3

Evocation: . .

COUNT ~ e ~ a r t m e k t within Stanford wherever Professor is within Department

. . . .

Response: ' 2 . . . ,

Evocation:

. COUNT Professor,,within Engineering . Schopl .

Page 41: TAXL-A simple Hierarchical Data Structure Manipulation ...

\

E . WRITE

The WRITE primifi$e causes a part of the data base to be printed in an outline

format with proper indentations to denote the various hierarchical levels.. For

each node, the labels in the data item at the node a re printed in the order in which

.they occur within the data.item.

Theasyntax of the first form of the WRITE primitive is:

<write primitive> : := WRITE <range>

Every node in the-<range>, with all the subtrees of each node properly

indented, is printed. The subtrees at each level a r e printed in an arbitrary order.

If there a r e no nodes in the specified range, then an indication of this fact is

printed.

Example (see Fig. 2) . . , .

Evocation:

WRITE Department within Humanities

Response : I

Communication Department Professor Parker

Computer Science Department Student Sheldon Becker Professor Miller

Secretary Grace Mickelson Secretary Carla West

Salary Classified Chairman Professor Forsythe

Evocation:

WiU1I'E Professor within Eloulriual Ei1gia6ePfkig . . . . . ., , . ,. . . . . . . . . . .

Response:

Null range

If the data base has the form of a tree, then an outline, as demonstrated

above, with no duplications within the outline, would always result from the use

Page 42: TAXL-A simple Hierarchical Data Structure Manipulation ...

of the WRITE primitive. However, since the data base has the form of a directed

acyclic graph, unnecessary printing of duplicate subtrees could result in

response to one evocation of the WRITE primitive. To alleviate this unnecessary

printing, only the root node of any subtree which would be printed the second o r

subsequent time in response to a single evocation of the WRITE primitive, along

with an indication that the entire subtree has already been output, will be printed.

Examp1.e (see Fig. 2)

Evocation:

WRITE ' Miller

. . 'Response:

Professor Miller Secretary Grace Mickelson Secretary Carla West

Salary Classified Assoc. Provost Miller

Secretary Carla West <occurs above>

Evocation:

WRITE School of Engineering

Response:

School of Engineering Electrical Engineering Department

Student Hardy . .

Salary $300.53 Wife Susan

Mechanical Engineering Department Student Hardy <occurs above> Student Laurel

. .. Salary$4QO

Page 43: TAXL-A simple Hierarchical Data Structure Manipulation ...

Evocation:

WRITE Provost

Response: . .

. ,Provost Lyman . . ,. . .

Assoc. provost Moses Assoc. Provost Miller

secretary Carla West Salary Classified.

, . . . Assoc. Provost Moses <occurs above> Assoc. Provost Miller <occurs above>

It is sometimes desirable to print only the nodes in the range without their

subtrees. The syntax of this second form of the WRITE primitive is:

<write primitive> : : = WRITE only <range> '

Example (see Fig. 2)

Evocation:

WRITE only University

Response:

Texas Ulriversity Stanford University

WRITE only Student wjthin Stanford

Response:

Sti~dent. T,snrsl Student Hardy . ,

Student Sheldon Becker . .

Thus far , the primitives which have been introduced.do not alter the relation-

ships between data. The following four primitives build and destroy the hierar-

chical relationships between data.

Page 44: TAXL-A simple Hierarchical Data Structure Manipulation ...

F.. PUT - , . .

., ' . . The PUT primitive builds hierarchical relationships between existing nodes.

Two ranges a r e specified, and every node in the first range is made td be one

level hierarchically inferior tb every node in the second range; subject to two '

restrictions. Thus, if there a r e n nodes in the f i rs t range, and m nodes in the

second range, then n x m hierarchical relationships a r e formed if none of the

restrictions a r e violated. The restrictions are:

1) No more than 1 direct (i. e . , one level) hierarchical relationship may

exist between any two nodes. That is , the following s i tbt ion may not

2) No node may be hierarchically inferior (or superior) to itself. That is,

For every possible pair of nodes in the first and second ranges, respectively,

a direct hierarchical relationship is built so 10,ng as none. of the restrictions a re

vidlated. Under no conditions a r e any existing relationships altered in any way.

The syntax for the PUT primitive is : . .

<put primitive> :' : = PUT <range> into <range > 2

AS suggested by the syntax, except when the restrictions would be violated,

a direct (one level) hierarchicalrelationship i s built from every node in <range>

to every node in <range > l.

Page 45: TAXL-A simple Hierarchical Data Structure Manipulation ...

Example (see Fig. 2)

Evocation:

.PUT Student within Engineering into Law School

Effect :

' C51 Law School

1 Dl Student Laurel

Evocation: . PUT Secretary into Provost Miller

Effect:

\ Professor Miller Cl53 ~ s s o c . Provost P I

Miller

\ Professor Miller ~151

~ s s o c . Provost P I

Secretary 1 c91]Mi1:" Grace Mickelson Secretary Carla West I2 11

I

A shorthand combination of the CREATE and PUT primJtJvss is useful

while building data bases. If is specifiedk$ Method II of the preceding

cllapler, 1. e. , will~uul .ally l i i e ~ a r c l ~ c a l or S U ~ ~ P C C contcxt, and if that ran@ i~

null, then a node having the given set of labels wi l l f irst implicitly CREATEtd

and a message output to the user that this creation has occurred. The YU'l'

operation will then proceed a s described.

Example (see Fig. 2)

Evocation:

PUT Student Henry Bauer into Cor~lputer Science 1

Response :

Student Hcnry Bauer Created

Page 46: TAXL-A simple Hierarchical Data Structure Manipulation ...

Effect :

' / 1 Student Henry Bauer \

G. COPY

It is sometimes desirable to be able to copy part of the data base so that

further processing may be done on the copy without disturbing the original. The

COPY primitive gives the user this capability. This primitive has three syntactic

forms, the first of which is: I

<copy primitive> : : = COPY <range>

A, copy of each node in the <range>, along with i ts entire subtree complete

with all the relationships which exist there, is made. These copied nodes,. with

their subtrees, a r e left unattached a s roots in the data base. The original nodes

and their subtrees a r e not altered in any way.

Example (see Fig. 2)

Evocation:

COPY Provost Miller

Effect: I D. 11

Provost Lvman .

1 t6b Assoc. Provost Miller

I , , Secretary

A.asoc. Provost Miller [z 81 I

I Secretary Carla West ~291

I I

Salary-Classified L3 01

I Salary Classified C24I

Page 47: TAXL-A simple Hierarchical Data Structure Manipulation ...

Evocation:

COPY Professor within Computer Science within Stanford

Secretarv F!I

Effect: .

/ Chairman C28I Professor 1291

Computer Science 01 Professor Department F ors-ythe

Carla. west

/ Chairman [GI

Professor Forsy tile

I Salary Classified 1241

Secretary

Professor Miller [l51 Grace

Secretary ~3 11 Carla West

The second form of the COPY primitive allows the user to make a copy and

PUT the copy somewhere into the hierarchy. ore specifically, two <range>'s

Student Secretary Sheldon Grace Becker Mickelso~l Salary

Classified

a r e specified. A copy of each node in the first range (along with i ts subtree and

all connections intact) is made and PUT into the hierarchy for each node in the

second <range> . That is, as many copies of the first range are made a s there

a r e nodes in the second range into which the copies a re PUT. This second form

of the COPY primitive is thus a shorthand combination of (possibly) several appli- . .

cations bf the first form of the COPY primitive and PUT primitive operating on

the copy.

Page 48: TAXL-A simple Hierarchical Data Structure Manipulation ...

The syntax is:

<copy primitive > : : = COPY <range> to <range>

Example (see Fig. 2) . ,

Evocation:

COPY Student within Computer Science to Department within School

of Engineering

Effect: . . .

Electrical r2 ' , Mechanical C121 Engineering Engineering

Student Sheldon Bcclcer I

Student Sheldon C281 - Student ~291 Becker ~hefdon Becker

The third variation of the COPY primitive is, in reality, an addition which

can be made to. the first two forms. As suggested by the form of the WRITE

primitive which allows the user to write out only the root nodes of certain subtrees . .

by including the keyword "onlyM in the evocation of the primitive, only root nodes . .

of specified subtrees can be copied, and in addition entered into the hierarchy if

desired. The syntax of this variation of the first two forms of the COPY primitive

i s :

<copy primitive> : : = COPY only <range> : ' "

<copy primitive> : : = COPY only %range> to <range>

In the first case, :only the nodes specified by the <range>, without their

subtrees, a re copied and the copies a re left unattached a s roots in the data base.

In the se.cond case, a s many copies of the nodes specified by the first <range>

(without their subtrees) as there a re nodes in the second <range> a re made and

Page 49: TAXL-A simple Hierarchical Data Structure Manipulation ...

the copies are PUT into the nodes in the second<range> . In both cases there . ,

is no alteration of any kind made tcj . the . > , original nodes or q e i r subtrees.

Example (see Fig. 2)

Evocation.:

COPY only Provost Miller

Effect:

/ C161 Assoc. Provost

Miller .,.,,..,.,,.,.. "~ ,--*. " . ? , A . . *,...", ,-.. -.--

A S S ~ ~ , Provost C2 81 Mi.ll.er

_ I , . .

I C241 Salary C l a s s i f i c .

Evocation:

COPY only Professor w i t m Computer Science Department witgin

Stanford.

/ CBairlnarl L2 81

Professor Forsythe

Chairman Professor Forsythe Professor Miller [353 . ..- ,c

1 Es] Student Sheldon Becker

I Seoretary Carla West C2 lI

I Salary Classified PI

Page 50: TAXL-A simple Hierarchical Data Structure Manipulation ...

Evocation:

COPY only Student within ~ o m ~ u t e r s c i e n c e to Department within

School of Engineering

Effect: Same as a preceding example with "only" omitted, since all

students within Computer Science have no subtrees.

The preceding two primitives, PUT and COPY, build new relationships

between data and, in the latter case, implicitly create new data. The following

two primitives, SEVER and DELETE, destroy relationships between data, and,

in the latter case, destroys data a s well. ,

H. SEVER

The SEVER primitive destroys relationships between data but never data

L itself. As with the DELETE primitive to follow, the SEVER primitive has two

for,ms. In both forms, at least one range is specified. In the first form, all <

nodes in the specified range a re made to have no nodes hierarchically superior

to them; that is, those nodes a re SEVERted from the tree and become roots of the

tree. The subtrees of the nodes which a re s o cut off from above a r e left undisturbed

unless some of the nodes within them a r e also being severed. The syntax of this

form is:

<sever primitive> : : = SEVER <range>

After this primitive has been evoked, all nodes in the specified <range> are

roots of the tree, there being no nodes in the data base within which they exist.

Example (see Fig. 2) , ,

Evocation: . .

SEVER Computer Science within Stanford . . . . . .

Page 51: TAXL-A simple Hierarchical Data Structure Manipulation ...

Effect:

I' School of /Humanities L61 Computer Science r101

De artment

Communication Department ~ 9 3 T 5 1 I?Gofessor Assoc. Provost 61 Miller

Miller

Carla West

Observe that n6de [lo] is now a root ofthe tree. Yet, a node in its subtree,

i. e., node [21] remains attached to node [16]. Recall that no relationships within

the subtree of a severed node a r e altered, . .

Evocation:

SEVER Student within Engineering Department within Stanford

Effect:

Student r221 Student Electrical Hardy . Laurel Engineering Engineering Department Department

Evocation:

SEVER Carla West

\ P63 Cl51

Assoc. Professor Miller Provost . ,

1 Miller

I P I Secretary Grace Gckelson

Secretary p2 11

Carla West I I

Salary Classified [24

. ,

In the first form of the SEVER primitive, all nodes in the range were com-

pletely severed from the tree; that is, all of the relationships which connected

these nodes immediately from above the nodes were severed. The second form

Page 52: TAXL-A simple Hierarchical Data Structure Manipulation ...

of the SEVER primitive allows the user to selectively sever some of the relation-

ships which connect the nodes immediately from above the nodes. The selection . .

is accomplished by specifying a second range. Those connections immediately

above a node in the f i r s t range a r e severed which causes that node to be within

any node in the second range., Thus, nodes in the first range a r e severed from

.nodes in the second range. The, syntax for this forni is tllus:

<sever primitive> : : = SEVER <range> f rom. . <range>

. . . . Example (see Fig. 2)

Evocation: . . . , \

SEVER Carla West from Assoc. Provost Miller

Effect:

\ Professor Miller ci5] ' [IS] Assoc. Provost

Miller

' ~191 Secretary Grace Mickelson

\ .

Notice that only that relationship which causes node [21] to be within node

(161 i s broken.

SEVER Carla West 'from Stanford

Effect: Same a s a previous example whose evocation was:

SEVER Carla West

, since all connections immediately above node [21]

cause iiode [2 $ to be within node [2].

Page 53: TAXL-A simple Hierarchical Data Structure Manipulation ...

Evocation:

SEVER Student within Computer Science from ~ l e c t r i c a l

Engineering Department

Effect: No effect since none of the connections aboire aode [18] (thk 1st . -

range) cause's node [18] to be within any node of the sec'ond range.

A unifying concept which may lessen any difficulty in understanding the dis-

tincition between the two forms of the SEVER primitive,is the following. ~ h n k

of the first form of the SEVER primitive a s having a second range which specifies

all the roots of the tree. The first form is thus a special shorthand version of

the second form, since any node in the tree is either a root of the tree or is

hierarchically inferior t8 some root of the tree.

The DELETE primitive has two fornis, precisely analogous to the SEVER

primitive. The syntax of these forms is:

<delete primitive> : : = DELETE <range>

<delete primitive> : : =. DELETE <range> from <range> Z

As with the two forms of the SEVER primitive, the first form of the DET,ETE

primitive is merely a shorthand vsr'sion nf the second fob with an implicit rang'o

which specifies all the roots of the tree. Thus, in the action of this primitive,

some node is being deleted - from a set of nodes.

It' a node x is in the first range and its position in the data base is such that

x is also within the second range, then node x is a candidate for deletion. In

order toxnderstand the. manner in which the DELETE primitive operates, several 2

simplifyik assumptions concerning the configuration of the data base near node

x will first be made. As the operation of the DELETE primitive becomes clearer,

these assumptions will be removed. ,

Page 54: TAXL-A simple Hierarchical Data Structure Manipulation ...

Consider f irst the simplifying assumption that node x together with i ts subtree

is a complete unit, sharing its information with the rest of the data base only

through, a t most, node x (if x is a root, the information is not shared a t all).

More specifically, every node within the' subtree of x is not within the subtree

of any other nodes except other nodes within x's subfree o r nodes hierarchically

superior to x. Examples of such nodes x from Fig. 2 include [8], [2], [I], [22], . . . . . . . . . . ., . .

and [2l], bit not [6] or [lo] o r [15] o r [12] or [20].

Now assume that - all connections immediately superior to x cause x to be

within the second range in an evocation of the DELETE primitive. The action of

the DELETE primitive will then cause the node x and every node within the subtree

of x to be erased from the data base. I

Example (see Fig. 2)

Evocation: . . . . . .

DELETE School of ~ngineer ing from 'stanford

Effect: , Stanford UniversityC2] / I \

/ I

Law School c51 ' School of Humanities Administration and S c i e r e s . -I 71

Evocation: n

DELETE Student within Engineering Department from

Effect :

Electrical c2 01/

~ c h o o l of Engineering

, \ . .

School of Engineerid8] / / \

\ Mechanical [12] Engineering

Department Engineering

Department

Page 55: TAXL-A simple Hierarchical Data Structure Manipulation ...

Now remove the most recent simplification and assume that not all connections

immediately superior to x cause x to be. within the second range in an evocation of

the DELETE primitive. This means that x.and its subtree contain' information

relevant to some other nddes in the data base besidesthe nodes from which x is

to be deleted. It would thus be incorrect to erase x and its subtree from the data

base; rather, only the connections between x and the nodes from which x is to be

deleted should be erased. In this case, the DELETE primitive is 'seen to operate

precisely as, the SEVEK primitive. ,

:Example (see Fig. ,2)

Evocation:

DELE'I'E Carla West from Professor Miller 4

Effect:

\ Professor Miller [15]

I I

Secretary Grace E91 Miakels on

/ ASSOC~ Prrost Miller P61

I

Secretary .Carla West t2 11

' [241 Salary Classified ... .-

Now remove the original simplification and assume that the subtree of x, is

1 not a complete unit and that information within x's sibtree is shared with the rest

of the data base through nodes other than x. More specifically, there exi.et nodes

within the subtree of x which a r e within the subtree of nodes other than those within

x's subtree or nodes hierarchically superior to x. Examples of such nodes x from

Fig. 2 include [6], GO), [15], [12], and [20]. As before, it would be incorrect to

erase those nodes (and their subtrees) within x's subtree which share common

information with other parts of the data base, i. e., those nodes (and their subtrees)

which.are within the subtree of nodes other than those within x's subtree or nodcs

Page 56: TAXL-A simple Hierarchical Data Structure Manipulation ...

hierarchically superior to x. So, a s before, only the connections between these

common nodes and the res t of x's subtree is erased.

Example (see Fig. 2)

Evocation:

DELETE Provost Lyman from Administration within Stanford

. Effect:

\ Administration C71

\ Professor Miller b51

/ 'i

/ \ Secretary Carla West C2 l] Secretary Grace L19 I - -

Mickelson Salarv Classified ~241

Evocation:

DELETE Student from Mechanical Engineering '

Effect:

[20] Electrical Engineering

Department I

\ Mechanical Engineering @I

Department

The heart of any data base system is the ability of the user to create a database, save

i t away somewhere (the user should not have to worry about where) and go away

to do something else. At some later time, the user should be able to fetch his

data base, query i t o r modify it, and save it away again for still further processing.

As background to any implementation, therefore, there should be a file system.

The following two primitives allow the user to interface with the file system in a s

easy and simple a manner a s should be possible for him.

Page 57: TAXL-A simple Hierarchical Data Structure Manipulation ...

SAVE J* - The SAVE primitive allows the user to save parts of his data base in quantities

of complete units a s discussed i n the preceding explanation of the DELETE primi-

tive. The syntax for this primitive is:

<save primitive> : : = SAVE <range>

The effect of an evocation of this primitive is to cause each node in the range

with its entire subtree (nodes and connections) to be removed from the data base

(just a s with the DELETE primitive) but saved in such a way so that the structure

which has been removed from the data base can be rel;ur~red lo the data base at

I some futurc time in precisely the same form in wh.jch it was saved.

The only restriction which applies to the use of this primitive is that the

(sub) tree being savedmust be a complete unit and cannot share its information

with other parts of the data base except through its root node. Thus, each node

and its subtree which is being saved must satisfy both simplifications mentioned

in the explanation of the DELETE primitive. If part of the data base to be saved

shares its information with other parts of the data base, the part to be saved

must f i rs t be COPY 'ed and then saved. /

K. RESTORE

. , The RESTORE primitive restores nodes and their subtrees to the .data base

in precisely the form in which they were saved. This primitive has two forms,

. . the second of which is a shorthand form for restoration and placement within the

hierarchy. The syntax of the first form is:

<restore primitive> : : = RESTORE <range>

The <range> in the use of this primitive must be a range specified by Method

II of the preceding chapter. Thus, there may be no hierarchical context of any

kind in the specification of this range. The set of saved nodes is searched and

Page 58: TAXL-A simple Hierarchical Data Structure Manipulation ...

the saved nodes having at least the set of labels a s that specified in the <range>

a r e removed (with their subtrees) from the saved area and restored to the working

data base a s separate trees with the root nodes of the saved subtrees becoming

roots in the data base.

The second form of this primitive is:

Crestore primitive> : : = RESTORE <range> to <.range>

The f i rs t <range> must satisfy the same requirements as before and the

same action occurs a s before in the saved area. However, once the nodes a r e . ~

removed from the saved area, the action of this primitive is equivalent to an

evocation of

PUT <range> within <range>

where the first <range> is the set of nodes just removed from the saved area,

and the second <range> i s the same a s the second <range> in the evocation of the

second form of the RESTORE primitive.

L. Conclusion

This chapter has described a set of primitives for creating, manipulating,

querying, and destroying relationships and data within the data base. It should

be observed that no arit11met;io procetssing nor any programming structure i s

possible within the framework of primitives discussed thus far. The next chapter

describes the design of a programming system in which TAXL and a language

such as BASIC are incorporated to yield a system in which both numeric and

nonnumeric data processing capabilities a r e available both independently and in

a manner in which the numeric and nonnumeric data bases may interact.

Page 59: TAXL-A simple Hierarchical Data Structure Manipulation ...

CHAPTER IV

THE TAXL/BASIC SYSTEM

The range specification mechanism and i ts use in the evocation of the data

base primitives presented thus far yields a system in which commands a r e inter-

preted a s they enter the system and a re executed immediately. In addition, no

arithmetic capabilities have been introduced thus far. A.s was pointed out in the

introduction, the BASIC prugranltuiilg lalgungc and oyotom (Kemeny [I 967]),

designed by Kemeny and KWti at Dartmoutlx, pruvides an exccllcnt oasy-to-learn-

and-use interactive computer system for arithmetic prucessi~lg. Rather than

design an arithmetic capability which would be included in TAXL, a design for

merging a version of BASIC and TAXL will be given. The version of BASIC .4

. .

most nearly like that which w i l l be .discussed here is that version written at

Hewlett-Packard, a system quite similar to the,.Dartmouth system. The 'reader

is expected to be familiar with some BASIC systcm in the discussion which

follows . T h e degree of interaction available in this version of BASIC, a s in most

versions of BASIC, i s different from the immediate interpretation and execution

of the TAXL commands considered thus iar . This difference should be well

understood. The key to determining the degree of interaction of drl on-line cum-

puter system is the specification of the data which is being manipulated.

Presumably, the data which the user would ultimately want to manipulate

is the t ree data base itself, along with the values of certain arithmetic variables

and arrays. If the system recognizes commands to manipulate that collection of

data, then that degrcc of interaction shonld he considered the strongest. Instead,

if the system recognizes commands to manipulate commands which manipulate the

Page 60: TAXL-A simple Hierarchical Data Structure Manipulation ...

data base in question, then the degree of interaction is less strong. The Hewlett-

Packard BASIC system is of this second kind. The data which i s immediately

manipulated by HP BASIC commands as they a re enteredvia a teletype is a

program buffer which contains commands which will manipulate the values of

arithmetic variables and arrays when the program is executed. The commands'

found in the program buffer which, when executed, cause the values of variables

and arrays to be manipulated and hereafter called BASIC commands, cannot be

entered and execulied directly as a re the TAXL commands. It appears, then,

I that TAXL commands, a s discussed thus far, a re only executable directly as

they a re entered into the system, and that BASIC commands a re only executable

indirectly after they have been entered in a program buffer.

I feel that both degrees of interaction should be available for both TAXL and

BASIC commands. That is , TAXL commands should be able to be put into a

program buffer for later execution and certain BASIC commands should be able

to be directly executable a s they a r e entered into the system. In keeping with the

spirit of this work, the distinction between which degree of interaction tLe user

desires a s he types commands into the system should be clear and straightforward.

It should be remembered that every TAXL command, a s well a s every BASIC

command, begins with some English keyword which strongly suggests the action

the execution of that command will have. Which degree of interaction the user

desires for each command he enters into the system can be indicated by him by

the presence or absence of an integer number prkceding the English keyword which . .

actually begins the command. Thus the following holds for both TAXL and BASIC \

commands. If an integer number is not present preceding the English keyword, .

the command will be interpreted and immediately executed. If an integer number

is preacnt preceding the English keyword, the command will not be immediately

Page 61: TAXL-A simple Hierarchical Data Structure Manipulation ...

executed but w i l l be entered into a program buffer with a sequence number equal

to the value of the integer number which preceded the command. /

A. Syntax Analysis . .

In the latter case, the question of when the syntactic structure of the command

is checked is open to debate. While this is basically a question of implementation,

the answer wili affect the learning behavior of the naive user. . Since one of the

design goals of the language is ease and speed of learning the language, the question

shodd be considered hcrc. Kemeny and Kurtz felt that the syntactic structure of

the commands should be checked immediately to see if a syntactic e r ror occurred in the

command. This philosophy has been followed in H P BASIC, a.s in most BASIC

implementations. The authors of some APL systems (Falkoff [1968]) follow a

different philosophy. Their belief is that the command should be entered into the

program buffer without i ts syntactic structure being checked, and not until the

execution of the command is about to commence will the user he. notified if a

syntactic error has indeed occurred.

Psychological studies on learning and training behavior (Wolfle [1951]) indicate

that immediate feedback speeds the learning process. Since one of the requirements

of this system is that it be easily learned, immediate feedback of syntactic errors ,

wherever possible, seems preferable to delayed feedback. If the user is not

informed of a syntactic e r ror which occurs in a command as it is entered into the

system, he may mistakenly feel that since the system h a s accepted the command,

the cummand is correct. It is at precisely this moment, when the user's attention

is more focused on the one command in question than at any other time in the

program's formation, that the user should be informed if a syntactic error exists

within the command. This concept is not too unlike programmed readers in which

the reader must successfully answer a question before he can proceed. By the

- 52 -

Page 62: TAXL-A simple Hierarchical Data Structure Manipulation ...

time the user has given the command to begin execution of the commands in the

program buffer, his attention will usually be more focused on the program a s a

whole and on its semantic structure rather than its syntactic correctness. To be '

informed of a syntactic error during the execution of the program would be more

of a hindrance to clear thought than a help.

The conclusion of the preceding paragraph seems to be true only when the

goal of the user is to learn the syntax of the language. Once this has been accom-

plished and the goal of the user is to write useful and logically complex programs,

the facility of sketching out logical sections of program without having to be con-

cerned with their syntactic correctness at that time seems to be important. Thus,

the goal of the user should be a consideration in deciding whether the syntactic

structure of a command is to be checked at command entry or at command execution.

Since one of the goals of the current implementation is to facilitate learning of the

language rather than writing large programs, the syntactic structure of a command

is checked at command entry, ,

From an implementerls point of view, a translation from the commandls

external form to an internal format which is easier to execute and a syntactic check

of the command can be accomplished at the same time. Rather than do the trans-

lation every time the command is encountered during program execution, it is

more reasonable to do the translation once at command entry into the program

buffer. Because a syntactic check may be performed during command translation

with a minimum of extra effort, a syntactic check at command entry time is quite

desirable.

B . Command Classification

A. summary of BASIC and TAXL commands will now be given (see Table

3). Each command i s placed in one of three categories which gives that command1 s

Page 63: TAXL-A simple Hierarchical Data Structure Manipulation ...

TABLE 3

COMMAND CLASSIFICATION

TAXL/BASIC Command Classification Use

,CRJ3ATE BOTH Creates new nodes

LABEL BOTH Adds labcls to nodcs

UNLABEL BOTH Removes labels from nodes

WRITE BOTH Writes part of the data base

COUNT BOTH Counts nodes in the data base

PUT

COPY

BOTH

BOTH

Builds relationships in the data base

Copies nodes andrelationships and

builds relationships in the data base

SEVER BOTH , B s t r o y s relationships in the data base I .

. - .UE LJi'l' E BUl'l-1 Uestro-ys nodes and relationshps in the . .

' ' data base

SAVE HO'I'H Saves part of the data base in secondary

storage : ~ ~ s ~ ~ I ( - J H E BOTH Restores part of the data base from

READ

DATA

PRINT

LET

DEF

DIM

MAT---

GO TQI

TF

FOR NEXT

GOSUB

RETURN

STOP

LIST

CLEAR

RUN

secondary storage

BOTH Reads numeric data from data block

BOTH Enters numeric data into a data block

BOTH Types values of variables and arrays ,

BOTH Computes and assigns values to variables

BOTH Defines an arithmetic function

BOTH Ueclares dimensions of arrays

BOTH The 2-dimensional array instructions

PROGRA.M' Transfers control

P:H.(iK:;:KA.M Condi ti.onal transfer

PRCGWA,M Sel;s rq arid ulrerales a l u i ~ l ~

PROGRAM Closes a loop

PROGRAM Sets up and operates a loop to seauence

through nodes in a range

PROGRAM Transfers to a subroutine

PR0GRA.M Returns from a subroutine

I?ROGRAM, Glops apragranl

S BS Lists commands in the program buffer

SBS Rcmovcs commands from. the program buffer

SBS 'Iilitiates execution of cumman& in the

program buffer

Page 64: TAXL-A simple Hierarchical Data Structure Manipulation ...

permitted degree of interaction. Some commands w i l l be restricted to less than

the highest degree of interaction. Commands classified by the sign PROGRAM

a r e only allowed to be entered into the program buffer for later execut io~and so

must always be preceded by an integer number when entered into the system.

Commands which control program flow would make no sense if they were executed

immediately upon entry to the system since they require a program to give them

meaning. Other commands, the numeric data and data base manipulation commands,

classified by the sign BOTH, may be executed immediately upon entry to the

system o r ,may be entered into the program buffer for later execution. Hence,

these commands may have BOTH degrees of interac'tion with respect to the

system. ,

A. further set of commands will now be introduced which manipulate the pro-

gram buffer. These a r e classified by the sign SBS (statement-by-statement)

indicating that these commands must be entered into the system to be executed

immediately and cannot be entered into the program buffer for later execution.

Systems such a s LISP 1.5 and most assembly languages allow such program

manipulation commands to be programmable. However, this somewhat advanced

concept is not essential for TAXL/BASIC.

Entry of a corninand int;rj the program buffer is implicit and i s indicated I

by preceding the command by an integer number. The command then has

a sequence number equal to the value of the' integer number. If a command

is entered into the program buffer with a sdquence number equal to the

sequence number of a command already in the buffer, the new command

replaces the old command.

Page 65: TAXL-A simple Hierarchical Data Structure Manipulation ...

LIST . - Classification: SBS - The LIST command has three syntactic forms.

<list command> : : = LIST

<list command> : := LIST <integer number>

<list command> : : = LIST <integer number> / <integer number >

The first form causes the listing of all'commands in the program buffer,

along with the seqyence number of each, arranged in ascending numerical order.

Commands may he entered i ~ t o the program buffer in any order but will always

be listed in ascending sequence order. ' The second form causes o d y the listing , .

of the command in the program buffer having the given sequence number, if such

a comma.nd exists within the buffer. The third form causes the listing, in .

ascending numerical sequence order, of all the commands having a sequence

number whose value is equal to o r greater than the first integer number given

and is equal to o r less than the second integer number given.,

CLEAR - Classification: SBS

The CLEAR command removes commands from the program buffer, and has

three syntactic forms, analogous to the LIST command:

<clear command> : := CLEAR

<clear command> : : = CLEAR <integer number>

(clear command> : : = CLEAR (integer number > / t integer number>

The first form causes the erasing uf all commando in the program buffer.

The second form causes only the erasing of the command in the program buffer

having the given sequence number, il: such a command exists. The third form

causes the erasing of all the cornmaads in the prugram buffer h.o.ving sequence

numbers whose values lie between (and including) the given integer numbers.

Page 66: TAXL-A simple Hierarchical Data Structure Manipulation ...

RUN - Classification: SBS - The RUN command causes the program in the program buffer to begin

execution. This command has two forms:

<run command> : : = RUN

<run command> : : = RUN <integer number>

The first form causes the executior? of the program ir? the program buffer to

begin with the command having the algebraically smallest sequence number. The

second form causes the execution of the program in the program buffer to begin

with the command having a sequence number equal to the value of the given integer

number. If no such command exists, the user is notified.

Commands in the program buffer a re .normally executed in ascending numerical . . .

sequence unless this sequence i s altered by the execution of a command having the

classification PROGRAM. The program stops executing either when a STOP com-

mand i s executed, when control is transferred to a nonexisting command, or when

the next command to be executed should be the command with the next highest se-

quence number and no such command exists. In any case, the user i s notified

where (by sequence number) the execution of the program is terminated.

C. Interface Between TAXL and BASIC

The commands of both TAXL and BASIC have now been presented. The control

commands of BASIC have been adopted to properly organize program flow, and

several commands for manipulating the program buffer have been given. Thus

far, however, the3nly interface between TAXL and BASIC i s at the program level.

Commands from both languages may be evoked interchangeably for immediate

execution and commands from bothlanguages may occur in the program buffer.

What is needed to make the system more useful is an interface at the data level.

Page 67: TAXL-A simple Hierarchical Data Structure Manipulation ...

The data f o r TAXL a r e the numeric and nonnumeric labels a t nodes and

the hierarchical relationships of the directed acyclic graph data base, while

the data fo r BASIC a r e the numeric values of variables and a r r a y elements.

Some BASIC sys tems include a limited str ing processing capability; however,

such a capability var ies s o widely in the relatively few BASIC systems (e.g. ,

Stanford [1968]) which possess one that this workwil l not concern itself with '

such a capability.

Hecall now the kind of u s e r for whom 1Ns s y s l e ~ n is inle~~deil . Tllc l i l a i ~ r

emphasis of his use of this system will be in handling nonnumeric dala, lhe

opcrntiono for whioh a r o available from the TAXL primitives and d a t a h s ~ .

The reasons for including BASIC a r c thc prcsence of the programming control

commands and the arithmetic processing capabilities which BASIC pussesses . At the data level, BASIC operates only on numeric data. Thus, if an interface

between BASIC and TAXL is to be made a t the data level, i t must be a t the nu-

mer ic data level. Hecalling that labels a t the nodes in TAXLts data base car1

be numeric, i t becomes c lea re r that the data interface must exist a t the numeric

level, the only data type which the two systems have in common. The interface

must thus concern itself with the convenient retrieval of.numeric values from

TAXLt s numeric labels which can then be used in computation and assignment

in BASIC commands, and also in the conversion and placing of the values of

BASIC variables into'TAXLts data base in the form of numeric labels. In ad-

dition, since the COUNT primitive in TAXL results in a number being output,

the value thus obtained should also be able to be used in computation and assign-

mcnt within BASIC.

The discussion of this data irite.rface will now proceed i n four steps: the

extension of the use of one fo rm of the subtree context specification for referencing

values, a solution to the problem of whether an identifier which occurs in a

Page 68: TAXL-A simple Hierarchical Data Structure Manipulation ...

T ~ L / B A S I C command i s a BASIC variable or a TAXL label, the introduction

of a VALUE operator and an extension of the use of the COUNT primitive, and

the introduction of a new sequencing statement pair, analogous t o BASIC's FOR-

NEXT sequencing pair, for sequencing through the nodes in a range.

Recall that in Condition l3I of the subtree context specification of ranges, the

. values of numeric labels were compared with given numbers. The values were

retrieved by evoking a range and considering the values of any numeric labels

which occurred in any of the data items of the nodes in that range. This same

mechanism can now be used outside the subtree context specification of ranges,

particularly in arithmetic expressions .in LET statements of BASIC; Use of this /

mechanism in a BASIC construct, which retrieves more than one value, is not

allowed and will be considered a semantic error. Admittedly, a construct which

would allow the assignment or computation on a vector of values would be useful;

however, th i s somewhat advanced c'oncept would not add to the simplicity of the

language. Since extensions and complications in other areas 'of the language

would have to be made in order for this construct to have consistent application

throughout the language, and since there will be alternate methods of performing

the same computation, this construct is, therefore, not allowed.

Examples (see Fig. 2)

Evocation:

LET S = Salary within Laurel.

Effect: The BqSIC variable S is assigned the value 400

Evocation:

LET S = Salary within Stanford .

Effect: Illegal, since the range yields more than one value.

Page 69: TAXL-A simple Hierarchical Data Structure Manipulation ...

1 Since there is no keyword which indicates that a value is being retrieved

from the tree, confusion can arise ,over whether an identifier is a BASIC variable

o r a TAXL label.

For example, in the command

LET S = X

is X a BASIC variable whose value is to be assigned to S, or is X a TAXL label

being used to reference a range consisting of one node with a numeric label, the

value of which is to be assigned to S? Tlrls problem is solved by requiring that

at any given moment, the set of BASIC variables and the set of active (not in the

s&ed area) TAXL labels be disjoint. TAXL labels a re created by evocations of

the CREATE primitive (or by implicit creation in evocations of the PUT primitive),

and a r e destroyed by evocations of the DELETE primitive. Once an identifier which dl

was used as a TAXL label no longer occurs in the tree, it may be used a s a BASIC ,

variable. BASIC variables a r e created implicitly by their f irst occurrence on

the left-hand side of LET statements; prior to this creation, their value is

undefined and calulot be used. DASIC variables may be destroyed by their use

on the left-hand side of a LET statement having an empty right-hand side. For

example,

LET X =

destroys X as a BASIC variable and allows its subsequent use a s a TAXE label.

With the mechanism describcd thus far, values may be retrieved from the

TAXL data base and used in BASIC contexts. II+I order to allow the values of

BASIC variables to be placed in the TAXL tree or removed from it, an operator

which, when applied to a BASIC variable, returns i ts value is needed. This

operation is automatic when a BASIC variable is used in any arithmetic context.

However, in TAXL's LABEL or UNLABEL commands, for example, evoked

Page 70: TAXL-A simple Hierarchical Data Structure Manipulation ...

0

labels stand for themselves. In such a context, to force evaluation of the BASIC I

variable name to obtain i ts value which is then to be put into or removed from the

label set of some node in the tree, the VALUE operator must be used. .

Example (see Fig. 2) . .

Evocation: . \

LET S = Salary within Student Hardy within Engineering

Effect: The BASIC variable S is assigned the value 300.53

-Evocation: I

UNLABEL salary within Student Hardy as value S

\ 1 yc21 Student Hard

/ salary $ lZ5I

\ C263 Wife Susan

Notice in the latter example, that a label S does not occur within any node C

in the specifi'ed range, and thus the VALUE operator must be used in order to

remove the numeric labe1'300.53, the value'of 'S, from the node.

The COUNT construct, which appears in the subtree context specification of

ranges and is also a TAXL primitive, is extended only in the sense of where the

construct can occur; i t may now occur within any BASIC numeric expression

and yields the number of nodes in the specified range.

Example (see Fig. 2)

Evocation:

LET N = COUNT Salary within Stanford

Effect: The BASIC variable N is given the value 3

. .

Page 71: TAXL-A simple Hierarchical Data Structure Manipulation ...

FOREACH, NEXT - Classification: PROGRAM

The FOREACH and NEXT statements a re loop control statements very similar

to the FOR and NEXT statements of BASIC. Recall that the FOR statement causes

a BASIC control variable to take on successive arithmetic vaiues over a set of

statements. Every reference to the control variable within the set of statements

delimited by the FOR and NEXT statement has the value which is the current

value of the control variable. The FOR statement gives the initial value, the

final value, and thc incrcmcnt for tho oontrol variable. The execution of the N E W

statement causes the control variable to take on its next value and execution resumes

following the FOR statement. When the control variable has taken on all of its

prescribed values, execution resumes following the NEXT statement.

The syntax of the FOREACH statement is:

<foreach statement> : : = FOREACH <range>

Recall that every <range> must begin with a data item consisting of one or

more labels. This data item then becomes the control data item which w i l l take

on successive values over the set of statements delimited by the FOREACH state-

ment and its paired NEXT statement. The values which the control data item will

take on a re the nodes in the data base specified by the <range>.. Every reference

to the control data item within the set of statements within the FOREACH loop hag

the value which is the current value of the control data item, i. e., a node in the

<range>. The execution of the NEXT statement causes the control data item to

take on its next value and execution resumes following the FOREACH slal;einent.

When the control data item has taken on the value of all the nodes in the <range>,

execution resumes following the NEXT statement. Because the nodes in a range

a r e unordered, the control data item assumes its values in an arbitrary order.

Page 72: TAXL-A simple Hierarchical Data Structure Manipulation ...

The syntax of this version of the NEXT statement is:

(next statement> : : = NEXT t data item>

The rules for nesting of FOREACH statements follow the rules for nesting

of FOR statements.

Examples (see Fig. 2)

Problem: increase the salaries of al l secretaries in the School of

Humanities and Sciences by 10 percent.

Program:

FOREACH Salary within Secretary within Humanities School

LET S = Salary

UNLABEL Salary as value S

LET S = S + . l*S

LABEL Salary as value S

NEXT Sa.la.ry

D. Responses Following the Execution of Commands

Everyone who has ever worked a t a terminal using a system which has com-

mands which a re executed immediately upon entry to the system (having classification

SBS in TAxL/BASIC) occasionally has the feeling that the command last entered

might not have been executed at all or might have been executed incorrectly. This

phenomenon occurs particularly among novice computer users, the intended users

of TAXL/BASIC. Often, as seen by direct observation, quite a bit of output might

be requested by the novice user to assure himself that the command in question

was indeed execul;ed correctly. It has also been observed that almost any short . response by the system after the execution of any command in SBS mode informing

the user that everything i s "all right'' and that the system "understood1' and

executed his command properly gives the user added confidence and almost com-

pletely obviates his need for the assii'liallce vulpul r~lentioned above.

Page 73: TAXL-A simple Hierarchical Data Structure Manipulation ...

Commands which inherently cause output at the terminal, PRINT, WRITE,

and LIST, obviously need no assurance output. Commands being executed in

PROGUM mode, other than PRINT and WRITE, should have no assurance output

because of the possible volume of such output and subscquent slowing of execution.

Attention can thus be turned to commands being entered into the system for im-

mediate execution.

If a syntax e r ro r occurs in the command, then proper notification of this

fact is sufficient to convince the user that the system is paying attention. to him.

If there a r e no syntax errors , then execution of the command will commence,

and if there are no semantic errors which,occur whl'le the co~nmnnd is boing

executed, then output a s simple as

@K

is enough to assure the user that everything is in fact okay. Semantic e r rors

such as null ranges in TAXL commands, illegal tree structuring arising from an

improper use of the PUT command, illegal label mallipulation in the UNLABEL

comrnand,BASIC variables without values occurring in an arithmetic expression,

illegal sequence numbers occurring in the RUN, LIST, or CLEAR comman~.ls, . .

and others Shou161 be repurled to the w c r ao oloarly as gossihle and the G% . .

messa.e;e. should be suppressed.

E . Conclusion . .

In this chaptcr, a design for the amalgamation of some variant of a BASIC

system a s suggested by Kemeny and Kurtz, and the T A S language as described

in preceding chapters, has been described and given the name TAXL/BASIC. The -

implementation of BASIC systems has been documented elsewhere. A subsequent

chapter will describe a test implementation of TAXL/BASIC, with justenougll of

BASIC included to test the feasibility of such a system.

Page 74: TAXL-A simple Hierarchical Data Structure Manipulation ...

CHAPTER V

AN IMPLEMENTATION AND ITS ANALYSIS .

This chapter describes a data structure and some algorithms used to imple-

ment a partial TAxL/BASIC system. Since implementations of BASIC systems

have been described elsewhere (Braden [1968]), only the TAXL data structure

and algorithms will be discussed hefe. The implementation is written in LISP 1.5

and i s currently operating under the Stanford Campus Facility ~ R V Y L time-

sharing monitor.

Because of the nature of interpreted LISP 1.5, the fact that TAXL/BASIC

is written a s an interpreter itself, and the time,required to do the extensive page

swapping which time-shared LISP requires, the current TAXL/BASIC system i s

i too slow *and too expensive for large scale operation. In addition, the central

purpose of this work was to develop a user-system interface rather than a large

operating system. Thus, the internal data structure and subsequent algorithms

were not designed with speed and efficiency 'in mind. If a 'large scale implementa-

( tion of TAXL/BASIC is attempted, i t is suggested that the current implementation

be studied to see what is required, and that'at least the algorithms, if not the

data structure itself, should be. redesigned.' -A full implementation of the current

data structure and algorithms, even if written in machine language, would probably

fail to give adequate service in terms of response time and cost once the data

structure exceeds the size which can be contained in primary storage.

' : In order to follow the listing of the interpreter in ~ppend ix I, the reader must

. be familiar with LISP 1.5 (McCarthy [1962]), and with property list manipulation

and list-structure alteration operations in particular. For those readers not so

interested in the fine details, an outline flowchart of the interpreter i s given in

Appendix II. Initial entry to the interpreter is at A with the RUN FLAG reset.

Page 75: TAXL-A simple Hierarchical Data Structure Manipulation ...

p 1st label atom p 2nd label - atom r, last label - atom

; F86. %-Format. of a node in fie data base.

I

I

a3 3,

3 1st father node last father - node

e

1 T I a

V ' "7- , u -

1st son node 2rd son - node last son node

Page 76: TAXL-A simple Hierarchical Data Structure Manipulation ...

The atom USES'

A

Lisp system atom informatiansuchas type, print name, etc.

having this atom a s a label .

I

.3, 4.

2nd node having this atom

11 . as a label

last node having this atom

!&- as a label

1594811

FIG. ¶-Format' af an atam t m d as a hhl .m.&e.data b e .

Page 77: TAXL-A simple Hierarchical Data Structure Manipulation ...

The flowchart describes the logical flow of control and does not exactly parallel

the programmed interpreter given in Appendix I. Most of the semantic e r ro r

checking is absent from the flowchart, a s a r e some of the various forms of some

of the primitives.

A.. Node and Dictionary Formats

The format for a node in the data base is given in Fig. 3. Thus, what i s . .. ,

given at a node is a list of the labels that make up the data item at the node, a

List of pointers to all immediately hierarchically superior nodes, and a list of

pointers, to all immediately hierarchically inferior nodes.

The format for the property list of an atom which is w e d as a label in the

data base is given in Fig. 4. The atom USES indicates a following list of pointers

to all nodes within which the atom in question is used as a label. The essential

structure is that of a dictionary. For every label which occurs in the data base,

there i s an entry in the dictionary giving all uses of that label within the data

base.

Most of the computation time required for the execution of a primitive i s

consumed in the computation of ranges. Hence, refinements in this computation

o r modifications in the data structure allowing such refinements w i l l decrease

the execution time significantly. Since the object of this study i s not the design

of such refinements, the algorithm presented for the computation of ranges was

chosen for its programming simplicity. Once lists of the nodes in as many ranges

a s a r e required for the execution of a primitive a r e obtained, the execution of the

primitive is fairly straightforward, as shown in the flowcharts in Appendix 11.

More will be said about computation time later in this chapter.

Page 78: TAXL-A simple Hierarchical Data Structure Manipulation ...

B. The Computation of Ranges

The computation of a range by'Method II of the chapter discussing the evoca-

tion of ranges is essentially a se t intersection operation. Suppose the range

Secretary Carla West

'

is to be computed. The property l is t of the atom label lfSecretarylf contains a

list of pointers to a l l uses of this label, a s do the property l is ts of the atom labels

lfCarlavt and "West. l t The intersection of these l is ts i s , by definition, a list of.

nodes which incorporates the range. A straightforward intersection of unordered

se ts a s programmed in1 the current implementation given in Appendix I is the

easiest to program but has a computation time on the order of the product of the

number of elements in the sets. The computation time can be reduced to the

order of the sum of the number of elements in the se ts by ordering the se ts ac-

cording to any arbitrary but well defined ordering.

The computation of a range specified by hierarchical context is a more com-

plicated operation. Given two l is ts of pointers to a set of nodes X and a set of

nodes Y , it must be determined for which xeX,

X within Y

is true. Those x's for which the above is true a r e retained in the range; those

x's for which i t is not true a r e not retained in the range.

There a r e two principal ways of determining which nodes xeX are within some

node yeY. One method is to s tar t at each x, and by following the chain of father

pointers beginning at node x, check each node encountered on the path from node

x. to the roots of the tree. If one of the nodes encountered is a y node, then the

search can be terminated since it has been ascertained that x is within Y . If no

y node is encountered on any path, then x is not within Y. Since all nodes on all

paths must be checked, the case in which x is not within Y involves the maximum

number of checks.

Page 79: TAXL-A simple Hierarchical Data Structure Manipulation ...

: Another method for determining which x is within some se t of nodes Y is',to

s t a r t at each node yeY, in turn, and by following the chain of son pointers begin-

ning at node y; check each node encountered on the path from y to the leaves of

the tree. If one of the nodes encountered is an xcX, then this x is an x which is

within Y. However, the search cannot be terminated since there may be an x l c X

which is hierarchically inferior to y, and hierarchically inferior to all nodes in

Y only through the node x. 'l'hus, if the search were Ler~~l i~la led upoil ellcountering

x, i t would never be ascertained that, in tact, xi is within Y.

Thus, in the general case, it :is moTe advantageous to search from the x's

upwards along the father chains than from the y t s downward along the son chains.

In addition, there will usuaily be 'more sons thxi Zalhers il 111e entire data biac ia

considered, implying that to search downward would entail searching along many

more paths than searching upwards.

In order to analyze quantitatively the .implemenktion of the range finding

mechanism, the maximum number of nodes accessed in order to determine which

x's a r e within Y w i l l be used a s a measure of the conlpulation required. A3

mentioned previously, the case in which x is not within Y involves the maximum

number of node accesses since every node on every path from each x upward to

the roots of the data base must be accessed.

Assume firs1 that the data base has the form of a true t ree rather than a.n

acyclic directed graph. Effectively, this means that each node has, . at most, one

father. Thus, assigning level 0 to each root node and defining the level of a node

to be rlulnerically one greater than the level of i ts father, each node has precisely

one well defined level. With thie formulationj n node accesses are required to

t raverse the path from a node x at level n upward to a root.

Page 80: TAXL-A simple Hierarchical Data Structure Manipulation ...

The assumption that the data base has the form of a tree will now be removed.

Thus, there may exist a node z at level m, m< n which has two fathers, where z

, is the first encountered node ab0ve.x for which this is true.

Indeed, node z may be at level ml with respect to one path from a root and . . . .

at level m2 with respect to the other path. Thus, node x may be at two levels at

once, depending on which path through node z is being considered. . .

Let nl b e the level of node x with respect to the path which makes node z at

level ml, and let n2 be the level of node x with respect td the path which makes \

node z at level m2. ~ h u s ;

and nl - ml is the number of node accesses to travekse from node x upward to

node z. From node z, ml + m2 node accesses a r e required to traverse both paths

from node z upward to a root.

Total: (nl - ml) + ml + m = n + m = n + m 2 1 2 2 1 ' . . .

Now generalize the preceding casedand assume that node z has p fathers, . . . .

p 2 1. Thus, node z may be at a s many a s p levels ml, m2, . . . , m Therefore, P'

node x may be at as many as p levels n 1' "2, .:, . , $2 where node x is at level ni

, ,

with respect to the path which causes node z to be a level mi, 15 i i p . . .

Page 81: TAXL-A simple Hierarchical Data Structure Manipulation ...

A.s before,

and n. - m. is the number of node accesses to traverse from node x upward to 1 1

node z. From node z, ml + m + . . . + m node accesses a r e required to traverse 2 . . P

the p paths from node z upwards to the roots.

Total: /

(ni- m . ) + m l + m Z + ... + m = n . + m + m + ... + m , i - l + m i + l + ... + m 1 p 1. 2 P

w11el.e a. is the nunbcr of nodc aooooooa required to traverse from node x upward L

to node z and thence to a root by the ith father path from node z, and

is the number of node accesses required to traverse from node z upward l o lhe

roots.by the p-1 remaining father paths from node z.

The above total may be rewritten as

( n i - m . ) + m l + m + ... + m P

1 L i L p I 2

where ni - m. i s the number of node accesses-required to traverse from node x I.

upward to node z, and

. m l + m + ' . , + m 2 P

is the number of node accesses required to traverse from node z upward to the

roots along the p father paths from node z.

None, all, u r some of these p paths from node z might thcmselves split

further .at levels closer to t.he soots. Jf the j.th path, 15 j .< g , so splits, then m. J

is not the true number of node accesses from node.2 along this path to a root, but

must be c o d u t e d by the above treatment, recursively.

In the worst case, the superstructure 'from node x upward toward the data

base roots forms a tree. Assuming that the average upward branching factor is

- 72 -

Page 82: TAXL-A simple Hierarchical Data Structure Manipulation ...

b, b >l, and there a r e L levels from node x up to the roots (counting the roots

a s level zero), ,then the maximum number of nodes to traverse is the number of

nodes in this tree. Including node x, the number of nodes is given by

The specification of ranges by subtree context proceeds in much the same

manner, with the nodes specified by hierarchical context used where tne roots.

of the t ree were used in the previous discussion. In one variant, the number of

nodes obtained a r e counted and compared to the result of some numeric computa-

tion. In another variant, the labels in the nodes so obtained a r e individually

checked to see if they a r e numeric, and if so, their value is compared to the

result of some numeric computation. Nodes specified by hierarchical context

having subtrees obeying the required conditions a r e included in the range, a s

described in a preceding chapter.

C. Reducing Range Computation Time

The method which has been considered in analyzing the range finding mecha-

nism consists of a traverse upward to the roots of the data base. In this method,

the search is terminated when a root of the data base is encountered. In addition,

, a downward search along the son chain toward the leaves of the data base, a s

described previously, might be more efficient in certain particular cases. In

such situations, the user should be able to take advantage of his particular data

structuring to reduce the amount of computation required to determine a range.

The following mechanism allows the user to specify whether an upward o r downward

search is to be made, and a t the same time, to specify a terminating condition for an '

upward search other than the occurrence of a root o r a terminating condition for

Page 83: TAXL-A simple Hierarchical Data Structure Manipulation ...

a downward search other than a leaf. The mechanism can only be used in con-

junction with specifying a range by hierarchical context or subtree context re-

quiring that searching be done.

The first form allows the user to denote that the usual upward search is to

be performed and to specify a terminating condition other than the occurrence of

a root. The terminating search conditior, is. a set ~f nodes T specified .by Method

11. Thus, when searching for a range

the search upward is terminated successfully by an occurrence of a y node and /

terminated unsuccessfully by an occurrence of a root o r a member of the termina-

ting set T . To imply to the user that the search i s carried on only below (and

including) the nodes which a re in the set T , the delimiter l1below1' i s used to

separate the end of th'e range specification by Method IV and the specification of

the set T.

A portion of a data base shown in Fig. 5 demonstrates how this feature can

be used to advantage. The range evolred by

Professor within Reading Committee within Student Y

is identical to the range evoked by

professor within Reading ~ o m m i k e e within Student Y below Department.

In the former case, however, it is not determined that Professors W and X

a r e not included in the range until all the paths from Professors W and X upward

to the roots of the data base have been traversed. In the later case, the search

is terminated upon encountering the node Computer Science Department. This

early termination caa save quite a bit of computation, particularly if the portion

of the data base shown in Fig. 5 occurs many levels down from the roots.

Page 84: TAXL-A simple Hierarchical Data Structure Manipulation ...

Computer Science Department

student Y Student z I

~ r n f e s s n r A professor B Profes!

FIG. 5--A portion of a data base demonstrating the utility of below and above

Page 85: TAXL-A simple Hierarchical Data Structure Manipulation ...

The second form allows the user to denote that a downward search is to be

performed and to specify a terminating condition other than the occurrence of

a leaf. As suggested by the previous construction, a terminating set T of nodes,

specified by Method Il is separated from the end of the range specification by

Method IV by the delimiter "above, l1 or equivalently so a s not to introduce another

reserved word, the delimiter pair "not below. l1

Example (see Fig. 5)

Professor within Computer Science not below Student I

An analysis of the implementation will now be made. The amount of memory

rcquircd for a data basc implemented in this way will be considered, as well a s

the factors that affect the time required to access the data base.

D. Memory Usage

In order to gain some sort of perspective on the amount of memory required

to contain a complete data base, a formulation of data base requirements will be

made. A fairly representative d a p base configuration will then be described and

the amount of m-emory required to represent this hypothetical data base will be

computed. Throughout the formulation and computation, Figs. 3 and 4 should be

consulted.

Assume that throughout the data base there is an average branching factor

s(s > 1). That is, on an average, each node has s sons. Let L be the number of

levels of the tree, numbering the level of the root nodes as zero. Then the number

of nodes in the tree is given by

Page 86: TAXL-A simple Hierarchical Data Structure Manipulation ...

If we let

m. = the number of labels at node i 1

f . = ,the number of fathers at node i 1

s. = ,the number of sons of node i , 1

then the amount of storage required to represent node i in this implementation

(see Fig. 3) is given by

Labels: 8 + 8 mi

Fathers: 8 + 8 fi

Sons : 8 si .

TOTAL: 8(2 + mi + f i + si)

Note that 8 bytes a r e required to store a pair of pointers. Thus, for the nodal

structure of the data base, the total amount of storage is given by

Now consider the possible diictionary structures. Each label which occurs f

anywhere within the data base has a dictionary entry. As seen in Fig. 4, there.

is a list of pointers associated with this entry to every node in the data base .in

which that label occurs. Thus, there a re a s many pointers out of the dictionary

as there a r e (not necessarily distinct) labels at nodes in the data'base, given in

this formulation by ,

N

Since eight bytes a r e required to store a pair of pointers in the current imple-

mentation, the amount of storage requi'red for the pointers is given by \

Page 87: TAXL-A simple Hierarchical Data Structure Manipulation ...

The only other significant contribution to memory utilization .arises from the

storage of the labels themselves. since each label 06curs only once in the dic-

tionary, independentlyof its usage within the nodal structure, the amount of ,

storage required for these labels depends upon the number of distinct labels. At . .

a minimum, these can be only one distinct label which occurs as.the only label

at every node in the data base. Theoretically, there is no maximum number of

distinct labels since the number of labels occurring at any node is not limited.

However, since we have assumed that there a re mi labels at node i , then a maxi-

mum will be achieved by further assuming that all the labels across the data base

a r e different. Thus, the maximum totai number of distinct labels is given by

N C I l l i i= 1

Assuming an average of q characters per label, the amount of storage reqtiiked

for the labels themselves is given by

Thus, 'there are .three constitutents of memory usage:

' N Dictionary pointers : ' 8 mi '

i= 3,

N Label storage; qx mi

i= 1

. . ;. , , ' .: . . . ' N . N TOTAL: . . ' 8 x i=1 ( 2 + m . + f . 1 I , ! + ~ . ) + ( ~ + 8 ) z i.. 1 mi

Page 88: TAXL-A simple Hierarchical Data Structure Manipulation ...

A hypothetical data base will now be described. The parameters of this data

base a r e not completely random but are based on a small sample of data bases

built by students learning to use TAXL (see the conclusion of this chapter).

Assume that tfie data base has an average L depth of seven levels and that each

node has an average of four sons, i. e. ,

and, therefore, the number of nodes in the data base is

Now assume that each node has an average of three labels and two fathers,

m. = 3, f. = 2, and s. = 4 1 1 1

Thus, the storage requirements for an average node a re given by

Labels: 8 + 8(3) = 32 bytes

Fathers: 8 + 8(2) = 24 bytes

Sons : 8(4) = 32 bytes

TOTAL: 88 bytes/node.

Hence, to represent the nodal structure of the data base requires

88 bytes/node 5461 ~ l u d e ~ = 480, GG8 bytes

The amount of storage required for the dictionary pointers is

546 1 8 3 = 131,064 bytes

i i 1

As indicated in the formulation, the maximum total number of distinct labels

.could be calculated as

However, a more realistic estimate can be made by tho following assumptions.

Page 89: TAXL-A simple Hierarchical Data Structure Manipulation ...

It will be assumed that a t each level therc i s a common label which serves

a s an attribute, and that a t every node at that level, there a r e two other labels,

the s e t of which a re disjoint across the level and the entire data base.' ~ h e s e

two other labels at each node serve as a value for the cominon'at'tribute. Thus,

since there a re four sons for each node, at level i, there a r e

2 x q i + l

distinct labels, counting the root level a s level zero. Therefore, over seven

levels, there are

distinct labels and hence

6 x 10,926 = 65,556 bytes

required to store all the labels in the data base. It is assumed that these a r e

an average of six characters per label.

Table 4 summarizes the storage requirements of'this hypothetical data base

and gives the percentage of storage required for each data base component.

E. Access Time . .. d ..

In the discussion of the time required to compute the range x within y, the

particular configuration of the data base and the manner in which both the nodes,

named by x and the nodes named by y, a r e distributed throughout the configuration

a r e the most important factors to consider. Because the particular distribution

of x 's and yls a r e such an important consideration, to hypothesize a particular

data configuration and then analyze this particular configuration a s before would

not accurately enough characterize access time in general. However, there a re

several important observations which can be made.

Page 90: TAXL-A simple Hierarchical Data Structure Manipulation ...

TABLE 4

STORAGE REQUIREMENTS FOR A HYPOTHETICAL D ~ . T A BASE

Bytes Percentage

of Total

, Node Structure 480,568 7 1 . 0

, Dictionary Pointers 131,064 '19..4

Labels 65,556 9 . 6

TOTAL

3 labels per node /

2 fathers per node

4 sons per node

6 characters per label

7 levels

Page 91: TAXL-A simple Hierarchical Data Structure Manipulation ...

As described previously, in the computation: of the range

X within Y . .,

the maximum time required occurs when there a r e no nodes xcX within any nodes

ycY. . In this case, a search has to be performed beginning at each node x along

the chain of father pointers to the roots of the data base. At each.node z encountered'

along a path toward the roots, an identity test must be made .to see..if z is identical

with any of the nodes ycY. If we.take.the, total number of comparisons for identity

a s a measure of access time, then i t can be seen that the number of nodes yrY

times the total number of nodes along the path(s) from a articular x l rX to. the

data base roots characterizes the maximum access time required to determine

if x' belongs in the range. Since this computation must be performed for each

xeX, the maximum number of comparisons required to determine the range

is given by

where C is the cardinality operator and P(x) . . i sa the total number of nodes encountered

dong all paths from a node x along the chain of father pointers to the roots of the

data base (see Section B of this chapter).

There a re two other factors, mentioned briefly earlier in this chapter, which

contribute to access time. Both of these factors arise in the computation of the

sets X and Y

As described in Chapter 11, the sets X and Y a re SpecBied by 'Method 11. Thus,

in order to specify the set X, n labels xl, x2, . . . , xn are specified and the set X

is comprised of all those nodes in'the data base which have a t least the n labels

mentioned above. A parallel argument can be made for the set Y. The contribution

Page 92: TAXL-A simple Hierarchical Data Structure Manipulation ...

to access time thus arises from:

1) finding each of the n labels in the dictionary

2) forming the intersection of the n sets of pointers, the ith set being

associated with the label xi and pointing to all those nodes in the data base

which'contairi x. a s a label. -

1 .. .

In the current implementation, the operation of finding each of the n labels

xl, x2, . . . , xn is performed automatically by the LISP system. This should be

accomplished by a hash addressing scheme.

The USE-lists associated with each dictionary entry a re unordered in the . .

current implementation, and hence each of the n-1 intersections which must be

performed.requires a number of operations proportional to the product of the

number of .pointers which occur in the sets to be intersected.

If the hashing function used to find the appropriate entries in the dictionary . .

is a' good one, the time required to find the n labels which constitute the set X

is proportional to n. Assuming that m labels coLstitute the set Y, the time

required to look up the n + m labels i s given by k(n+m); where k i s some constant

dependent on the hashing function.

As explained previously the time required to perform the n-1 intersections

wlduh dyf11ie the set X.aaeI the m-1 iiiceri.sectionS which define the set Y is given by

2 (n- l )Kx + (m- l ) K

2 Y

where K is the average number of pointers associated with each of the n labels X

which constitute the set X, and K is the average number of pointers associated Y

with each of the m labels which coiistitufe the set Y .

Thus the total access time is given by

Page 93: TAXL-A simple Hierarchical Data Structure Manipulation ...

F . Operation Time . .

Once all the ranges required for a given command have been computed, the . ,

time required to complete the operation called for by the given command generally 1

depends only on the cardinality of the range(s) upon which the command will operate.

For all those commands which require only one range, the time required to com-

plete the operation is proportional to the num,ber of nodes in that range. For

those commands which require two ranges, the time required i s proportional to

the product of the number of nodes in each range. It should be noted that the . . . .

operation time for all those commands which require additional tree searching . , . ,

for their operation, i. e. , WRITE and DEL,ETE, a r e influenced by the subtree . . . . . - .

structure below the nodes in the computed range(s). Also, the operation of the , . ' . .

' , . .

SAVE and RESTORE commands depends on the structure and extent of the sec-

ondary storage dictionary . . . . , . . . . . .

G. System ,Measures .

In Table 5 measures of significant TAXL system functions in the current

implementation a r e summarized. The formulae given in the table,show the nature'

of the dependence of the system's functions .upon the parameters involved. Pro-

portionality factors a r e not given. Except for the memory utilization, all of the

systems functions give a measure of access time in terms of the cardinalities,

denoted by the operator C', of certain sets which a re involved in the particular

system function. Such sets include sets of nodes, sets of labels, sets of fathers

at a node, and sets of sons at a node. . .

The measures for memory utilization and the time to compute X within Y . .

have been derived previously. in this chapter. Since the USE-lists a r e un- . ..

ordered in the current implementation, the time required to perform the

intersection of two such lists. is proportional to the product of their cardinalities.

Page 94: TAXL-A simple Hierarchical Data Structure Manipulation ...

Memory Utilization

TABLE 5

SYSTEM MEASURES

Time to perform intersection of. USE-lists W and Z c(w) C(Z)

Time to compute X within Y (the sets X and Y a r e already defined) C(Y) P(x)

--

Time to add a label to a node in the. .

data base CONSTANT

Time to remove a label 1 from a node q in the data base m + lu

q Time to add a node q to the

data base C(new fathers (q))

Time to remove a node q from the data base C(sons (fathers (q))) + C(fathers (sons (q)))

N: number of nodes in the data base

m. : ' number of labels at node i 1

f.: number of fathers of node i 1

s.: number of sons of node i 1

q: average number of characters per label

C: cardinality operator .

P(x): total number of ancestors of node x '

Page 95: TAXL-A simple Hierarchical Data Structure Manipulation ...

In order to add a label to a node in the data base the following operations

must be performed:

1) Add a node pointer to the USE-list associated with the label.

2) Add a dictionary pointer to the label l ist a t the node.

Sincethe USE-list is unordered, the node pointer may be added to the front of the \

USE-list, an operation not depending on the cardinalities of any sets. Since the

usual option for adding a label to a node requires that the label be added at the

~ l l d @ Ule l a b 1 llsl, Ule lalxl llsl ill Ule rlude mus lbe searulleh iu Nild lls elrd. . . .

However, if the label List i s stored in reverse order, the new label can be added

to the front of the list, an operation not depend;ng on the cardinality of the label

list. Thus, the time required to add a label to a node i s a constant.

In order to remove a label 1 from a node q in the data base, the following

operations must be performed:

1) Remove the node pointer from tlle USE-list 'associated with the label. . . ' . .

' 2) ' ~ e m o v e the dictionary pointer from the. label list at the node.

Since the USE-list must be searched in order to remove the node pointer, time

proportional to 1 the number of uses of the label 1 in the data base (i. e . , the u '

cardinality,of the USE-list), is required. In addition, since the label list at the

node must be searched for the dictionary pointer, time proportional to m the Y'

number of labels at node q i s also required. Thus, in order to remove a label

from a node in the data base, time proportional to m + 1 i s required. u

In order to add a node q to the data base, the following operations a r e required:

1 ) Add the new father pojnters to the father l i s t of q.

2) Add n pointcr to q to thc Eon l i ~ t of each now fathor of rl.

Since the father and son lists at nodes a r e unordered, the new father pointers

may be added to the front of the father list of q, requiring time proportional to

Page 96: TAXL-A simple Hierarchical Data Structure Manipulation ...

the number of new fathers,of q. Thus, the total time required is proportional

to C(new fathers (q)).

In order to remove a node q from.the data base, the following operations ,

must be performed: . .

1). Remove the son pointers to q from each of the fathers, of q.

2) Remove the father pointers to q from each of the sons .of .q.' . .

,. .The father and son l ists must, therefore, be 'searched.for the pointers to be

removed, and. this operation must be performed for each father and.son of q.

Thus, the time required to remove the son pointers to q from the fathers of q . . .

is4proportional to, . . . . . . . . . -

. C(sons (fathers (q))) 7 ' . . . . . . . - .

i . : In a similar . . manner, the,time required to remove, the father pointers to q from

each of the sons of q is.proportipna1 to . . .

C(fathers (sons (q))) * . ,

Thus, the total time required to remove a node q from the data base i s proportional

to the sum of the two cardinalities given above.

A useful refinement to make in.the implementation is to keep the U S E - ~ ~ S ~

order&!. The system f i c t i o n measurement which would be improved by' this

.refinement would be the 'time req&red to. perform the intersection of two USE-lists.

Since the lists would'be ordered, 'the time' required' would be proportional to the

. ^ - sum of the cardinalities of the l ists rather than the product. However, the time

' 'required1 to add a label to the .data base would increase since the node pointer

. . 'could no longer be added to the front of the USE-list but would have to be added

at its appropriate place in the .ordered list. Thus, the time required to add a

label 1 to the data base would depend on lU, t he cardinality of the USE-list of 1.

It i s felt that this refinemelit would .be a useful 'addition tb the implementation,'. ,

Page 97: TAXL-A simple Hierarchical Data Structure Manipulation ...

since USE-lists a r e intersected for almost every range definition. The operation

occurs much more frequently than the addition of a label to the data base.

A better refinement would be to keep the USE-lists not only ordered, but

ordered in the form of a balanced tree (Knuth [1970]). The advantages of

storing a USE-list of cardinality n in this fashion arise from the fact that the

time required to insert a new element, to delete an old element, and to find the

smallest element in such a tree, each requires time proportional to log n. (The 2

algorithms for performing these furictions will appear in The. Art of Computer

Programming, 'Volume 3, 'by D. E.. Knuth).

Thus, labels may be addehand deleted from the data basc+ with a logarithmic

dependence on leu rather than a linear dependence. The additional storage required

for structuring the USE-lists in this fashion affects only the multiplicative constant

in the formula for the dictionary pointer storage, the formula for whibh would

now be

since one father and two sons pointers would be required for each entry.

Additional rcfincmcnto, and possibly the best rtffi.lcinel3s i lr Llle represellla-

tion and algorithms for addressing and manipulating the nodal structure,,. might

wcll bc in thc direction of hash, o,r scatter storage techniques (Morris 11968)).

In the LEAP system (Feldman [1969]), a hash addressing scheme based on a hash

of two elements of an object-attribute-value triple provides a convenient and usefill

method for the retrieval of information concerning the uscr-defined relationships '

among a universe of items. . . . .

Hash coding is the simulation'of an associathe memory, and since TAXL . .

is an assqciative semantic processor, it is, felt that research into new methods &

Page 98: TAXL-A simple Hierarchical Data Structure Manipulation ...

of using hash coding techniques might well uncover more efficient ways of imple-

menting a system such a s TAXL.

H. Conclusion

A test implementation and analysis of a limited TAXL/BASIC system has

been described. Several comments can be made concerning the analysis. '

The factor of eight which appears in the form-& for t o b l memory usage ar ises

from the fact that in the version of LISP 1.5, in which the TAXL interpreter i s

written, eight bytes a r e requiredto store one LISP element (a pair bf pointers).

This factor can be reduced by writing TAXL in some other list processing language

system (Hansen [1969]) or by using special data structures designed for TAXL in

particular, and embedded in some assembly language system.

Otherwise, it can be seen that the total memory usage depends linearly on

the number of nodes in the data base, a s well as on the kurnber of labels a t those

nodes and on the interconnections between those nodes. Upon considering the

formula for access time, it can be seen that the access time depends linearly on

each of the cardinalities of the sets X and Y and on thi depth and number of paths

to the roots of each xeX.

Operation time for various of the primitives could be decreased by imposing

an order on the lists of fathers and sons a t the nodes in the data base. The

ordering of the labels i s defined by the user, and hence an iaternal ordering could

not be imposed on them without complicating the algorithms which manipulate the ,

labels. An ordering imposed on the fathers and sons would allow a faster retrieval

of specific fathers or sons. However, the time required to insert new fathers

and sons into an ordered list would consume more time than if the list were not

ordered.

Page 99: TAXL-A simple Hierarchical Data Structure Manipulation ...

On the basis of classroom utilization, the feasibility of such a system, as

described in this work, from the user's point of view with respect to the goals

discussed in the introduction has been ascertained as affirmative. On two sepa- , .

rate occasions, lectures were given to the type of potential user of TAXL/BASIC

a s described in the introduction to this work. One such group was composed of . .

students enrolled in a graduate course in communications. Their only previous

computer . . . experience was a limited introduction to terminal processing via a

BASIC system, The other group was composed of summer school students and

teachers enrolled in an introductory course for computing in the humanities and

social sciences. Their only previous computer experience was a four-week ex- . . . .

posure to Algol W with no terminal processing. Even though the two groups were

a t different levels in their educational experiences and their limited computer

experiences w i r e of a different nature, their ability to grasp and learn how to use

the TAXL/BASIC system was fairly uniform. After only two hours of classroom

lecture and ten minutes of terminal usage instruction (which included log-on, log-

off, and other ~o~-TAXL/BASIC procedures), almost a l l the students, working

in groups of two o r three, were able to use the system with a fairly high degree

of assurance in a t least an experimental mode to answer most of their remaining

The students were asked to build and manipulate data bases which would be

of interest to them in their work. Political cross affiliations between members

of the United States Senate and House of ~ e ~ r e s e h t a t i v e s , a bartender's guide of . .

ingredients for different drinks, and an inventory of an army supply depot were

some of the examples for which the students found TAXL/BASIC useful and

interesting.

Page 100: TAXL-A simple Hierarchical Data Structure Manipulation ...

From this preliminary survey of the utility of TAxL/BASIC with respect to

i ts intended goals, i t appears that the system meets, i ts intended requirements.

Experimentation with more'economical, more complete systems able to handle

larger data bases i s required before more bomplete results can be obtained. . . . . a

. . ... . . . \ . .

Page 101: TAXL-A simple Hierarchical Data Structure Manipulation ...

CHAPTER VI

FUTURE WORK AND SUMMAFtY

Throughout the course of this work, several ,topics have arisen which tend to

complement the present state of the work as described in this paper.

In order to better test how easily the system can be learned and used by com-

puter novices, a well written userf s manual could be compiled with its prospective

audience well in mind. Graduated exercises on which the student could work while

using TAXL/BASIC a t a terminal could be provided.

The interface between TAXL and BASIC could be made more complete. By

defining a good string manipulation facility for BASIC, this string manipulation

facility could be interfaced with TAXLfs label structure. As mentioned previously

entire 1-dimensional arrays of numeric values could be retrieved from a range,

each of whose nodes contain numeric labels. In addition, the LABEL and UNLABEL

commands could be extended so that with one command evocation, the set of numeric

labels, whose values reside in a 1-dimensional BASIC array, could be added to or

removed from a range of nodes in the TAXL data base. Finally, a good external

encoding for the data basc could be designed and the READ and DATA statements

of BASIC could be extended to allow the reading of portions of the TAXL data base.

Currently, the TAXL addressing structure i s semantic and associative. The

range specification mechanism could be expanded by allowing syntactic addressing.

Thus, constructs such a s SON OF . . . and FATHER OF . . . and compounds of

these would be allowed.

A facility for labcling arcs , which might stand for attributes whose values

could be found as the labels at the nodes which terminate the arcs, could be intro-

duced. This might allow a more concise and more easily manipulable data

Page 102: TAXL-A simple Hierarchical Data Structure Manipulation ...

representation in those cases in which there a re many attribute-value pairs

describing a hierarchically superior node. Multiple a rcs ,between two nodes

could also be introduced. '

Currently, intersections and unions of ranges may be specified by the suc- , .

cessive application of several of the primitives operating on the ranges, the

intersections o r unions of which a re being sought. An explicit facility for speci-

fying intersections and unions of ranges would .be useful in those contexts where

they a re required frequently.

By allowing a dynamic macro facility, the user could define his own primitives

a s successive applications of the TAXL primitives o r other user defined primitives.

Themacro could have the form of a tree which the user can create in the data

base. The root' node of this tree could contain the keyword which would cause

the tree to be scanned and evaluated when a command beginning with the same

keyword is'evoked. The macro tree would be required to have a certain form so

that in scanning the tree in some predetermined order, the system could fill in

the templates occuring in the macro tree with the range specifications occurring

in the calling command and initiate execution of the commands found in the tree

in a proper order.

The suggestionsmade in the concluding sections of the previous chapter con-

cerning memory utilization, access time, and operation time could be carefully

worked out to improve the speed and efficiency of the TAXL system.

In summary, this paper has presente.d an easy to learn and use data manage- . .

ment and manipulation system for computer novices. . .

Chapter I outlined the need for such systems and suggested the uses to which

they could be put.

Page 103: TAXL-A simple Hierarchical Data Structure Manipulation ...

Chapter I1 discussed the format of the data base and the mechanism for

addressing such a data base in semantic and associative terms.

Chapter ITI introduced eleven primitives for constructing, destroying, and

otherwise manipulating and querying the data base. The primitives a re designed

to operate on portions of the data base addressed by the range mechanism dis-

cussed in the second chapter. Ln this way, the addressing mechanism and the

operational primitives a r e clearly separated.

In Chapter 1V, the design oi a system in which 'I'AXL and a numeric processing

system possessing logical programming capabilities was introduced. Additional

primitives for managing the programming structure were introduced.

Chapter V discussed a current implementation of TAXL and gave measures

of memory utilization and access time in terms of natural parameters of the

system.

The current chapter outlined possible future work and summarized this paper.

Page 104: TAXL-A simple Hierarchical Data Structure Manipulation ...

REFERENCES

Bauer, H., Becker, S., Graham, S. , Satterthwaite, E . , ALGOL W Language . . . .. .

~ e s b r i ~ t i o n , Computer science department Report CS110, stanford University,

September 1969.

' 11 Braden, H., ~ u l f , W. , The Implementation of a BASIC System in a ~ u l t i ~ r o -

gramming Environment: CACM, Voi. II. No. 10, October '1968; p. 688.

Falkoff, A. , Iverson, K.'E. , The A P L / ~ ~ O Terminal System, ACM Symposium

on Interactive Systems for Experimental Applied Mathematics, ( ~ c a d e m i c

Press , New York, 1968); p. 22.

11 Feldman, J., Rovner, Po, An Algol-Based Associative Language: CACM, Vol. 12,

No. 8, August 1969; p. 439.

Griswold, R. et a1 The SNOBOL 4 Programming Languag 4 - -' 3

e, (Prentice Hall,

Inc. , ~nglewood, New Jersey, 1968). D

Hansen, W. J . , The Impact of Storage Maliagement on Plex Processing Language

Implementation, Computer Science Department Report CS113, Stanford

I University, July 1969.

Information Processing Language - V. Manual, ed. by Allen Newell, Rand

Corporation. (Prentice Hall, Inc., Englewood Cliffs, New Jersey, 1961).

Kemeny, J . , Kurtz, T . , BASIC Programming, (John Wiley and Sons, New

York, 1967). .. .

11 6 11 Knowlton, K. , A Programmers Description of L , CACM, Vol. 4, No. 6,

J1.1.m 1 9 6 3. ; p. 6 1.6.

Knuth, n. E. , The Art of Computer Programming, Vol. 3, (Addison-Wesley

publishing Company).

Knuth, D. E. , Optimum Binary Search Trees, Computer science Department

Report CS149, s t h f o r d University, January 1970.

Page 105: TAXL-A simple Hierarchical Data Structure Manipulation ...

It Lang, C. , Gray, J. , A Ring Implemented Associative Structure Package:/ CACM,

Vol. 11, No. 8, August 1968; p. 550. .

McCarthy, J. -- et al. , LISP 1 . 5 Programmers Manual , (The MIT Pre s s , Cambridge,

Massachusetts, 1962).

Morr is , R. , "Scatter Storage Techniques," CACM, Vol. 11, No. 1, January 1968;

p. 38.

Ross, D. T. , "A Generalized Technique for Symbol Manipulation and Numerical

Calculation," CACM, Vol. 4, No. 3, March 1961; p. 147.

S tanford /~as ic User 's Manual, Stanford Computation Center Campus Facility, - .

stanford University, Stanford, California, December 1968.

Webster's Third New International ~ ic t?onary , (G.and C Merriam Company,

Springfield, Massachusetts, 1964). . .

Wirth, N. , Hoare, C . A. R. , "A Contribution to the Development of ALGOL,"

CA.CM, Vol. 9, No. 6, June 1966; p. 413-431. . . . -

Page 106: TAXL-A simple Hierarchical Data Structure Manipulation ...

APPENDIX I . .

L I ( I T ~ G o F THE INTERPRETER

V E R B O S ( N 1 L ) C S E T ( O P S P ( ( + . 3 ) ( - . ' 3 ) ( k ' . 4 ) ( / . 4 ) ( N E G 41, (*! 5 J

( S U B 6 ) 1 ) C S E T ( S T A K N I L ) . C S E T ( O U T P N I L ) C S E T ( P X P N I L ) C S E T ( C H K N I L ) C S t T ( K E L S ( E U N i O GR GE L S L E I ) C S E T ( R U N N I L ) C S E T ( S Y N T A X h I L I C S E T ( S B S T C S E T ( S L B S U B ) B

C S E T ( L I N E N I L ) C S E T ( L I N E S N I L ) C j E T ( T k I S L I h E k I L ) C S E T ( U N I Q N I L ) C S E T ( I S N F h I L C S E T ( N L R G $ $ % N U L L R A N G E S C S E T cauor s a o 4 * $ ) . . C S E T ( L L I M ( B B S C A R R I A G c K E T U X N S N O T , I N WHEREVER I S I N T O ' w I T H ' I N

U h L E H T t i FROM AS 13Y PNC B E F O i i E EQ l u E Q GR Gf L S L E ) ) C S E T ( O N L F N I L J C S E T ( C E L T . h 1 i ) C S E T ( I K P K C L 114 S O $ I K P & U P E i l U t L I M I T E R o . . 9 ) C S E T ( I A E S B S I L L k G A L A 1 I I . T H M E T I C E X P H E S S I C h B ) C S E T ( P V C S $ $ $ A H I T H i Y l E T I C V A K I k d L E C A N N O T H A V E A S U U S C R I P T . 0 . $ ) C S E T ( A I M S $ S $ A R R P Y I O t i X T I F I t H P U S 1 H A V E , 4 S U B S C R I P T . 0 . 9 ) C j E T ( L h M I $ $ $ L I N E NUMHEK MUST i3E I N T E G E K S I C S E T L h C T h (NOT I h ) ) C S E T ( P L T F N I L ) C S E T ( E L S L N I L J C S E T (OK O K ) C b E T ( h X T d N I L ) C j E T ( I h T C I ( I N T O l n I T H I N U N D E h T C ) I C S L T ( C F L G N I L ) C S t T ( K F L G N I L ) C S E T ( w l i c R E V t t l h H E H E V E K ) CS,ET ( P P V P L A P V A L C S E T ( P V A L P V A L ) C S k T ( L S E S L b t S ) C S E T ( X T U P N I L ) '

C S E T ( : ' JWS h l l ) C S E T ( L C K K S B S C A R R I A G E R E T U R N $ ) C S E T ( B Y A S . ( b Y A S ) ) D E t ; I h E ( (

( M A I h ( L A M B D A h I L ( P H C G ( X ) . M l (CUNL) (CHI( ( P K U G Z ( P R i J G 2 ( P K I N l S B S ) ( P R I ~ ~ SY.NTAX) ) ( P R l F i T K U N ) ) )

( C C N O ( R U N ( C i N D ( ( C G K I ' k I S L I N E ) ( P K O C Z - ( C S E T i T h I S L I N k ( C C R T H I S L I N E ) ) '

I ( C S E T Q L I k E ( C i J A K T H I S L I h c ) 1 ) )

, -. ( T ( S T P P t u I i J ) ) ) ( 1 ( T R E P U 0 ) ) )

M 2 ( C O L h l T YCOOC. ) - ' ( C S E l d IUXTk ( ~ f i ~ t ~ ) ) ( C S E s . 4 KFLG N I L ) ' ( S E T C X ( F T C H )

( C C A D ( ( h d P i 3 t H P X j ( P K O G h I L (COND ( ( i q L T ( F I X P X ) ) ( M E S S ( Q L U T E S S B L I N E h U M a E R MUST B t I N T E G E R S )

b L A r J K N I L ) ) ) (CCND ( ( E C h X T k t M K K ) ( P R G G Z ( L I N E S R C h X N I L )

- ( b E G I N ( U U O T t M A I N ) N I L ) ) ) ) ( C S E T C S Y h T P X T ) ( C S E T Q S t i S N I L )

Page 107: TAXL-A simple Hierarchical Data Structure Manipulation ...

( C S E T O L I k E ( C O N S A N I L ) ) ( i E T 4 X L F T C H ) ) J J ) ( C C N D

( ( k i ; X ( Q U O T E i ) k L k l ' t J J ( U E L E T J J ( ( t Q X X(r;lliilTE ' S E V E R ) ) ( D E L E N , I L J J ( ( t Q X ( Q L U T E ' C U P Y ) ) ( 'PULP ~ I ' L J ) ( ( E i i X ( Q U O T E P U T ) ) ( P U C P 1)) ( ( E d x ( G L O T ~ 6 k I T t J ) ( d R I T ) . ? ( ( Ebi X ( O U U T E L A b E L , ( M A K E T J ! ( ( E O X ( 4 U d T E U N L A B t L ) ) ( M A F E N I L J J ( ( E L X ( b i U 3 T E C C U r \ i T J ) ( C O l r T J J ((EU x ( Q U O T E CHEAT^) J ( c R E T . ~ ' ) ( ( E d X ( C U O T E L E T ) ) ( L E 7 T ) J ( ( A W ( N O T S ~ S J ( ~ a x ( U L G T ~ G C J ) J (PAOGZ (GUT 'OJ

(Cl,lN(J (RLJl\r 120 M 2 1 ) ( T N I L J ) ) ) ( ( A I u U ses ( ~ h j x ( Q L C ~ T E L I S T ) ) ) (L ISJ) ( AN^, stjs ( EG x ( U U O T ~ C L E A A J J 1 ( C S E T Q KFLG ( C S E T P ' L I ~ E S NIL)) J ( ( A N D s t s ( i O x ( Q U C T E R U N J J I ( P K G G Z (RNNJ ( G O M Z J J ) ( ( E U X ( O L U T E S T U P ) ) ( C C h D ( R U N ( S T P P T J ~ ) ) ( ( E 4 X ( Q U U T E S H 3 W b J ( SHCJnU ( T R E A D N I L ) J J ( ( t Q X ( Q U U T t T R A C E I J ( T R A C E ( T R E P D N I L I A J ( ( E Q X ( G L U T E U N T R A C E J I ( U N T R A C E ( T R E A D N I L ) I ) ( ( E U X ( d U U T E P R I N T ) ) ( P K Y N I J ( ( E d X ( G U O T C X T U P J J , ( P R l h T ( C C H ( Q U O T E X T O P ) J ) ) I T ( M E S S ( Q U O T E $ % a l L L L C A L COMMAND... 6) X k i L J J 1

( C C N D ( S Y N T A X (PtiUG2 ( P R O G Z ( C S k T G S Y N T A X N I L ) ( C S E T d S B S T J J ( L I h E S R C H ( C A R , L I N E ) T )

( C G h O ( ( A N D K F L G S d S ) ( P R I N T C K J J J ( G C 1'41)

U E F I h E ( ( . .

( I T P ! ( L A H B O A N I L ( P R i l G , ( Y L LT N t k f j ( C S E T Q U N I G h I L J ( C C N D ( ( M C M B N X T W O L I M J ( M E S S C P J )

( ( E Q N X T k ( U G O T E L ~ I Q U E L Y J I ( C S E T Q U N I Q ( F T C H J ) J J 11 ( S t T O L ( C G N C ( ( A T O H ( S E T b i L T ( F T C H J ) J ( A P P E N D L ( C O N S LT h l 1 L J ) )

( T ( A P P E N D L L T J I i ) (CUNiJ ( ( M E M B N X T v l D L I H J ( S E T Q L T L J ) ( T ( G O 11) J J ( C C N O ( S Y k T A X ( R E T U X h h l L ) ) J

I ( S E T Q N E w F ( O R NEdF Y J 1 ( S E T 4 Y ( N I N U S ( C A h L T J j J

(CCku 1 i r i E M d ( C A K L T ) ( C C K L T ) ) ( S E T U L ( t k k A L t ( L A N L I J L J l l ( ( S E T 6 L T ( C D K L l ) ) ( G O 1 ) ) )

( S E T C L ( C C N S L N I L ) J ( C L N U ( ( A I L U P u l l - ( i JK h t d k Y J (FiiJI L k L b I I l i ~ t ~ l t L I V i ~ l i

( 7 (RETURII) L ) ) ) . ( C S E T Q X T D P ( C O N S L X T O P J J

(CGND ( & L i d ( R E T L N N L 1 ) )

( M E S S N L N I L J ( P H l i J T ( G U O T E BbB C R E A T t D O J J ( i i E T C R k L>

D E F I N E ( (

( N I k U S ( L A M ~ D A ( X I , ,:::.

( C L A D ( ( C K C F L G ( G E T X U S E S ) ) r \ ( . ILJ . . . . . . ' .

. . ( ( A N D P L T F (NOT ( G E T X L S E S ) J I T J : : ( T ( M E S S ( d U O T E %$$NOT I N G S E . . . $ 1 'X T>

D E F I h t E i t ( I T M S ( L 4 M t 3 D A N I L ( P R C G ( R E S ) I SET^ HES ( ~ ~ h . 5 i I T M I R E S ) ~

( C C K D ( ( t C N h T ' d ( Q U O T E A h U J J ( P H O G 2 ( F T C h J ( G O I ) ) ) ) ( P E T U k N R t S >

U€I;I~E ( ( ( F T C H t L A M d 3 A N I L ( P R G G ( T c M P J

( S E T O TEMP N X T h J

Page 108: TAXL-A simple Hierarchical Data Structure Manipulation ...

. ( C S E T 4 N X T d ( C C ~ L ) ( ( C C ; h D ( R U N ( N U L L LINE) J ( T ( E O L J ) ) E M K K ) ( T ( P K O G ( A a D J

( CUIdD ( ( N O T ( A T O M ( SE T C A T A E E D ) ) ) J ( C C h D ( A X P ( K E T U R N A ) ) ( T

( M E S S ( Q L O T E $ $ $ L I S T S h O T A L L O W E D S J B L A N K h i L J J J ) ( ( A N D ( N U M B E H P A ) ( N O T ( F I X P A ) ) )

( C G N C ( ( S E T Q C ( M E M B E R A N U M S l l ( R E T U R N D 1 1 ( T t P K O G 2 ( C S E TQ NUMS ( CONS A NuMS ) )

('KE T U R N A ) ) ' J ) ) . ( ( N I T ( E Q ( C A R ( S E T Q 8 ( E X P L 0 D . E A ) ) ) P U O T . ) )

'. ( A L T U H N A) J ( ' ~ S E T U B (CCR 9 1 ! !GO L 5 ) ! J

L 2 ( C C N D ( ( C C N D ( H U N ( N U L L L I N E ) ) ( T ( E O L ) ) ) ' ( M E S S ( Q U C T E $ % $ M I S S I N G Q U O T E S ) t3LANK h I L ) J

( ( A N D (NU'NBERY ( S E T Q 'A ( T R E E D ) ) ) ( N O T ( F I X P A ) ) ) ( P K O G Z ( C d N D ( ( S E T ' O e ( M E M B E R A NclPl5J.J

( S E T Q 0 ( C O N S 8 0 ) ) ) ( T ( P R O G 2 ( C S E T C i N U M S i C U N S A N U M S J )

( S E T Q U ( C O N S A i l 1 4 J ) J ( G O L 2 J ) J

t ( A T C M A ) ( S E T G E ~ E X P L O G E A ) ) J ( A X Y ( R E T U P N A ) J ( T . (MESS ( P u O ' T ~ JSSLI 'STS N O T A L L O W E D Z ) a L A h j K h I L J ) J

( C O N D ( ( E U ( C A R 0 ) B U O T ) ( K E T U R N 3 ) 1 ) 1 4 (COND ( ( E Q ( C A R a ) U ~ G T I ( K E T U R N ( A P P E N D ~ LJ ( M K A T G M ) J J ) )

' ( R L I T ' (CAR 8 ) ) ( C G h D ( ( S E T Q i3 ( C C R l 3 ) ) (GU L 4 ) ) ) ( S E T 4 C ( A P P E N D 1 U ( M K A T O M ) ) J (GC L 2 J

L 5 ( R L I T ( C A R 8 ) ) ( C O N D ( ( N U L L ( S E T b 8 ( C D R B J ) ) ( S E T Q D ( A P P c N O 1 D ( M K A T E M J ) ) )

( . (E6 i ( C A R 8 ) QUOT ) ( R E T U R N ( A P P f N O l 0 ( M K A T U M J J ) I ( T (G tJ L 5 J J J

( G O L Z I 1 ) ) ) ( C C N D ( S Y N T A X (CCND ( ( O R A X P ( P T C P l T E M P ) J ( A P P E N D 1 L I N E T E n P )

. . ( T ( C S E T U L I N t ( A P P E N D L I h C ( A P P E N D 1 ( C L N S 4 U U T T E M P ) P U G T ) ) 1 ) ) 1 )

( F E T U H h TEWP> D k F I N E L (

( T R E E C ( L A H O O A N I L ( P K O G ( X J ( H E T U R h ( C u h C (RUN ( P K G t i 2 ( P H C G Z ( S E T Q X ( C A R L I N E J J

' ( C S t T C L I N E ( C D H L INE) ) ) X J J 4 1 ( T R E A D N I L >

D t F I h t ( (

( K A h G E ( L A M B u A I F L G J ( P K O G ( R h G E J ( C Q N C ( ( N U L L F L G J

( L U h i ( ( Eid h X 1 W ~ ~ ' F R E V ~ R ) ( S E T Q H N G E I k i H t K E P K T X T O P ) J ) ( T ( P K U G Z C S E T G , R N & E ( I N F T J J . .

(CCrmU ' ( ( t u N X T N w H E H t V E A I ( S E T P K N G E ( d h E K E P K T K N G E J J )

( T N I L ) ) J I J J . . ( ( N U M B E H P F L G ) ( S f T u R N G E ( I N P T I I ) )

( S E T U P N HNGE> .... . . I " .

D E F I N E ( ( . . ( W R I T ( L A M 8 3 A N I L (P.KclC; ( X . 1 . . ' .

( C S E T C C h L F N I L ) . . . ( C C I J U ( ( E u N X T k ( b i b i 3 T E . C h L Y J J ( , P ~ o ~ z ( C S E T i l CNLF T 1 ( F T C H ) J J ) ( C C h L ( E Q N X T w E M R K ) ( S t T Q X XTOP I )

( ( N b L L ( S E T Q X ( H A N G E h l L J ) ) (MES.5 I r iLRG 8 L A N K T I ) ) (CCNL) ( ( N O T ( E i : ' ~ x T w E M R K J ) ( # , L S S I M P K ' U i i M NXTW N I L ) I J ( C C h D ( S Y h T A X ( & E T U R Y N I L J ) )

Page 109: TAXL-A simple Hierarchical Data Structure Manipulation ...

( Z S E T l b l E L ' S L N I L ) ( C C l u D , ( ( N U L L X ) ( R E T U R N ( P K I l u T ( d U O T E d B J F l O T H I N G T U W H I T . E $ ) ) J ) )

h ( C C k U ( X ( L E V k L ( C C h S ( C A P X ) h 1 L J 2 ) J ( T ( K t ' J U K N N I L ) ) )

( S E T , . X ( C U R X ) ) ( G O W > ,

l j E F I h E ( (

( L E L E L ( L A M ~ D A ( a s p r ( PRUG ('XI A ( C O N D ( ( N U L L .P J ( H.E. TUKN. bi I L J ! )

( T T A B S P J ( S . E T C X , ( C P A R LJ ) B ( P K I N L ( C A R X ) J.,

( C C F ~ D ( ( S E T Q x ( C O K 'XI I ( P K O G i ( P H IN^ BLANK) ( G O a,,) j

( C i i h D ( ( M E M B ( C A R !JJ E L S L ( P K O G ~ ( P R I N T ( Q U O T E $ 8 8 < O C C U R S A B O V E > B ) ) , '

, ( P R U G 2 ! S . t T d Q ( C D K 6 1 ) ) ( G O A ) ) J J ) ~ T E R P R I ) ( C S E T G E L S L ( C C ~ S ' ( C A R C ) fl.sL.rr (CON,O (UNLF' (RETURN NIL) J )

( L E V E L ( C i I L i R ( C A i l Q J ) , ( P L U S SP 3)) ( Sf 19 U (.CGR Q)) (GU, A>

U E F I h E ( ( ' ' . .

( C R E A T E ( L A M B G A ( A F A T ) ( P R U G ( Y . L J ( S E T U Z ( G E N S Y M 1 ( Q U O T E F A T H I ) ) ( C S E T Z ( C c i N D ( F A T ( C J N S F A T N I L ) ) ( T N I L J ) )

' ( H P L A C D X ( G U N S 2 N I L ) J ' . ( S k T h Y (LA11 X I )

CL ( C E F L L S T ( L I S T ( L I S T ( C h R Y ) (CCNS X ( G E T ( C A R ' Y ) U S E S ) ) ) ) L S E S ) (CUND ( ( S E T U Y ( C D K Y ) ) ( G O C l J J ) . .. (RETUHN X> I

O E F I h t ( (

( N C M N ( L A M B D A ( X ) ( P K O G ( Y R E S L S E l d S E 2 ) ( S t T G Y ( S E T C X ( C A R X j J J ( S E T 8 R E S ( G E T ( C A R X ) U S E S ) )

F i l ( C O N D ( ( S E T Q X ( C U R X ) ) ( S E T d U S E 2 N I L J I ( U P d l C (GU N 3 ) b ( T ( R E T U R N R E S ) ) )

( S E T Q U S E 1 ( G E T ( C A R X J L S E S ) 1 h2 ( G C E ~ C ( ( n E n e (CAI ( U S C ~ ) I : L S J L S C T Q U S E Z ( C O N S ( C A R u s e 4 1 U S E L I ) ) )

( C C F l D I ( i t T U L S t 1 ( C d c i U S E 1 ) l ( v . G N Z J J l ( S E T U k E S U S E 2 J ( G O h i )

h 3 ( C C N U ( R E S ( S t T O U S E 2 ( C A A R R t S ) J J ( ' I ( R E T U R N L J S E I ) ) ,

N 4 l C O N U ( L M E M t 3 ( C A R U 5 E Z J Y J I L I L J ( T ( G C h5)))

( C C N D ( ( S E T U U S t 2 ( C C K i J S E 2 J 1 ( t i c N 4 ) J ) ( S E T G g j E l ( C G h S ( C A R K E S J U S E 1 J )

h 5 ( 5 E T u R E S ( C Z R R E S ) J ( G C h3> O E F I N E ( (

( P U C P I L A M ~ U A ( F L G ) ' ( P R O G ( K N G L RP~~;ZI . . ( C C k D ( ( t U N X T h E M R K ) ( M E S S C P ) ) ) ( C S E . T b j P U T F k L b ) ( C S t T U C ~ L F N I L ) ( C C R L I ( ( E d h X T d ( W U U T E O h L Y 1 ) ' .

( C C h O ( P U T I - ( M E S S I F P R O L I M hX,TLi N I L ) ( T ( P H O G Z (FTCHI (CSETI;; C~ULF T ) J ) ) ~ J

( S E T U R N G l ( R A N G E S N I L ) J ( C C h G ( ( C t M U h X T k I N T O ) ( F T C H I J 4

( ( A l i G ( I \ rCT P U T F J ' ( t O h X T k E M R K I ) ( P H O G Z ' (5EF6 uiqti.2 (CUIJS X T b P N I L ) ) ( G U P I ) ) )

( T ( P h O C L ( M E S S O i 2 J ( H E T U G & h l L 1 J 1 ) '

( S E T 4 i i N G Z ( R A N G E S N I L ) ) P 1 (Cl;hD ( ( I L o T ' ( ' E Q N X T N t M R K ) ) , ( M k S S I M P K O L I M NXTW N I L J J J

(coIuD' ( S Y N T A X ( P A i 3 G 2 ( C S E l u P b T f k 1 L ) ( H t T U R N N I L ) ) l )

Page 110: TAXL-A simple Hierarchical Data Structure Manipulation ...

( M E M ~ , ( L A M U O ~ ( X LJ ( P R O G N I L V ( C C N D ( ( & U L L L J ( R E T U R N N I L ) J

( ( E U X ( C A R L J J ( K E T U P N X J ) J ( S E T Q L ( C D R L J J (GO M >

. .

i i E F I h E ( ( ( M E C B E R ( L A M B D A ( X L J ( P R O G N I L M ( C G N D ( ( N U L L L J ( R E T U R N N I L J J

( ( E Q U A L X ( C A R L J J ( k E T U R N ( C A R L J J J J L S E T Q L L C D H L I J ( G O M>

U E F I N E ( (

( P U T 1 ( L A M B L A ( 'TBPL W H R E J ( P H C G ( T B C M O C A R O J . ( S E T U T B L M T B P L J

P2 (,CUNU ( ( N U L L T U C M ) ( i 4 E T U R N I J H d E ) 1 ) ( S E T Q T B P L ( C A P T B C M ) J ( S E r C Q w h h E J

Y 1 L S E T d C A R Q ( C A N 9 1 1 ( C C N O ( ( N G T P u l e ) (PFtULi! ( C S E T d E L S L N I L ) . .

( S E T C T B P L ( C O P Y T b P L N I L J j J J ( ( E L ) T B P L CAhal ( P K O G 2 (COldD ( S B S ( P K C C 2 ( P R I N l ( O U O T E

$ $ $ N O D E CANNOT B E P L A C E 0 lfii ITSELF... $ J ) ( M C S S N CAR61 T J A ) J ( G O Q 2 J J J 4 (1SIlu C A A Q T B P L ) ( P R C G 2 ( L C K D ( S a S (PRLiG,. ( P R d G 2 ( M E S S N CARCi N I L A

. . ( P R I N 1 ( Q U O T t 8 8 8 I S 1 i ~ k t ~ D . y I h 9 ) J J ( M E S S N T B P i T J ) J J ( G O Q 2 J ) J

( ( M t M 8 C P R Q ( C A R ( G E T ( L A O R ' T B P L J A P V A L J J J ' ( P K i J G 2 ( C G h U ( S B S ( P R O G Z ( P K O G Z ( M E S S N T B P L h l L I

( P R I N l (LJUOTE BS5 I S A L A E A l i Y 1 N $1 J J ( M E S S N C A R 9 T ) ) ) J ( G O Q 2 J . J J ( T ( C S E T C X T O P ( E F F A C k T B P L X T O P J J J J

( C S E ' T d KFL.G TJ ( C Q N C ( ( E U 4 XTCIPJ ( P K O G Z ( IJCCNC XTOP ( L U N S T B P L b i l L J J ( G O Q l J ) J

( T ' ( P R C G 2 ( N C O N C C A R 4 ( C C h S T e P L N I L J J ( Z S E T ( C A U R T b P L J ( CUNS C A R Q ( C A R ( G t T ( C A D K T b P L J A P V A L J J J J J ) J

62 ( C G N D f I S E T C Q ( C U R C ) ) ( G C P 1 ) J ( T N I L ) ) 41 ( S E T P T B C M ( i D H TaCMA ) ( 3 6 P 2 >

o € F I h € ( (

( E F F A C E ( L A M E O A (.+ L J ( P R O G ( Y k L ) . . ( C G N D ( ( h U L L . L I ( K E T U k N N I L J J

( ( E G X ( C A R L J J (R'ETURI'J ( C D R L J J J J ( S E T Q H L L )

E ( S E T Q Y L J ( S E T P L ( C O N L J J ( C L R D ( ( k t J L L L I ( R L T U R h H L ) )

( I t d A ( C A K L J J ( P R U G Z ( i i P L P C O Y ( C D R L J ~ ( R E T U R N h L A h ) ( T (GO E >

3 E F I h E ( ( ( C G F V ( L A M S O A ( X F A T ) ( P R G G ( Y L J

( S E T 4 Y ( C O N S ( C O P T f C A d X ) ) N I L ) ) ( C S E T u E L S L ( C O N S (CLINS X Y J t L S L I ! ( S € T Q F A T ( C K E A T E Y F A T 1 J ( C C h 3 ( O N L F ( R E T U R N Y J J J , ( 5 E T Q X liOUK X J J t

C - ( C C R C ( ( h U L L X J ( R E T U R N Y J J ( h C Q N C Y (CONCI '( ( S E T Q 2 ( A S E L . (C 'AA X b E L S L , ) J ( C O N S L I\11LJ )

, . ( T ( C O N S ( C O P Y ( C A R X J F A T ) N I L A J J J I , C f T Q X ( C D R X.1) . ( G C C>

D k F I N E ( ( ( A S C C (LAIYBUA ( X Y ) ( P R b G h 1 L

A ( C C N U ( L E G ( C A A R Y J X J ( R E T U R N ( C O A R ~ 1 1 ' 1 ( ( S E T b Y ( C G k Y J J (GC A ) ' ) ) . ( R E T U e I U N I L > .

O E F I R E ( (

( C a r l (L'AP!E,OA ( X i ( P R C G ( Y l C ( L O N O ( ( N U L L X 1 ( R E T U R N Y J ) J

( S E T Q Y L k C E N C Y ( C O N S ( C A K X J N I L I J )

Page 111: TAXL-A simple Hierarchical Data Structure Manipulation ...

( S E T G X ( C D k X J l (GO C> U E F I N E ( (

( P E E ( L A M E C A ( X Y L l ( P H G G N.1L ( C O N 0 ( ( U K L A M I L ( N O T SBS!) ( A N U R U K (NOT L J J J ( K E T U K N h l L 4 ) J ( P R I N L X I ( P R I N T Y J ( R E S k T ) ' ( B E G I h ( G U O T E M A I h ) N I L >

D E F I N E ( (

( M E S S O P (LPM6L;A N I L ( P N U J N I L ( P H I h T ( Q U U T E $ $ $ M I S 5 I h G C F E F A N D O I ) ( K E S E T J ( B E G I h (GUOTE M A I N J h l L >

O E F l h E ( (

( M E S C ( L A M B D A ( A YJ ( P R C C & I L ( C O N D ( S B S ( M E S S X Y 1 ) ) ) ( F R l r U L X ) ( P k l N 1 . Y ) ( P F t l N ! (6)111~iTF, d L d ~ i N t $ 1 ) ( F R I N T ( C u A H T H I S L I N E ) ) ( R E S E T ) ( B E G l h ( O U O T k M A I N ! h.IL>

U E F I h E ( (

( R E S E T ( L A C t 3 D A k I L ( P R D G N I L ( C S E T d C F L G N I L ) ( C S E T O S Y F T A X N I L ) ( C S E T d H U N N I L ) ( C S E T C S E S T! ( C b E T G A X P N I L ) ( C S E T Q P U T E N I L >

q E F I N t ( ' (

( S h O h U ! L A M E G A ( X ! ( P H U L ; ( Y J P ( C G k O ( ( A U L L X ) ( R E T U R h r U I L ) ) )

, ( P i i l N T ( C A I 1 k ) l ( P K I k T ( S E T d Y ( C U N U ( ( A N D ( N U M d E R P ( C A R X I ( N O T ( F I X P ( C A R X ) ) ) )

( G E T ( M E M U E K ( C A R A ) NUMSJ U S E S ) I ' ( 1 [ G E T ( C A R X J U S k S J J ) J J

( C C h D ( Y ( P R C G ( 2 )

. . . ( S E 1 . Q Z Y )

P ( P R I N T ( C A k ( G k T ( C A D R ( C A R Z J ) A P V A L ) ) ) ( L O N U ! (M!li"IJIB ( C A R 2 ) ( L O U Z ) J ( M k S S ( U U O T E D I I P C I C 4 T E S )

( C A B L ) ) ) ) ( C ~ N U ( ( N L L L c s c r a z c c c ~ ZI) 1 ( K E T U H N r j i L ) ) ( I j O P I ) J )

( S E T i J x ( C U R A ) I ( G O A> U E F I N E ( (

( I S I h ( L A M E C L ( U i ti) ( P K U G ( X ) ( C C h D ( ( h J L L ( S E T P K ( C A k ( G c 1 (CADI4 U I J A P V A L ) ) ) ) ( R t T U H k N I L ! ) )

I ( C G N D ((UR ( E U ( L A & X I B J ( I S l h ( C A k X ) 8 ) ) ( A E T U K k d l ) ) ( ( S t T b ) X I C C R x l ) l l i G 1 ) ) )

( i l E T U i c ~ \ l h l L > 3 t F I N f ( I

( D E L E ( L A M B L A ( X J ( P H O G L R A G E J i C t i N d ((Ed t M H K N X I W J ( K ~ S S ~ P ! ) ) ( C S E T d D t L T X 1 ( C C A C ( ( k c R X T a ( U U C T E ~ ' l \ i € ) ) ( P H U G 2 ( F T L H J ( S E T Q R N G E T ) ) ) ) ( S C T U ic ( & A N u E S N I L 4 ) ( C L N C ( H N G E ( P R O G N I L

! S E T L R h G t X I L (HPLACC ( CAk RhJCfi) k I L )

( C U N D ( ( S E T $ KIJGE ( C B K R N G E ) ! ( G O Z ) ) ) ( K t T U R l q tv IL ) J J

(CCIL-O ( ( t l : A X T k ( & J U T E F H C P ) ) ( f H O G Z ! F T C I i ) ( S E T L i R N G E ( k A N G E S N I L ) ) ) ) ( T ( 5 E T P KNLk ( C O N S X T U P N I L J ) ) )

( C L A D ( ( b i G T ( E U ' N X T W E M H K J ) ! M E S S I M P H O C I M N X T H Y I L ) ) ) (CCND ( SYIJTAX ( H L T U K i J 'F;IL)) )

( C b I T ( Q U O T E C E L L ) X HNGf> U E F I k E ( (

( D E L L ( L A M B O A ( A i4NG) ( P R O G ( T t M 1 FL T E M H J Dl (C t iNC( ( S E T U F L ( S E T d T E M K ( C A F ~ ( L E F ( C A D R ( S E T Q T k M 1 ( C A K X ) I A P V A L ) 1 )

( C U h C ( ( P W G ( F L G X U N G ) 052 1 S t r T ~ XKlv i r Kiuc;)

Page 112: TAXL-A simple Hierarchical Data Structure Manipulation ...

" D S 1 ( C d N D ( ( U H ( E ( C A R T E M R ) ( A H X R N G ) ( I S I N (C'AR T E M H J ( C A R X R N G J ) )

( P H O G Z P P R u G Z ( E F F A ~ E T E M l ' / C A R T E M R I ) ( S E T U F L S T J ) . ( S E T & FL ( E F F A C E ( C A R T E M R ) FL ) J ) J

( ( S E T Q XRNG (C'DK X R N B ) ) (GG D S 1 ) ) J ~ C C N C ( ( S E T Q T E M i i ( C C H T E M K ) ) ( G O D S Z ) . )

( T ( C S E T ( L A O R T t P l ) F L ~ I ) ( R E T U R N F L G ) J N I L )

. . ( T . ( P K U G 2 ( C O i u D ( S 6 S ( P R O G 2 ( Y k S S N ( C A R X) N I L ) ( P H I I \ T ( ~ U U T ~ $ i s h O T I N R A N G E T O S E V E K / D E L E T E B ) J ) I )

( G O 0 2 1 1 ) ) ) ( ( N C T ( E d R N G X T U P ) ) ( P R O S 2 (C0h3 ( S B S ( P K O G 2 ( M E S S N ( C A R X ) N I L )

( P K I N T ( Q U O T E S $ B , t i A S NO F A T H k K S 8 J ) ) J J (GO G 2 h 1 J ) (CZf"D (Fi N k L J

( D E L T ( P H C 6 2 ( L U N D ( ( A N D ( E L I X T U P R N G ( E Q T E M l ( C A R X T U P ) J J ( C S E T Q X T U P ( S E T U H N G ( C C K K T O P h l J )

( T ( C S E T b i X T O P ( E F F A C E T E M l X T U P ) ~ ) ) ( D I S C T E M l ) ) )

( ( N U L L ( M E M B T E M l X T O F I J ( C S E T Q X T U P ( C O N S T f M l X T O P ) ) J J ( C S E T d K F L G T

02 ( C C h D ( ( S c T G X ( C D R X I ) ( G G D l ) ) ( T N I L ) ) ( A E T U R N T >

U f F l h E ( (

( D I S C ( L A M B O A ( X I ( P R U G ( Y L B L S ) ( S E T Q L S L S ( L A K X) 1 ( S E JC Y ( C U D K X I )

C Z ( C E F L I S T ( L I S T ( L I S T ( C A R L t i L S ) ( E F F A C E K ( B E T ( L A H L B L S ) U S E S J I J ) U S t S )

( C O N 0 ( ( S E T U L B L S ( C 3 K L B L S I ( G O 0 2 ) ) ) 01 ( C C h D ( ( N U L L Y ) ( K ~ T U K N ' K I L ) J

( ( G R E A T E ~ P ( N M E K ( C A R ( G E T ( C A O H ~ C A R Y J I A P V A L ) ) ) A ) ( P K U G Z ( D E L L Y ( C O N S X N I L j ) ( R t T b H N N I L ) ) ) )

[ C I S C , ( C A R Y ) ( S E T d Y ( C U R Y ) 1 ( G O D l >

O E F I h E ( (

( P A K i ( L A M B O A ( X I ( P R O G ( C I U S h h G S R N G E E I D S I D S I D L Y J ( C O N C ((EG N X T k E M K K ) ( M E S S U P ) ) ) ( C S E T 4 E L S L & I L I '

( S E T O d h G S ( A A h C t S N I L ) l ( S f T O ICS ( C A R E L S L l ) (CCIND ((PIEMEI N X l w B Y A S ) ( F T C H ) )

( ( A h C ' ( N U L L X ) ( E Q EMRK N X T H 1 ) ( C G h D ( S t N T A K ( R E T U F A N I L ) ) ( T ( G O U N 5 1 1 ) )

( T ( H E 5 5 U P ) ) ) ( C C N G ((EP N X T w E M U K ) ( M E S S t i P ) J I ( C S E T U C F L G T ) ( S E T Q IDS ( c ~ f i ( ITM)).) i c s E T d CFLG N ~ L ) ( C C N O ( S Y N T A X ( R E T U R N b i I L ) ) ) ( C L N U ( X (GO L t l l 1 )

' ( C U I \ I C ( ( N O T ( t G 1 h X T w E M k K ) ) ( M E S S I M P A O L I M N X T W N I L J ) J L N 5 ( C C N D ( ( k U L L ( ~ t ~ b n N G E ( C A R F(FtGSJ ) ) ( P H L G Z ( C O h D I ( h i l T R U h )

( P k l l \ T N L k L J l 1 ( L O Uh41) 1 ) . '

U h 3 ( S E T d Y (,COPT (C,AK ' ( S E T d X ( CAR H r Y G t ) J J I )

( S i r T Q L 10s) L N 1 (CONL) ( (MEMf.3 ~ C A ; 2 ) % ( C A R X 1 ) ( S ~ T G ' O L E F F A C = ( C A K L 1 Y ) )

( T (PRGGZ;(C!Jbii) ( S d S ( P H O G L ( P R U G 2 ( P i i l h l l ( C A R Z ) ) ( P h I I U l . (CI.~OTE $i+i DOES N O T L A d U S ) ) )

L M E S b t J X T I ) ) ) (LC U N l ) ) ) ) ( C C N C ( ( S E T Q L ( C C K Z J ) ( G u U N 1 ) )

( ( N ~ L L YJ ( Y K O G 2 ( C L A O ( S d S ( P R O G Z . ( P R 1 , N l (QLI iJTE b $ $ C A h k L i T K E M C V E A L L L A B E L S F R O M 8 ) ) (MESS,& X T I ) ) ) ( G i i 1 l h 2 j ) J )

( K P L A C A A Y ) ( 5 E T b i L I D S )

Page 113: TAXL-A simple Hierarchical Data Structure Manipulation ...

l iN6 ( C E F L I b l ( L I S T ( L I S T ( C A k $ 1 ( E F F A C E X ( L E T ( C A R L ) U S E S ) I ) ) U S E S ) ( C C N U ( ( - S E T & L ( C U R L ) (.GC . U N 6 ) 1 1 ( C S E T Q K F L G 1 )

UP42 (CCIUD ( ( S E T G H l u i i k 4 C U H KNG.€.) ') ( G i l U N 3 ) ) ( T N I L ) ) U N 4 ( L t i N i ) ( ( S E T U R F i L S ( C O k 'RNG'S.) J ( 'dii UN5) ) )

( R E T U K t 4 N I L ) Le 4 S k T w I C i \ I L ) ( S t T U CIiL;S ( C O P T 1 D S ) ' J

( C O t q D ((t9 N X T h ( W U D T E t 3 t i F C h t j d (P 'ROGZ I F T C H ) ( S t 1 2 ' I D I \ r X T k J ) J ) .( CLNC c c ~a .I D ~ M K K . ) ( M E S S O ~ P )

( T ( F T C H ) ) ) ( C O r J D ( ( 'Ni )T( 'EC N X T h E M d K J ) ( M E S S I M P k C I L I M I\iXTk' N I L I ) I

L E 6 (CbIUL, ( ( & U L L ( S E T U h h G E (-CXk AIqGS')..!:! (PHCiCS ( C O N E ( ( N O T R U h ) ( P k I N T h L H G 1 ) ) I G O L 0 4 ) ) ) )

L , ~ ~ I S C T ~ V ( C A A ~ K I ~ G E I ) ( S t J . y l U b - ( b t l Q L ( L b P T C l d S ) ) ) L E l (CU.FiL; (4ME.Mb ' ( C A K 2 ) Y ) ( . P h U G 2 (C.UNU 'I Skis ( P R 0 6 2 ( P R O C Z

( P K I N L ( C A R L J ) (PKINL . ( U U C T ~ 53;s d ~ l t C A i ) Y CAO'ELS O J ~ j ( M E S S N (CAlc RPiCiLi 1 3 ) 9 i (GLI L U Z J ) )

( ( L E T 4 Z ( C C K 2)) (GU L d l j J ) ( 5 E T Q L . C I C S ) ( C C N D ( . ( N U L L I C ) ( S L T U E I U S Y ) J

( 7 ( S E T O E I I J S I U S 1 1 ) Lt !Y ( C U N D ( ( h U L L ( C D h E I D S ) I N I L )

( T ( P R U G Z ( S E T 4 E I D S ( C 3 R k l U S ) ) (GU ~ b 9 1 ) ) 1 ( C ~ N C ( ( N U L L IC) ( P ~ ~ C G Z ( R P L A C D EIGS iijs ) ( G O ~ t ) b ) ) J ( C G I J D ( (bbl I O ( C A R Y ) .1 ( F A L L 2 ( i . ' ~ G C i 2 ( R P L A C D E I U S Y 1

( K P L A C A ( C A R K N G E J I D S ) ) ( b U L b B ) ) ) ) ( S E T Q X ( C U R Y ) )

L 6 3 ( C D N D ( ( N U L L X 1 ( P K U Z N I L (cL;[\D ( ( N U T S B S ) ~ H E T U W ~ ~ N I L ) ) ) ( P R I k 1 i l i ) ( P K I F i l ( O U C T E B b P ' C D C S NOT L A b E L 9 ) ) ( V t S S h (LAC< K N G t J ~ I L ) ( P k I l u 1 ( d U D T t d % l -- 8 ) ) ( M k S S h ( C O N S 13s N I L ) N I L ) ( P H I N T ( Q L O T E $ 8 8 A L > ~ E D AT EIVDSJ 1 ( R P L A C U Y I D S J j )

( ( E L i C ( C A ~ x J ) ( P ~ U O Z ( K P L A C O Y I D S ~ ( Y P L - A C D t ~ ~ s x i ) ) ( 1 ( P K C G 2 (IJA31;2 ( 5 C T L Y X J ( S E T Q X ( C O B X j ) ) (GU L B ? h , 4 1

L e d ( 3 t F L f S T ( L I S T ( L I S T ( C A i l 4 ) ( C C N S ( C A K F(IZGEI IGET(C.A lc I I U S E S ) ) ) ) U S E S ) ( C C N L ( ( S E T Q Z ( C D R L ) ) (C;C L k b l l . 1 ( C S E T G KFLG 1)

L t 2 2 (CUIUU ( ( S E T O RNGE ( C U R K I q G t ) ). (GLI L E 5 ) ) ( 1 [ \ r l L ) ) L C 4 ( C C h D ( ( L E T 6 1 K h G S ( C W i i kr\iGS:).) (GO L B C I 1 )

( ~ 6 T l j l l N i h l l > i j E F I N f I I

( C C L T (LAIVleCA h I L ( P R O 3 ( X ) ( S E T Q x ( R A N G E h l L ) ) (CC;ILL( ( N ! d T ( E6 ~ X T H E P l X K ) ) ( W E S S : M P d u L / P : N X T k N ' I L ) b )'

t c c n i , c s ~ r \ ; r a x (KETUKI\I NIL)) 1. ( P K I & T ( k M t M A >

i > E F I h F ( (

k h P - E C ( L A M O L ) A ( X I (PRO(; ( K ) ( 5 E T Q K 01

h cccno ( ( ~ U L L X I (HETURI; K J ) ) ( ,CE.Td K ( A 0 3 1 K ) I ( S t T O k (( 'CCK A')') ( G i i &>

O E F I N E ( ( . I C K L T ( L A M U C A h I L L P K U G ( X I

( C S ~ T C C F L G T ) ' (CONU ( ( E U ( C A A C ~ ( ~ E T U x ( I T M S ) . ) ) E M R K ) . ( M G S S U P J )

( ~ C T ( t ~ N X T W EKRK J ) (.MESS I'MPRUL IM N X T ~ N IL I I ( C C N D ( S ~ I \ ~ T A X ( k ~ . r i l n i \ l ;JIL)I)

C ( C U h D ( X ( C P L A T E ( C A k NIL.)) ( ' T ( 0 0 C l ) . ) J ( C S E T G X T L P ( C C k S ( C A N X ) X T O P ) ) ( S f T u X ( C D K X j )

Page 114: TAXL-A simple Hierarchical Data Structure Manipulation ...

C l 'I C S E T Q K F L G T J ( G U C J C S f T Q C F L G N I L ( H E T U K N N I L >

U t i F I N E ( ( ' ( W I - E R E P R T ( L A M B C A ( K N G E ( P R O G '( X L1)

( F T C H J ( C S E T G I S k F . T I ( C O N 0 ( S Y N T A X KI L ) ( ( N U L L H N G E ) ( R E T U U h N I L ) ) I ( C O N 0 ( ( E d N X T h ( Q U O T E C O U N T ) ) ( P K U G Z ( F T C H J

( S i i T Q w ( U U U T t K E E P C N T ) ) ) J ( ( E Q h k T k ( Q U O T E V A L U E ) ( P R U G 2 ( F T Z H )

( S E T P W ( Q U U T E & l i E P V A L ) ) 1 ) ( T ( S E T ; w ( Q U O T E K E € P . J ) J )

( S E T U X ( R A N G t 01 1 ( H E T U H h !Y Y R N G E >

U E F I k E ( ( ( K E E P ( L A M B 3 A ( T S T N O U E S N O U t S I ( P K O G ( X H ) . .

( C C N C ( S Y N T A X ( R E T u R i d N i ~ ) ) )

( C G N U ( ( k U L L T S T N L U E S ) ' ( A E T U R N ( C O N E ( I S N F N I L ) ( T N U U t S J ) ) ) ) K 1 . ( S E T 9 H T S T h O U E S )

( C C N C ( ( N U L L b i O U k S ) ( R E T U R N X ) ) J K Z (LONU ( ( ~ ~ U L L , H J ( C O N U ( ISNF ~ I L ) ( T ( S E T L I x ( C O N S ( C A R N C D E S ) x ) ) d ) r

( ( i i t c ( E Q . ( C A k ti) ( C a K N U U E S I ) ( I S I N ( C A R H ) ( C A K N U C E S J ) ) (CC.I\C ( I S N F ( S E T U X (CilkS ( C A R N U D E S ) X ) ) ) ( T N I L ) ) )

( T I P H G G 2 ( S E T 6 1 H ( C C h H J ) ( G C K i ) ) J J ( S E T C N O u E S ( C D A Fjc)OES) I (GO K 1 > .

O t F I I \ E ( (

. ( K E E P C N T ( L A M t 3 u A ( T S T N t l U k i S N U D t S ) ( P K U C ( X R E L NUM C h T H) ( S E T 2 H E L ( F T C H ) J ( S E , T d h U M ( F T C t i I ) ( C C N C t l h C T ( k U P 8 E H P k U M ) ) ( M E S S ( Q U O T E $ $ $ N O T A N i M 8 t R . .. 9 ) NUM N I L ) 1

I l i V U T (ML-MB R E L F t E L S ) ) ( W E S S ( U U O T E $ $ $ f ~ t i T A R E L A T I O N A L OPERATOR... 8 ) K E L N I L ) 1 J . I

( C C N D ( S Y N T A X ( R E T U k N h I L J ) ( C U h U ( ( N U L L T S T N O U t S ) ( R E T U k I \ N I L ) ) )

K l ( S E T Q H T S T A G C E S ) ( C l j l J U ( ( N U L L N O D E S ) ( H E T U R h X J J ) (SkTrbl C N T i))

K 2 ( C C i V i l ( ( N U L L h ) ( G G K 3 ) ) ( ( I S I N ( C A R ti) ( C i h K O D k S ) ) ( S E T & C N T ( A U O 1 C N T ) ) ) )

( S E T Q H ( C U R h ) ) ( G O K 2 ) K 3 ( C C N D ( ( h K t L C F M C N T K t L N U b i ) ( S t T Q ' A (CCINS ( C A R N O D E S ) X I ) )

( S E T w N O d E S ( C b & N U D t S ) ) ( G O K L > O E E I h E ( (

( K E E F V A L ( L A I Y B L P ( T S T h O C t S h C U t S J ( P H C G ( X Y K E L IriUM H ) ( C U N U ( ( N O T ( h U M B f k P IJuM) J ( M E S S ( Q U U T E $ $ $ h O T A NUMBER... $ 1 NUM N I L ) )

( ( k O T ( M E M B R E L R E L S 1 ) ( M E S S ( Q U O T E S B S N i l T A K E L A T i C N A L GPEliATGH... 9 ) AEL N I L ) I )

( C O N 0 ( S Y N T A X ( X k T U R l V h I L ) 1 ) '

( S E T 4 K E L ( F T C H ) ) ( S E T w k U M ( F T C H ) ) ( C O N U ( ( N U L L T S T k U U E S I ( W E T L k h h i L 1 ) J

K 1 ( S E T Q Ii T S T N O D t S l I

( C C h D ( ( h U L L \ C U E S ) ( R E T U K h X I ) ) K 2 ( L O N U ( ( N U L L 1 - 4 ) h I L )

( ( A N D ( S t T Q Y ( F I L U M ( C A A R H ) ) ) (OK ( 'EQ ( C A K td) ( L A H K O O t S ) ) ( 1 S I h ( L A X h ) ( C A R N O D t S ) ) ) ( k R E t L i P M Y R E L N i M 1 )

( S E T U X ( C G N S ( C A R N i 3 L S I X J ) ) ( T ( P H U G Z ( S E T 3 h ( C O K I - ) ) ( G O K 2 ) ) ) )

( SETQ. i \ODES ( C U R NUCES J ( G O K 1 > O E F I l V E ( (

( h R k L U P M ( L A M B D A ( N k E L P M ) ( P K O G N I L ( RE T L F N

' (CUtqD ( I t 4 R E L P ( u J U T t f L J l ( E d U A L h M ) J ( ( E d R E L P ( U U t I T t k E Q ) ( N O T L t Q L A L N h i ) )

Page 115: TAXL-A simple Hierarchical Data Structure Manipulation ...

( (124 KELP (IJUUTE G K I I (GREATECP h M ) ) 4 ( E Q KELP I GUOTE G t 1 ) ( O k (GREATEHP N M) ( EuUAL N P I ) ) ( ( E C RELP (QUCTE LS 1 ) (LESSP N M)) ( (EL ) KELP ( UUCT t L E ) ) ( C K ( LESSP N M) (EQUAL N M>

f O E F I N E ( 4

(PESSN (LAMBCA (X F L G ) (PHCG h I L (CON0 ( ( N U T SbS) ( k E T U k N h 1 L ) A) (SETU X (CAK X ) J

A ( F R I N 1 (CAR X ) ) (COND ( ( S E T U X ( C U R x ) ) (PRCG2 ( P K I N i BLAhK) (GU A ) ) ) ) (CGKD ( F L G ( T t R P & I >

t j E F I h E ( ( . ( I N P T (LAMBOA k i L (PhUG ( I i A P L NJTF X X H Y YH I

(CSETQ ELSA ( I T M ) ) c (CCkD (SYNTAX (GO S l I 1

( ( N U L L ( S E T 6 Y1-l (NCMN E L S L ~ J ~ (RETURN I J I L ) ) ) . ( S E T 4 I N P L (CChS YH I Y I L ) )

S 1 ( C C I J U . ( ( i L I FtXTvr (6;bCTE I S ) ) IPRLGZ (FTCI-) ( C S f T U [SNF l L i l N U I t t U N X l k luLWltr I J i l T I I iPACSb2 ( C T C n i l \ l L J ) ( T V I 1 ) I ) ) .

2 3 (CCND ((VIEMU hXTki hOTf4) N I L ) (SYNTAX (RETURN N I L ) ) ( 1 (GO Z O ) ) ) (CUND (eta N + T ~ c u u u ~ t NLT) r

(PKOGZ (SETQ I N P L (CONS N I L I N P L ) ) ( l -T( ; t i ) l J (,T (SETC INPL' (CCFIS T ' I 'NPL ) ) ) )

(CUND ( ( E d &XTw (QUOTE 1 % ) ) ( F T C H ) ) ( T ( M E S S I M P L D L I M NXTW h I L ) 1 )

( 'ETC X ( I T M ) (CGNU ( SYiITAX ( G O 2 3 ) ) .'

( ( N U L L ( S E T u YH (NCKN X! 1 ) (KETUKN N I L ) ) ) ( S E T U I ~ P L cccns Y H INPL)) ti;U 2 3 ) . . .

LO (SETU YH (SETC Y ( C A k 1 h P L ) I ) ( S E T Q ' I N P L (CDF I N P L ) ) L 4 (CLhI.1 ( ( h I J L L I h P L ) ( R c T U K h YH) ) I

(CSETG NOTF (CAR 1 h P L ) A ( SkTG X ( LAUK I N P L j ) ( S E T U Xt i N I L ) ( S E T 4 I N P L ( C C C K I~PL I I

2 1 (CCND ( ( I S I h (CAR X ) (CAR Y ) ) (PRCG2 (CUILD (NUTI- ( S t T d .XH (CONS (CAR X ) X H ) I ) (1' N I L ) ) . (60 ZZLJ)) - .

( C C k D ( ( StTC; Y ( C C K ' Y I ) (LC; L 1 1 1 1 ( C 6 f u Q (FlbrF N , I L ( T I SkJu XH (C(.il ' lS ( L A K # ) X t I ) 1 )

L 2 (SETU Y Yr l ) (CL;l\tD ( ( S k 1 i . J X ( C D K X ) ) (CC ' 2 1 1 ) ) (CGND ( ( SET4 Y ( S E T U YH X t i ) (GO 241 1 1 ( F E TUR~U h l L >

U k F I N E ( (

(RAhGES (LAMdDA ( F L G J (PKUG ( X I H (S t iTG X (CChS (RANGE FLG) X I )

(COND ( ( t Q 1 h F . r ~ (UUUTE ANU)) (PHOLZ ( F T C H ) ( G O H I ) ) ) ( R i T U H h X>

I )EFINE ( (

( U U I T (LAMUUA ( F XH YHI (PkOC; ( X I ( s c r u K A H )

0 3 , (CChD ( ( h U L L (CAR Y H J ) (PUOCZ ( P H I h T h L P G l (GU . D 4 ) I ) ) 0 1 (CCNL) ( '( NclLL (CAK X ) ) ( .PhUb2 (PIXI I\;T NLHG) ( b U L ) Z ) ) 1

( F ( C A A X ) ( C P R YHI) ' . .

U 2 (CGNU ( ( S t T d A (CDK x l ) (GO U L ) ) ) (SETQ X XH)

~ 4 ( L L ~ L t o t i d ~h t i L H Y n ) ) IGU i ~ 3 1 1 ) (HETURN N I L >

2 E F i N E ( ( (FhUC (LAMSOA ( X I (PROG F t I L N (CCND ( ( ~ I u H B E R P (CAR X I ) ( H t T U k N (CAR X I ) )

Page 116: TAXL-A simple Hierarchical Data Structure Manipulation ...

' ( ( S E T & X ' ( C U R X J J ( G O N J J J ( R E T U R N N I L >

UEFINE ( ( '

( L I S ( L P M B U A N I L ( P R U G ( Y X ) ( C C N D ( ( E G N X T k E M H K J

( C O N 0 ( ( S E T u X L I N E S ) ( R E T U H h ( P R U G N I L L ( P R I N T ( C A R XJ J '

(CCI\ILi ( ( S E T 4 X ( C D R X.41 (GO L ) ) I 1 1 1 ( T ( M E S S ( Q U G T E B B B r 4 G T t i i N G T C L I S T S ) B L A N K T J ) J ) J

( C C N D ( ( N O T ( A N D I R U i v l E 6 i i P ( S t T i ) X ( F T C H ) ) ) ( F A X P X J J ) ( M E S S ( O U U T t B B S L I N E h U M d E H MUST 3t I N T E C E H S J B L A N K N I L ) J

. ( T ( C G N C I t h ~ l T d A N C . I S E T C ! Y ( L I N E S R C H X 0 ) ) ( t d ( C A A H Y ) . X I ) J

. ( M E S S ( Q U O T E 4 9 S h O T H I N G T O L I S T $ ) B L A N K T i 1, ( T ( R E T U R N ( P k I k T ( C A R Y J J J J ) ) ) ' >

O t F l h E ( ( ( L I h E S R C H ( L P M B C A ( L F L G ) ( P F C G ( Y L J

( C O N 0 ( ( O R ' ( N U L L . L I r \ l t S J ( L i i t A T E R P ( C A A H L I N E S ) L ) ) ( H E T U K h (CUFID ( ( O R ( F I U L L F L G ) ( N U M B E R P F L G ) ) N I L ]

( T ( C S t T G L l h E S ( C C h S L I k E L 1 N E S J ) ) J ) J I ( E Q ( C A A R L I N E S ) L )

( K E T t l K N ( C C N D ( N U L L F L G ) ' ( C S E T Q L I N E S . ( C O H L . I N E S J J ) ( ( h U M t i t R P F L G J L LNES l ( T ( R P L A C A L I N E S L I N E ) ) ) ) ) )

( S E T i l Z L I h E S ) . ( S E T Q Y ( C C R L I N E S ) ) M ( C C I J U ( ( U k ( L U L L Y ) ( G l i t A T E H P ( C A A H Y J L ) )

( K E T U K N ( C l j l u D ( ( .OH ( E j U L L F L G I ( N U M B E R P F L G J 1 N I L ) ( T ( R P L A C U Z (CIJIJS L I e E Y J J J J J J

( ( E O ( C A A K Y ) L ) ( * E T U K N ( C U N D ( ( N U L L F L G J ( K P L A C D Z ( L O R Y J ) )

( ( h U M B E R P F L G J Y J (1 ( H P L A C A Y L I N E J J J 1 J I

( S E T Q L Y J ( S E T Q Y ( C U K Y I 1 ( G O M> D E F I h E ( (

. I H N k ( L A M i 3 D A N I L (PRO(; ( X Y 1 ( C G N O ((Eu ~ X T W E M R K J ( S E T Q Y L I N E S ) I

, ( ( N U T (AhU ( h U M E E P P ( S E T & X ( F T C h J J J ( F I X P X J J J ( M E S S L N M I D L A h K N I L J J

( ( N O T ( P N D S SET^ Y ( L I ~ E S K C ~ ~ x 0 1 ) ( k ~ ( C A A K Y ) X J ) ) ( M E S S ( Q U O T E $$ShU , S U C H L I i i l E NUPEIEHBJ B L A N K N I L A J )

. . ( C S E T Q T H I S L I N E YJ ( C S E T Q L I N E ( C O A R T H I S L I N E ) ) ( C S E T G s e s NIL) ( C S E T Q RIIN T >

iJfF1NE ( ( ( S T F P ( L P M E C A ( X ) ( P K U G N I L

( F H I K T B L A N K ' ) ( P R I R L ( C U U T E S T O P ) J ( P H I N 1 ( C O N D ( X ( U l i O T E $ti$ A T . L I N E $ 1 ) ( T ( U U C T E $ B $ A F T E R L I N E b)))) ( P R I N T ( L A A H T H l S L I N E ) J ( C S E T Q T H I S L I h E k I L J ( C S E T C 5t2S T J ( C S E T Q R U N N I L ) ( B E G I N ( 3UUTE- MA1 l \ r l & I L L >

i ) E F I l r E ( ( . ( L E 1 T ( L A M B D A N I L ( P R t i G ( h L A Y J

( C C N D ( ( N O T ( A T O M N X T W ) ) ( M E S S ('QuUTC P t $ I L L E G A L A L G E ~ H A I C V A R I A B L k S l B L A N K N I L ) ) )

( C S E T d AXP T J ( S E T U X ( F T C H I I ( S E T O h , ( C k T X F V A L J ) ( C O N 0 ( ( N O T ( A T C M N X T h ) ) ( , P k G G h l L

( C C b i U ( INUMBEHP id J ( M E S C A V C S .X I J I . ( S E T 4 X ( C C h S X N I L ) ) ( C S E T U OUT? ( C U k S Y I L h l L J l ( P P O P ( F T C H ) ( C S E T Q W T P ( L O R U U T P J J

Page 117: TAXL-A simple Hierarchical Data Structure Manipulation ...

( C O N 0 ( S Y N T A X ( R E T U R N C U T P I J ) ( S E T 9 L ( E V L L U L i T P I J )I

( ( G I ( ( N U L L k J ( h U M B t R ' P k ) l N I L . ) t T ( M E S C A I M S X I ) )

( C C h C (('EQ NXTW t O S 1 l ; N ) ( F T C H ) ) ( 1 ( M E S S I M P t i C L i M h X T h ' N I L ) ) )

( C G N D ( t E U h X T w t M R K . ) ( M E S S C P I J J ( S E T O Y ( C O N S h t I A N I L ) I

D ( C C N D ((E6; N X T w . E M l i K ) h I L J ( T t P K O G 2 ( A P P E N a A Y ( F T C H I J ( G O D l ) ) I

( C S k T Q A X P ' N I L ) ( C S E T U U U T P (COlr iS N I L N I L ) ) , . ( P P O P ( C D k Y I ) l C S t T Q C L T i J ( C L H C U T P I )

(iONCl ( S Y N T A X (FtETURN 0L iTP.J 1 ) . . ' ( S E T Q Y ( E V L L S U T P J J

I L L N U I ~ A I U M A J I L U I U O . L ( C ~ U C Y ) ( ! J E T L I S T ( L I S T ( L I S T X Y ) t P V A L 3 ) . ( T N I L I) I

( ( S E T P k ( S A S S L W ) J ( ? P L e C C w Y ) I ( T ( D E T L I S T ( L I S T ( L I ST ( G A K X 1 ( C G N S (CONS 2 !

( G E T ( C A R X J P V A L ~ J 1 1 P V A L I ) I ( C 5 E T G K F L G T ) (RCTUCJN YS

D E F I N E ( (

( A E X Y ( L A M B D A ( I N P I ( P R O B ( F L G Il\iC' X I ( C C W ( ( E Q ( C A R INPJ P L U S S J ( S E T U INP (CDR A N P ) ) I

( ( E d ( C A R I & ? ) D A S H ) ( P F O G Z ( C S E T b j S T A K ( C O K S ( C U ~ ~ S l i l ~ d V E hkGl 4 ) L l A K I ) ( S E T C INP ( C U R I N P I ) ? ) )

A ( C O N 0 ( ( N U L L I N P l ( C O N 0 ( F L G ( H E T U R k G U T P ) )

( T ( M E S S I A E B L A N K N I L ) ) I J ( ( A T G C I h P J ( S E T C I k P ( C C N S I N P N I L ) ) ) )

( S E T 4 X ( C A k I W P ) J ( C O h U ( ( A T C W X )

( C O h U ( ( S E T O I h C ( S P S 5 G C A O P S P N I L ) I ( P K O G N I L ICLiI '4D ( (IJULL F A G ) ( M L S S I A C B L A N K N I L ) I )

C (CONt i ( ( L E S S P ( ~ C A K S T A K ) ( C U R I N C I ! ( C S t T u 3 1 A K I C O N S I N C S T A K ) ) ) . .

I T ( P U 0 G 2 ( P ~ U G ~ ( C C N D ( ( N b k L : (CAACI Sl A U l J ~

i ~ ~ j ' 1 . l ~ ~ (hEi61 i - L G N i L ) ) ) ( T ( A P P E & D L OUTP ( C A A R S T A U I I ))

( ~ S E T L I S T A K ( C D K S T A K J I ) ( G O c ) ! I ~ J ) I T (11ROG2 (l1Rl;C,7 L C G N D ( F L C ( M E S S I A F R l APjK I \ i I L ) I )

APPEND^ C U T P X J J ( C U N O ( I A N O ( C D R I N P ~ (aUOT ( A T ~ M ( C A ~ R I N P ) I J

I N L I T (NIJMBEUP X ) J J ( P k O G 2 (PP(.lP I f . A K ( S k T U I N P ( C O H I N P J J J i

( k P P E N r j l CiUTP SUB) ) ) j ) ( T ( P P b P X I ) )

( S E T U ~ L G ( N O T F L G I ( S E T Q I N P ( C U R 1 N P I ) ( G O A > d t F 1 h E ( (

( P P t P ( L A M B L ~ A ( X ) ( P H O G Nli ( C f i E . T Q S T A K ( C O N S ( C O N S L P A R 0 1 S T A K I ( A E X P X I

F ( C C N D ( ~ E Q ( C P A H S T A K J L P A K ) ( . H E T U K ~ ( C S E T Q STAK (CUR STAKJJ I I ) ( A P P E N U A U U T P ( C A A R S T A K ) J (CSETLJ S T A K ( C D R S T A K ~ j ( G O $>

L J E F I N E ( (

( C h C C ( L A M B C A ( X ) ( C O N D ( ( k U M B E R P X I X )

( I ( M L L C A l N S 6 L A N K > UEFINE ( (

( C A R \ ( L A M B D A ( X A ( C C N D ( ( N U T ( A T G M X J J X ) ( T ( M ~ S C A V C S B L A N K >

L i E F I h E ( ( ( E V L L ( L A M B D A ( X i ( P R O G ( Y V A L )

Page 118: TAXL-A simple Hierarchical Data Structure Manipulation ...

3

t

'2

c.

c:

D

rr.

n,

rr

.

n-.

C

- n

- n

W, - n

-

T

rn

Z

0

0-

CJ -

- L

nL

' 0 -

Xs

7

- m

7-

-

D7

-

- .-Or--

--

z-----d

r

r.

--

~.

- 4mv.

nw

ntc

.

C*

n-

~m

zn

O

n

-n

t,r,n

c7

I

L~

VO

C m

:.

nv

,

v.

C:

~C

J-

~O

C

I I/,

rn

c.

ow

c

-m

nr

nv

.~

-+

,

z

-m

z

z

-4

2

-.

z

r.

7Z

zn

-.

Z-

-+

z+

mr

-E

C

n--I

0

I?

--C

C

- 0

C-4

O

CG

-u

c

CC

L-

r

E:

r

7=

-I

- o

-- -

n-p

2-

---

I&

E; B

*;

En

<--C

Z

- --

- -

z

Z-r. r

--3

4

-w,

-I-=

x-

-

o

-v,

-=

---a

m

CG

b

-.

ns

7u

T

z.4

Z

R

ID

-v

,

rn

wz

m-+

lT

<Z

Xn

.C

-

M*

Cx

C

:G

CO

-

r,

Z

C-

cC

r:

fl..

m

rr

c-

--

-

--

--

--

--

sD

~

-:z

cT

~;~

-P

4

OC

~D

v

-i

4

3 D

D+

r.4

30

0

4

- ~

--

n-

-W

Cn

rr

~

-i4

-

4 T

G

X'D

r

r

D

m Z

PIG

-C,U

lV!

C

rr,

n-.m

m-m

mrr!m

rr.v

, ID

-

4~

2

TD

-

b

I- -

- -

X

-0

XZ

@

.r~

:m

Z-

cT?

tn

CC

'L

:E

?C

.4

lc

Z

XX

--

x-

r

bt

l-

<

<

x

7

D

DW

-4

-

w.

c

..

m

cx

w

- r!

07 i

rj c-

-I

D -ir

cjc

-

C-

-

~-

I-

"z

X

I-

4

C

V P

I -tP

O<

<

-<

<4

<

I-

XZ

-

'z:

tC

3.

C4

-C.

<

PC

'T

ZU

-

D-

-+

-

--ze

z

v.-

.,

< <

--

-c

-

- C

ZI.

Z-

p-

-

m

mrr.

3-

-

~(

CIC

,T

~G

-W

.-

~-

C:D

C~

;-

~D

n

m

rx

wr

rv

-

WC

V

D T:

-W

--

~W

-V

CV

V

C.D

m

c-

i

v1

fi

~

ZC

DC

L.

~I

D~

~-

S-

3

-

r.

3~

T~:.c

-

-,z

:m-

C V

IZ

7J

C *,

XF

W?

+E

,E

-E

X

n

.Z

co

CD

~r

rC

mT

w

Z

lI

:c

?

vc

-+

Zt

C

-4

v

mx

c

co

c

e

;D

f-C

, -P

--

71

4.C

wx

!IW

D

~

.-

>r

cT

o

xt-

a?

c<cz

--

+z

rz

r+

o

xx

w-

v

.<

C.<

n

-n

;+

=-

-w

X

'x

-

7-

4

- 2

-T

Ci

- X t.

C..E

. k>

Z CE c IT

--

pc

x-

m

z

>- -

- rr

l -

- b

SX

-

- -

C,

v,

ZCJ

cnc

3

- -

PD

-r

.1

-C

.<

7

.0

w

I -

.--

-

-x

X

.

0

Z

v x

r

nc

-c

e-

x

4-

c

--

w-

cc

E.

xb

r

,-

m

3+

-4

c-

-c

X.T

L.-Z

z-

c

-2

-ZZ

-4

4 r

TZC

---I

z

z

W~

+W

*C

--

~ -T

R-7

- 7I-n

. -4

r-

' --

~m

--

c X

->

~

-~

~-

v.

~S

-u

-4p

m-

-l

ry

-i

-0 - 4

w:

7, - r

-rr

r-r----

n 3-0

4-O

D L

-D

-c

rn

-r

lc

V

, w

CZ

WC

IW

.

. -.

X -

I-*-

Dv

.X

-

n-.

w.<

b

rn

D=

. -

T

-m

w

-V

SW

~A

72 -

4

i C:

r -

-W

;Z

zn- -

rr

-I

~~

P~

;-

~.

~~

--

XT

T~

-C

T.

7

- Z

7

4-

v

2. .w

t rr

. 7;

4 z n

- c

r

L

n-

+W

,T

)

r.m

-m

-

- -c--

C

' n

:z

ln.

#----I

- -

OD

&

-n

,m

-

C

ez

c',

-

r

7 6

W.

C

'm

2

2.0

r

W.

OO

-T

~~

-

zZ

-Z

C,

~

c

-n

:x

-

z

- r,

my.-

; c

;~

v:

-~

~c

-D

D

mc

~-

c

.n

cm

c

r -I

- C

VIT

c

__

_

- -

X-

-D

C:.-

XG

~C

~,B

r

:m

%x-x

- -

-<

-

V

C. C

D

FE

-

T~

x<

Px

--

c-

~ t

-P

C,-

P

C.

PC;%

-n

D-7

.-

--

Z

*P

C%

--

Sr

,Z

-

r p C

. C

D

Z

x

. -I

mn

t

mc

-C

-

rx

nx

-~

~n

r

- 7

V:

V

W

C

C,

Tw

'-

4v

,-

C-

Z*

.C

IG

XD

C'.

c

-c

xlA

rr.

4r

-

1.

~n

-0

D

~-

<c

~-

~A

~z

Dz

-c

-

-I

-r

<

Z-

-

- -

~-

IC

-X

~-

PC

~~

A-

~Z

C:

O

nz

--Z

IC

-

- Z

- P

'Z

--

E

T+C

.DD

-iWZZ

Brr

I

Z

- W

IT-

c

<m

-

C n: 21

W

7

- 13

E

Z-D

-

I7

IT.

D

-0

V

-D

W

DX

4

r

0 x

-

- 7

34

-

-4

z'

. W

4

b

V

C3

Z

cz

L=

C

78

-P

C:

D -

-4

--

~~

p-

v.

z

v

z

~n

- -

DX

P

7r

D

OC

-~

:.F

-I-

VZ

.

v- cn

C.

F.

a:

m

u

7r

zzc-

b-

- v B

w

r -

- r -

c

z:

--

~

-I-

F D

C

r:C

X

- z

n

g, '$

-

0--

To -

72

X

c -

z.

-.

-~

-n

-4

6

- I Z

z.

7r

C

-2

:t--r

,c

--.

m

4

- D

WV

,

- n

zr.z

zc

E

x -

- i/?

I

- v,

- D

C.C

LC

13

tP

< D

-+

C

0

k'4

Xix

-C

:

- x

I

- z

7

P-

0

FC

C-

C

Zz

-

jrr -

2:

(r

'l

pw

-E

-C

.

C-

X -

-i -

r'

- 4

Tr.-IC

..T

PD

- -

<

D -

<

D

DD

D

X

C

- C X

-

- B

'7c

Z7

;1'V

,X

- - r -

r

-m

-

4

l~

c

- -

-c

.-

vlD

v.4

i

m L

-

-D

--+

-ID

-

. -

4

D-

DX

.

-u

7r

-y

-

. *

< --

--

m

---L

w

* -

--

- C

1

-

Page 119: TAXL-A simple Hierarchical Data Structure Manipulation ...

APPENDIX n

LOGICAL FLOWCHART OF THE TAXL . ~ ~ T E R P R E T E R

+ Fetch

Place Previous Commanc Yes Command.with Sequence in Comu.and Buffer with Nunber given by instruc- Recorded Sequence N u m b -+ tior coupter from command

bufkr Fetch From T~rmiIIal ma

Set [nstruction cokte; ,

to Squence Number of Next Command in Command

Sequence

, Sequence 1;: 1 Record Sequence Number

Reset Sequence

1 Switch on Key word

' (+e)&b,,&&b COUNT 1

Page 120: TAXL-A simple Hierarchical Data Structure Manipulation ...

For Each Label in Data Item:

I

Create Node with '

no Labels, no Father, no Sons

For Each Data Item:

Add Pointer to Label onto Label List

a t Node

Add Pointer to Node onto List of Uses on Label's Property

List

Get Data Items

Get Data (-1 Add Data Item

to List

Return List

Get Data cl;,

Add Word to List

(See Table 2) e Return- List

of Words In Data Item

Page 121: TAXL-A simple Hierarchical Data Structure Manipulation ...

Error P- Error i.c'--@ Fcr Each' Iabe l

in Data Item:

> i

Add Pointer to . LEbel onto Label

List al Nodb

Add P ~ i n t e r to Node onta List of Uses on Lab l ' s P,roperty List, if not P-lready there

f L

.

ForEach Label in Data Item:

., Remove Pointer to Label from Label List at Node

Remove Pointer to Node from List of Uses on Label's Property List, unless Label occurs Again a t Node .

Page 122: TAXL-A simple Hierarchical Data Structure Manipulation ...

For 'Each Node M in Range2:

Add Pointer to M onto List of Fathers

of N

Add Pointer to N onto List of Sons

of M , A

I

w P W I

Create a copy of the

every ,node in range, . .downward (along lists of sons) toward leaves of tree. Redefine range, as the root nodes of this copy. For each node in (the new) range, make the list of fathers null

159486 -

Page 123: TAXL-A simple Hierarchical Data Structure Manipulation ...

F3r E . x h Frther M of the Node N:

IZemo-;e .the pointer to the son N from the list d s m of M

Make the List of Fatbers d ' N Null

from Rangsl to RangeZ

For Each Node N

For each father f of the Node N Through which N is Within M:

Remove the Pointer to the Sm N Fmm, the List of Son€ of f

Remove the Pointer to the Father f from the List of Fathers d N

.

For Each Node M in. Rangea :

a

159487

Page 124: TAXL-A simple Hierarchical Data Structure Manipulation ...

Get Rangel (5 The Remainder of this Algorithm is Recursive and will be Stated in Words.

The accompanying Diagram will Help

No to Clarify the Algorithm

Let nodes n . and f be Range 1 and Range2 .respectively

No

1 Define Range to be all the ~ o & s of the Tree

Get

-b 1. Remove Hierarchical Connections from Rangel to Range2

2. I£ n now has a t least one father remaining, then quit (A nonclosed subtree has been encountered)

Otherwise,

3. Remove al l labels from n (See flowchart for unlabel)

4. ' Check each of the sons of n (i. e. , al l nodes p)

If p has on1 one father (i.e., n), &en, recursively, '

go.to Step 3 with argument p. (The algorithm remains in this recursive l q ' a s long as a ponclosed.subtree is not encountered.

I€ p has more than one father (i. e:, th.ere is a node q in addition to n), then reoursively, go to Step 1 removing con- nections from p to n.

Page 125: TAXL-A simple Hierarchical Data Structure Manipulation ...

Get Range

ode and Subtzee ro Secondan Storage

Copy Laage Mormatizn for Each Label i n the . Subtree into an Exterul Dictiocary, .Itself Sav~d on Secondary Storage

Restore 0 For Each Node In Range:

For E&A Node In Range :

Secondall Storage

Secondary Storage

Remwe Node (and Subtree) From Secondary Storage C

Secondary Storage in the Same Manner Ranges are Identified

I

mation for each Label in the Sub- tree on Secondary St.orage from the External Dictionary to the Internal Dictionary (the use-

Copy Subtree to . Primary Storage

Page 126: TAXL-A simple Hierarchical Data Structure Manipulation ...

w

For Each Node in .Range:

Print Latels at the Node

Recursive"ty, Visit the Sons

Get Range 9 Print Number d Nodes in Range

Set Instruction Set Instruction Counter to Counter to Sequence Value of Number - number of first .

Command in Command Buffer

v Set Run Flag

I

I

Reset Run Fl