home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume10 / ifp / part06 / interp / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-07-06  |  4.6 KB  |  181 lines

  1.  
  2. /****** main.c ********************************************************/
  3. /**                                                                  **/
  4. /**                    University of Illinois                        **/
  5. /**                                                                  **/
  6. /**                Department of Computer Science                    **/
  7. /**                                                                  **/
  8. /**   Tool: IFP                         Version: 0.5                 **/
  9. /**                                                                  **/
  10. /**   Author:  Arch D. Robison          Date:   May 1, 1985          **/
  11. /**                                                                  **/
  12. /**   Revised by: Arch D. Robison       Date:  Jan 20, 1987          **/
  13. /**                                                                  **/
  14. /**   Principal Investigators: Prof. R. H. Campbell                  **/
  15. /**                            Prof. W. J. Kubitz                    **/
  16. /**                                                                  **/
  17. /**                                                                  **/
  18. /**------------------------------------------------------------------**/
  19. /**   (C) Copyright 1987  University of Illinois Board of Trustees   **/
  20. /**                       All Rights Reserved.                       **/
  21. /**********************************************************************/
  22.  
  23. #include <stdio.h>
  24. #include "struct.h"
  25. #include "node.h"
  26. #include "umax.h"
  27. #include "cache.h"
  28. #include "stats.h"
  29.  
  30. #if OPSYS!=CTSS
  31. #endif
  32.  
  33. static char Version[] = "\nIllinois FP 0.5";
  34. static char Author [] = " Arch D. Robison";
  35. static char Date   [] = " Dec 5, 1986\n";
  36.  
  37. #if OPSYS==UNIX
  38. #define OPSYSTEM "UNIX"
  39. #endif
  40. #if OPSYS==MSDOS
  41. #define OPSYSTEM "MS-DOS"
  42. #endif
  43. #if OPSYS==CTSS
  44. #define OPSYSTEM "CTSS"
  45. #endif
  46.  
  47. boolean LongPathFlag = 0;
  48.  
  49. #ifdef COMPILE
  50. boolean CompilerFlag = 0;       /* Enable compiler if set */
  51. boolean RuleFlag = 0;           /* Display rules if set   */
  52. #endif
  53.  
  54. private void Init ()
  55.    {
  56.       extern void D_arith (), D_form (), D_pred (), D_misc (), D_seq (), 
  57.           D_ss (), D_subseq (), D_string (), D_cray (), D_vector ();
  58.       extern void InitString (), InitNode (), InitFile ();
  59.       extern char RootPath[];                  /* from file.c */
  60. #if OPSYS==MSDOS
  61.       char CWD [64];
  62. #endif
  63. #if OPSYS==UNIX
  64.       extern void EnvGet ();
  65. #endif    
  66.       if (Debug & DebugInit) printf ("enter Init\n");
  67.  
  68.       InitString ();
  69. #if OPSYS==MSDOS
  70.       CWDGet (CWD,MAXPATH);
  71. #endif
  72. #if OPSYS==UNIX
  73.       EnvGet ("IFProot",RootPath,MAXPATH);      /* Check for RootPath */
  74. #endif 
  75. #if ECACHE
  76.       InitCache ();
  77. #endif
  78.  
  79.       InitNode ();
  80.       D_arith ();
  81.       D_form ();
  82.       D_pred ();
  83.       D_seq ();
  84.       D_subseq ();
  85.       D_misc ();
  86.       D_ss ();
  87.       D_string ();
  88. #if OPSYS==MSDOS
  89.       InitFile (CWD);
  90. #endif
  91. #if OPSYS==UNIX || OPSYS==CTSS
  92.       InitFile ();
  93. #endif
  94. #ifdef COMPILE
  95.       if (CompilerFlag) {
  96.      extern void InitSymTab (), InitCompiler ();
  97.      InitSymTab ();
  98.      InitCompiler ();
  99.       }
  100. #endif
  101. #ifdef GRAPHICS
  102.       InitDraw (); /* for CS9000 graphics only */
  103. #endif
  104. #if STATS
  105.       printf (" (stats)");
  106. #endif
  107.       if (Debug & DebugInit) printf ("exit Init\n");
  108.    }
  109.  
  110. extern void UserLoop ();
  111.  
  112. /*
  113.  * GetOptions
  114.  *
  115.  * Process command line options.
  116.  *
  117.  * Input
  118.  *     argv = command line arguments
  119.  *    argc = argument count
  120.  */
  121. private void GetOptions (argc,argv)
  122.    int argc;
  123.    char *argv[];
  124.    {
  125.       int k;
  126.       char *P;
  127.  
  128.       for (k=1; k<argc; k++) 
  129.      if (*(P=argv[k]) == '-') 
  130.         while (*P && *++P)
  131.            switch (*P) {
  132. #ifdef COMPILE
  133.           case 'c': CompilerFlag = 1; break;
  134.           case 'r': RuleFlag = 1; break;
  135. #endif 
  136. #if DEBUG
  137.           case 'd': 
  138.              while (*++P) {
  139.                 extern char *index();
  140.             static char Opt[] = DebugOpt;
  141.                 char *t = index (Opt,*P);
  142.             if (t != NULL) Debug |= 1 << (t-Opt);
  143.             else printf ("[unknown option = -d%c] ",*P);
  144.              }
  145.              break; 
  146. #endif /* DEBUG */
  147. #if ECACHE
  148.           case 'e':
  149.              while (*++P)
  150.             if (*P >= '0' && *P <= '2')
  151.                Cache[*P-'0'].Enable = 1;
  152.             else
  153.                printf ("[unknown -e option = %c] ",*P);
  154.              break;
  155. #endif /* ECACHE */
  156.           case 'l': LongPathFlag = 1; break;
  157.           default: 
  158.              printf ("[unknown option = %c] ",*P);
  159.              P = "";
  160.              break;
  161.            }
  162.    }
  163.  
  164. main (argc, argv)
  165.    int argc;
  166.    char *argv[];
  167.    {
  168.       printf ("%s: (%s)",Version,OPSYSTEM);
  169.       (void) fflush (stdout);
  170.       GetOptions (argc,argv);
  171.       Init ();
  172.       printf ("\n\n");
  173.       UserLoop ();
  174.       Terminate();
  175.       if (Debug & DebugInit) printf ("normal exit\n");
  176.       exit (0);
  177.    }
  178.  
  179. /************************** end of main.c **************************/
  180.  
  181.