C:/Users/Dennis/src/lang/russell.orig/src/pass1/applinfer/mkappl.c

Go to the documentation of this file.
00001 # include "parm.h"
00002 
00003 # include "stree/ststructs.mh"
00004 
00005 # include "stree/Array.h"
00006 
00007 # ifdef BAD
00008     extern boolean BADflag;
00009 # endif
00010 
00011 /*
00012  * mkappl(l)
00013  *
00014  * input: A denotation in the form of a list of primaries.
00015  *
00016  * output: The denotation in the form of a tree of applications
00017  *         and conditionals. A heuristic (described elsewhere)
00018  *         is applied to decide how to parse the list if args
00019  *         are not fully bracketed.
00020  *         The input list l is destroyed and replaced by the
00021  *         empty list.
00022  */
00023 
00024 NODE * mkappl(l)
00025 NODE * l;
00026 {   Array *  array;      /* array of pointers to primaries */
00027     NODE *  tree,       /* the result tree */
00028          *  sl;         /* a singleton list containing the tree */
00029 
00030 #   ifdef DEBUG
00031         if ( !is_list(l) || is_empty(l) ) {
00032             dbgmsg("\nmkappl: arg not a list: %o\n", l);
00033             abort();
00034         }
00035 #   endif
00036 
00037 
00038     /* Convert l into an array. */
00039         array = list_to_array(l);
00040 
00041     /* Construct a singleton list containing (hopefully) the tree of
00042        applications and conditionals.                               */
00043         sl = mkappl2( array->a_body, &array->a_body[array->a_size-1] );
00044         lock(sl);
00045 
00046     /* Return the tree, freeing the array and the list. */
00047         if (is_empty(sl)) {
00048             yyperror("Empty argument list without operator");
00049             tree = lock(sl);
00050         } else {
00051             tree = lock( first(sl) );
00052         }
00053 
00054 #       ifdef BAD
00055             if (BADflag)
00056                 flcheck(0,0);
00057             else
00058                 flcheck(0,1);
00059 #       endif
00060 
00061         free_array(array);  vfree( unlock(sl) );
00062 
00063 #       ifdef BAD
00064             if (BADflag)
00065                 flcheck(0,0);
00066             else
00067                 flcheck(0,1);
00068 #       endif
00069 
00070         return ( unlock(tree) );
00071 
00072 }

Generated on Fri Jan 25 10:39:46 2008 for russell by  doxygen 1.5.4