Index of /~lloyd/tildeProgLang/C/Tree

      Name                    Last modified       Size  Description

[DIR] Parent Directory 30-Oct-2007 11:47 - [   ] BFirst.c 14-Feb-2006 14:22 1k [   ] Infix.c 14-Feb-2006 14:22 1k [   ] Insert.c 14-Feb-2006 14:22 1k [   ] Ops.c 14-Feb-2006 14:22 1k [   ] Parser.c 14-Feb-2006 14:22 3k [   ] Parser.h 14-Feb-2006 14:22 1k [   ] Postfix.c 14-Feb-2006 14:22 1k [   ] Prefix.c 14-Feb-2006 14:22 1k [   ] Queue.h 14-Feb-2006 14:22 1k [   ] QueueElement.h 14-Feb-2006 14:22 1k [   ] QueueOps.c 14-Feb-2006 14:22 1k [   ] Tree.h 14-Feb-2006 14:22 1k [   ] TreeElement.h 14-Feb-2006 14:22 1k [   ] Write.c 14-Feb-2006 14:22 1k [   ] driverParser.c 14-Feb-2006 14:22 1k [   ] driverSortTree 25-Jan-2000 11:22 1k [DIR] z/ 06-Mar-2006 09:37 -


[C] [A+DS] [Tree]   [Parsing] in [Java] [SML]

Compilation

An easy way to compile and run: Copy all `.c' and `.h' files into a clean Unix/Linux directory (folder). Compile by gcc *.c     Then run by ./a.out

Procedure Formal Parameters

Some of the procedures in this directory have procedure formal parameters, i.e. parameters that are themselves procedures such as process below:

   void infix(Tree T, void process(TreeElementType))
   /* NB. process is a procedure formal parameter. */
    { if( T != NULL )
       { infix( T->left, process );
         process(T->elt);
         infix( T->right, process );
       }
    }/*infix*/
   /* Infix Tree Traversal. */

infix traverses a Tree in infix order and carries out some process operation on each Tree Element. A process operation must be provided as a procedure actual parameter when infix is called, just as some Tree actual parameter must be provided for the Tree formal parameter T. The actual parameters are substituted for the formal parameters when infix is called. e.g.

   void PrintElt(TreeElementType e) { printf("%s ", e); }

    ...

   infix(someTree, PrintElt);      /* call infix */
   /* PrintElt is the procedure actual parameter */

infix can be called with many different actual parameters. Procedure parameters are implemented, by the compiler, as pointers to the code of routines.

Procedure formal parameters are particularly useful in the parser.

© L.Allison, 1999, 2000, 2003, www.csse.monash.edu.au/~lloyd/tildeProgLang/C/Tree/