\documentstyle[11pt,lingmacros,tree-dvips,trees]{article}
\textheight=9in
\textwidth=6.5in
\oddsidemargin=0in
\evensidemargin=0in
\topmargin=-.5in

\begin{document}
\begin{center}
{\large\bf Avery Andrews'}\\
\medskip
{\Large\bf The Trees Preprocessor}
\end{center}
\medskip

Consider the tree shown in \ex{1} drawn from Newmeyer (1986) following GKPS:

\begin{example}
\hspace*{-1.8em}\small
\tree{\ntnode{Za}{S},
  {\ntnode{Zb}{NP},
    {\tnode{Zc}{that book}}},
  {\ntnode{Zd}{{S/NP}},
    {\ntnode{Ze}{NP},
      {\tnode{Zf}{I}}},
    {\ntnode{Zg}{{VP/NP}},
      {\ntnode{Zh}{V},
        {\tnode{Zi}{want}}},
      {\ntnode{Zj}{{VP/NP}},
        {\tnode{Zk}{to}},
        {\ntnode{Zl}{{VP/NP}},
          {\ntnode{Zm}{V},
            {\tnode{Zn}{ask}}},
          {\ntnode{Zo}{NP},
            {\tnode{Zp}{Mary}}},
          {\ntnode{Zq}{{VP/NP}},
            {\tnode{Zr}{to}},
            {\ntnode{Zs}{{VP/NP}},
              {\ntnode{Zt}{V},
                {\tnode{Zu}{tell}}},
              {\ntnode{Zv}{NP},
                {\tnode{Zw}{Tom}}},
              {\ntnode{Zx}{{VP/NP}},
                {\tnode{Zy}{to}},
                {\ntnode{Zz}{{VP/NP}},
                  {\ntnode{Zab}{V},
                    {\tnode{Zbb}{read}}},
                  {\ntnode{Zcb}{{NP/NP}},
                    {\tnode{Zdb}{e}}}}}}}}}}}}%
\nodeconnect{Za}{Zb}%
\nodeconnect{Za}{Zd}%
\nodetriangle{Zb}{Zc}%
\nodeconnect{Zd}{Ze}%
\nodeconnect{Zd}{Zg}%
\nodeconnect{Ze}{Zf}%
\nodeconnect{Zg}{Zh}%
\nodeconnect{Zg}{Zj}%
\nodeconnect{Zh}{Zi}%
\nodeconnect{Zj}{Zk}%
\nodeconnect{Zj}{Zl}%
\nodeconnect{Zl}{Zm}%
\nodeconnect{Zl}{Zo}%
\nodeconnect{Zl}{Zq}%
\nodeconnect{Zm}{Zn}%
\nodeconnect{Zo}{Zp}%
\nodeconnect{Zq}{Zr}%
\nodeconnect{Zq}{Zs}%
\nodeconnect{Zs}{Zt}%
\nodeconnect{Zs}{Zv}%
\nodeconnect{Zs}{Zx}%
\nodeconnect{Zt}{Zu}%
\nodeconnect{Zv}{Zw}%
\nodeconnect{Zx}{Zy}%
\nodeconnect{Zx}{Zz}%
\nodeconnect{Zz}{Zab}%
\nodeconnect{Zz}{Zcb}%
\nodeconnect{Zab}{Zbb}%
\nodeconnect{Zcb}{Zdb}%
\end{example}
This would require some drama to do by hand, but the {\sf trees'} system
makes it reasonably easy.

The system consists of three components:  a preprocessor that
converts a simple tree format into \TeX\ input; a \TeX\ macro file that
lays out the nodes for trees, and Emma Pease's tree macro package that
interfaces to Postscript and draws lines, and assorted other fancier sorts
of graphics.

\section{The trees preprocessor}
\subsection{Usage}

If you give a file-name argument {\tt trees test}, the input will
be read from `test.txp', and written to `test{\_}tx2.tex', the latter
being what you then submit to {\TeX} (the clumsy and complicated
name is to make it easy to clean up directories without accidentally
deleting source files).  Errors go to `test.err'.  The resulting
dvi file will be `test{\_}tx2.dvi': the nuisance of specifying clumy
names can be reduced by putting the parts of papers requiring
preprocessing into include files.

Alternatively, with no filename argument,
the input is read from stdin, output written to stdout, errors
written to stderr.

A sample input file is test.tex

A tree begins with \verb+.[+, ends with \verb+.]+, and are preprocessed for
joint use with `tree-dvips.sty' (node boxing \& line drawing) and `trees.sty'
(tree layout).

Nesting is indicated by increasing depth of embedding, sisters
must be indented equally, i.e.:
\begin{verbatim}
 .[
 S
    NP
      John
    VP
      V
        bit
      NP
        Fido
 .]
 \end{verbatim}
If a node is to be connected to its mother by a triangle, it
is followed by the flag \verb+|tri+.  If it is to be given a special
tag (for boxing, or whatever), the flag \verb+|tag fred+ (or whatever)
is supplied.


\section{Trees}

1.  Purpose.
Trees is a preprocessor designed to work together with my `trees.sty'
(La)Tex macro package \& Emma Pease's `tree-dvips.sty' package
to help with
tree-formatting.  It probably doesn't do anything that couldn't actually
be done entirely in TeX, but for the moment I leave to others to spend
their lives figuring out how.

2.  Basic Operation.
The file needs to invoke trees.sty \& tree-dvips.sty, e.g., in LaTex, it
might start out:
\begin{verbatim}
  \documentstyle[tree-dvips,trees]{article}
\end{verbatim}
(or you could have \verb+\input{tree-dvips.sty}\input{trees.sty}+ in the text).

The signal for `trees' to kick into action is a line beginning with
`.['.  The tree is then presented as an indented list, with a first
daughter appearing (directly) after and more deeply embedded than its
mother, and subsequent sisters indented equally to the first. The tree
closes with `.]' (at the beginning of the line).

E.g.:

(1)
\begin{verbatim}
 .[
 S
   NP
      Det
         a
      Nom
         A
           savage
         Nom
          N
            puppy
   VP
     V
        destroyed
     NP
        Det
         the
        Nom
           shoe
 .]
\end{verbatim}
What comes out of the preprocessor is input to be handled by
`trees.sty' (which does tree layout) and `tree-dvips.sty' (which does the
line-drawing).

So from (1) we get (2):

(2)
\begin{verbatim}
\tree{\ntnode{Za}{S},
  {\ntnode{Zb}{NP},
    {\ntnode{Zc}{Det},
      {\tnode{Zd}{a}}
    },
    {\ntnode{Ze}{Nom},
      {\ntnode{Zf}{A},
        {\tnode{Zg}{savage}}
      },
      {\ntnode{Zh}{Nom},
        {\ntnode{Zi}{N},
          {\tnode{Zj}{puppy}}
        }
      }
    }
  },
  {\ntnode{Zk}{VP},
    {\ntnode{Zl}{V},
      {\tnode{Zm}{destroyed}}
    },
    {\ntnode{Zn}{NP},
      {\ntnode{Zo}{Det},
        {\tnode{Zp}{the}}
      },
      {\ntnode{Zq}{Nom},
        {\tnode{Zr}{shoe}}
      }
    }
  }
}
\nodeconnect{Za}{Zb}
\nodeconnect{Za}{Zk}
\nodeconnect{Zb}{Zc}
\nodeconnect{Zb}{Ze}
\nodeconnect{Zc}{Zd}
\nodeconnect{Ze}{Zf}
\nodeconnect{Ze}{Zh}
\nodeconnect{Zf}{Zg}
\nodeconnect{Zh}{Zi}
\nodeconnect{Zi}{Zj}
\nodeconnect{Zk}{Zl}
\nodeconnect{Zk}{Zn}
\nodeconnect{Zl}{Zm}
\nodeconnect{Zn}{Zo}
\nodeconnect{Zn}{Zq}
\nodeconnect{Zo}{Zp}
\nodeconnect{Zq}{Zr}
\end{verbatim}

The preprocessor has converted the visually convenient indented list notation
into appropriate TeX grouping for the \tree macro (defined in trees.sty), and
has put the node labels into `\ntnode' (nonterminal) and `tnode' (terminal
commands), which feed the \node command (in `tree-dvips.sty') as discussed
briefly below.  Each node has also been assigned a tag starting with
`Z', and linedrawing commands (`tree-dvips.sty') issued as appropriate.


3.  Options.
Options are separated from the node label by a vertical bar (`$\|$').  There
are currently two of them.  The `tri' option connecs the node to its mother
with a triangle instead of a line.  And the `tag TAG' option, where TAG
is any alphabetic string, sets TAG as the tag of the node.  Both of these
are illustrated in:

(3)
\begin{verbatim}
 .[
 S
   NP
      the puppy|tri
   VP|tag vp
      barked
 .]
 \nodecircle{vp}
\end{verbatim}
Putting your own label on the VP node makes it easy to use tree-dvips.sty
commands on it freely.

Two additional useful options are handled directly by the
{\sf trees.sty} definitions.  First, one sometimes wants to specify the
space between the mother and daughters (if the tree is rather wide,
for example, the default spacing at the top might be too small).
This can be done by putting a command such as \verb+\daughterskip{4ex}+
somewhere in the mother node, e.g.:

(4)
\begin{verbatim}
 .[
 S\daughtergap{4ex}
   NP
     the annoying child|tri
   VP
     ran away from the crazed puppy|tri
 .]
\end{verbatim}
It is also possible to specify the distance between a node and its
previous sister with a command such as \verb+\sistergap{-2em}+.  This can
be especially useful in packing `wide trees' that wouldn't otherwise
fit.

The default spacings for sisters \& daughters can also be altered,
as discussed in trees.sty.

4. \verb+\ntnode & \tnode.+
The \verb+\ntnode+ and \verb+\tnode+ commands do some moderately
complicated things 
that are basically adapted to make it easier to write LFG papers.  Both
commands operate on node specifications where a bunch of annotations
are specified as sitting on top of the main node label.  E.g.:
\begin{verbatim}
  \ntnode{a}{(\uparrow SUBJ)=\downarrow/NP}
\end{verbatim}
Puts the annotation on top of the node-label, and automatically sets
it in math-mode.. The levels are separated by a slash, and there can be as
many as you like.  The difference between \verb+\ntnode+ and \verb+\tnode+
is that the 
latter sets the last level in italics, as is the norm for terminals.

(5)
\begin{verbatim}
 .[
 S
   (\uparrow SUBJ)=\downarrow/NP
     \uparrow = \downarrow/N
       Mary
   \uparrow = \downarrow/VP
       yelled
 .]
\end{verbatim}
For information on altering the operations of \verb+\ntnode & \tnode+, see
trees.sty.  One could also switch off all of this stuff by redefining
them to in effect do nothing:
\begin{verbatim}
  \def\ntnode#1#2{#2}
  \def\tnode#1#2{#2}
\end{verbatim}
\subsection{Assembly}
The program has so far run under Sun cc, and Turbo C 2.
For Sun cc, the module ansi.c is required, to supply some
library functions that appear to be missing.  There are some
bits of code for the VMS/VAX C version, but the adjustments would
need to be made by hand.  A executable and source files with a
Unix makefile are provided.

\subsection{Availability}
Emma Pease's tree-dvips may be found in tree.tar.Z in /pub/TeXfiles
on csli.stanford.edu.
The preprocessor plus trees.sty may be found in pstrees.tar.Z
in /pub/TMP on csli.stanford.edu

\end{document}
