home *** CD-ROM | disk | FTP | other *** search
/ ftptest.leeds.ac.uk / 2015.02.ftptest.leeds.ac.uk.tar / ftptest.leeds.ac.uk / bionet / CAE-GROUP / SCL-WIN3x / FED_PLUS.EXE / FEDEX.C < prev    next >
C/C++ Source or Header  |  1994-12-13  |  6KB  |  210 lines

  1. static char rcsid[] = "$Id: fedex.c,v 1.12 1994/05/11 19:50:52 libes Exp $";
  2.  
  3. /************************************************************************
  4. ** Driver for Fed-X Express parser.
  5. ************************************************************************/
  6.  
  7. /*
  8.  * This software was developed by U.S. Government employees as part of
  9.  * their official duties and is not subject to copyright.
  10.  *
  11.  * $Log: fedex.c,v $
  12.  * Revision 1.12  1994/05/11  19:50:52  libes
  13.  * numerous fixes
  14.  *
  15.  * Revision 1.11  1993/10/15  18:48:11  libes
  16.  * CADDETC certified
  17.  *
  18.  * Revision 1.9  1993/02/22  21:47:03  libes
  19.  * fixed main-hooks
  20.  *
  21.  * Revision 1.8  1993/02/16  03:22:56  libes
  22.  * improved final success/error message handling
  23.  *
  24.  * Revision 1.7  1993/01/19  22:44:17  libes
  25.  * *** empty log message ***
  26.  *
  27.  * Revision 1.5  1992/08/27  23:40:21  libes
  28.  * mucked around with version string
  29.  *
  30.  * Revision 1.4  1992/08/18  17:12:30  libes
  31.  * rm'd extraneous error messages
  32.  *
  33.  * Revision 1.3  1992/06/08  18:06:18  libes
  34.  * prettied up interface to print_objects_when_running
  35.  *
  36.  * Revision 1.2  1992/05/31  08:35:00  libes
  37.  * multiple files
  38.  *
  39.  * Revision 1.1  1992/05/28  03:53:54  libes
  40.  * Initial revision
  41.  *
  42.  * Revision 1.7  1992/05/14  10:12:23  libes
  43.  * changed default to unsorted, added B for sort
  44.  *
  45.  * Revision 1.6  1992/05/10  01:41:01  libes
  46.  * does enums and repeat properly
  47.  *
  48.  */
  49. #include <stdio.h>
  50. #include "error.h"
  51. #include "express.h"
  52. #include "resolve.h"
  53. #include <stdlib.h>
  54. #ifdef YYDEBUG
  55. extern int exp_yydebug;
  56. #endif /*YYDEBUG*/
  57.  
  58. char EXPRESSgetopt_options[256] = "Bbd:e:i:w:p:rv";
  59.  
  60. static void
  61. usage()
  62. {
  63.         fprintf(stderr,"usage: %s [-v] [-d #] [-p <object_type>] {-w|-i <warning>} express_file\n",EXPRESSprogram_name);
  64.     fprintf(stderr,"where\t-v produces a version description\n");
  65.     fprintf(stderr,"\t-d turns on debugging (\"-d 0\" describes this further\n");
  66.     fprintf(stderr,"\t-p turns on printing when processing certain objects (see below)\n");
  67.     fprintf(stderr,"\t-w warning enable\n");
  68.     fprintf(stderr,"\t-i warning ignore\n");
  69.     fprintf(stderr,"and <warning> is one of:\n");
  70.     fprintf(stderr,"\tnone\n\tall\n");
  71.     LISTdo(ERRORwarnings, opt, Error_Warning)
  72.         fprintf(stderr,"\t%s\n",opt->name);
  73.     LISTod
  74.     fprintf(stderr,"and <object_type> is one or more of:\n");
  75.     fprintf(stderr,"    e    entity\n");
  76.     fprintf(stderr,"    p    procedure\n");
  77.     fprintf(stderr,"    r    rule\n");
  78.     fprintf(stderr,"    f    function\n");
  79.     fprintf(stderr,"    t    type\n");
  80.     fprintf(stderr,"    s    schema or file\n");
  81.     fprintf(stderr,"    #    pass #\n");
  82.     fprintf(stderr,"    E    everything (all of the above)\n");
  83.     exit(2);
  84. }
  85.  
  86. int
  87. main(int argc, char** argv)
  88. {
  89.     /*extern char *optarg;
  90.     extern int optind;
  91.     extern int getopt(int, char**, char*);*/
  92.     int c;
  93.     int rc;
  94.     char *cp;
  95.     int no_warnings = 1;
  96.     int resolve = 1;
  97.     int no_need_to_work = 0;/* TRUE if we can exit gracefully without */
  98.                 /* doing any work */
  99.  
  100.     Boolean buffer_messages = false;
  101.     char *filename = 0, file[32];
  102.     Express model;
  103.  
  104.     EXPRESSprogram_name = argv[0];
  105.     ERRORusage_function = usage;
  106.  
  107.     EXPRESSinit_init();
  108.  
  109.     EXPRESSinitialize();
  110.  
  111.     if (EXPRESSinit_args) (*EXPRESSinit_args)(argc,argv);
  112.  
  113.    /* optind = 1;*/
  114.   /*  while ((c = getopt(argc,argv,EXPRESSgetopt_options)) != -1)
  115.     switch (c) {
  116.       case 'd':
  117.         ERRORdebugging = 1;
  118.         switch (atoi(optarg)) {
  119.           case 0:
  120.         fprintf(stderr, "\ndebug codes:\n");
  121.         fprintf(stderr, "  0 - this help\n");
  122.         fprintf(stderr, "  1 - basic debugging\n");
  123. #ifdef debugging
  124.         fprintf(stderr, "  4 - light malloc debugging\n");
  125.         fprintf(stderr, "  5 - heavy malloc debugging\n");
  126.         fprintf(stderr, "  6 - heavy malloc debugging while resolving\n");
  127. #endif 
  128. #ifdef YYDEBUG
  129.         fprintf(stderr, "  8 - set YYDEBUG\n");
  130. #endif         break;
  131.           case 1:    debug = 1;        break;
  132. #ifdef debugging
  133.           case 4:    malloc_debug(1);    break;
  134.           case 5:    malloc_debug(2);    break;
  135.           case 6:    malloc_debug_resolve = 1;    break;
  136. #endif 
  137. #ifdef YYDEBUG
  138.           case 8:    exp_yydebug = 1;        break;
  139. #endif         }
  140.         break;
  141.     case 'B':    buffer_messages = true;        break;
  142.     case 'b':    buffer_messages = false;    break;
  143.     case 'e':    filename = optarg;        break;
  144.     case 'r':    resolve = 0;            break;
  145.     case 'i':
  146.     case 'w':
  147.     no_warnings = 0;
  148.     ERRORset_warning(optarg,c == 'w');
  149.     break;
  150.     case 'p':
  151.     for (cp = optarg;*cp;cp++) {
  152.       if (*cp == '#') print_objects_while_running |= OBJ_PASS_BITS;
  153.       else if (*cp == 'E') print_objects_while_running = OBJ_ANYTHING_BITS;
  154.       else print_objects_while_running |= OBJget_bits(*cp);
  155.     }
  156.     break;
  157.     case 'v':
  158.     printf("%s %s\n%s\n",EXPRESSprogram_name,"V2.10.0-beta April 28, 1994",EXPRESSversion());
  159.     no_need_to_work = 1;
  160.         break;
  161.     default:
  162.     rc = 1;
  163.     if (EXPRESSgetopt) {
  164.         rc = (*EXPRESSgetopt)(c,optarg);
  165.     }
  166.     if (rc == 1) (*ERRORusage_function)();
  167.     break;
  168.     }
  169.  
  170. */    
  171.      printf("Enter the full name of the EXPRESS file: \n"); 
  172.      
  173.      gets(file);
  174.      
  175.      if(fopen(file,"r")!=NULL)
  176.      filename=file;    
  177.      else{ 
  178.      printf("File not found...Bye! \n");
  179.      return(0);
  180.      }
  181.  
  182.  
  183.     if (no_warnings) ERRORset_all_warnings(1);
  184.     ERRORbuffer_messages(buffer_messages);
  185.  
  186.     if (EXPRESSinit_parse) (*EXPRESSinit_parse)();
  187.  
  188.     model = EXPRESScreate();
  189.     EXPRESSparse(model,(FILE *)0,filename);
  190.     if (ERRORoccurred) return(EXPRESS_fail(model));
  191.  
  192. #ifdef debugging
  193.     if (malloc_debug_resolve) {
  194.         malloc_verify();
  195.         malloc_debug(2);
  196.     }
  197. #endif /*debugging*/
  198.  
  199.     if (resolve) {
  200.         EXPRESSresolve(model);
  201.         if (ERRORoccurred) return(EXPRESS_fail(model));
  202.     }
  203.  
  204.     if (EXPRESSbackend) (*EXPRESSbackend)(model);
  205.  
  206.     if (ERRORoccurred) return(EXPRESS_fail(model));
  207.  
  208.     return(EXPRESS_succeed(model));
  209. }
  210.