[BACK]Return to k2.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / k097

Annotation of OpenXM/src/k097/k2.c, Revision 1.3

1.3     ! takayama    1: /* $OpenXM: OpenXM/src/k097/k2.c,v 1.2 2000/01/17 13:57:26 takayama Exp $ */
1.1       maekawa     2: /* k2.c main program of k. */
                      3:
                      4: #define DATE "1998,12/15"
                      5: #include <stdio.h>
                      6: #include "datatype.h"
                      7: #include "stackm.h"
                      8: #include "extern.h"
                      9: #include "extern2.h"
                     10:
                     11: char *getLOAD_K_PATH();  /* from d.h */
                     12:
                     13: #ifdef CALLASIR
                     14: #include "ak0.h"
                     15: #endif
                     16:
                     17:
                     18: extern int DebugCompiler;  /* 0:   , 1: Displays sendKan[ .... ] */
                     19: extern int DebugMode;
                     20: extern int K00_verbose;
                     21:
                     22: int Startupk2 = 1;
1.3     ! takayama   23:
1.1       maekawa    24:
                     25: main(int argc,char *argv[]) {
                     26:   extern int Saki;
                     27:   extern int Interactive;
                     28:   int i;
                     29:   char *s;
                     30:   char tname[1024];
                     31:   FILE *fp;
                     32:   if (argc >= 2) {
                     33:     for (i=1; i < argc; i++) {
                     34:       if (strcmp(argv[i],"-d") == 0) {
                     35:        fprintf(stderr,"DebugCompiler = 1\n");
                     36:        DebugCompiler = 1;
                     37:       }else if (strcmp(argv[i],"-nostartup") == 0) {
                     38:        fprintf(stderr,"Do not load startup.k\n");
                     39:        Startupk2 = 0;
                     40:       }else if (strcmp(argv[i],"-v") == 0) {
                     41:        K00_verbose = 1;
                     42:       }else if (strcmp(argv[i],"-vv") == 0) {
                     43:        K00_verbose = 2;
                     44:       }else{
                     45:        fprintf(stderr,"Usage: 1: k\n");
                     46:        fprintf(stderr,"       2: k -d  (DebugCompiler=1)\n");
1.3     ! takayama   47:        fprintf(stderr,"       3: k -nostartup  (do not load startup.k)\n");
        !            48:        fprintf(stderr,"       4: k -v (verbose) or k -vv \n");
1.1       maekawa    49:        exit(1);
                     50:       }
                     51:     }
                     52:   }
                     53: #ifdef CALLASIR
                     54:   GC_init();
                     55:   KasirKanAsirInit();
                     56: #endif
                     57:   KSstart();   /********  initialize ***********/
                     58:   /* Call setjmp(EnvOfStackMachine) for error handling. cf. scanner() in
                     59:    Kan/stackmachine.c */
                     60:
                     61:   fprintf(stderr,"This is kan/k0 Version %s",DATE);
                     62:   fprintf(stderr,"\n");
1.2       takayama   63:   fprintf(stderr,"WARNING: This is an EXPERIMENTAL version\n");
1.1       maekawa    64:   if (K00_verbose == 1) {
                     65:     KSexecuteString(" /K00_verbose 1 def ");
                     66:   }else if (K00_verbose == 2) {
                     67:     KSexecuteString(" /K00_verbose 2 def ");
                     68:   }else {
                     69:     KSexecuteString(" /K00_verbose 0 def ");
                     70:   }
                     71:   execFile("var.sm1"); KSexecuteString(" strictMode ");
                     72:   execFile("incmac.sm1");
                     73:   execFile("slib.sm1");
                     74:
                     75:   printf("\n\nIn(1)=");
                     76:   s = "startup.k";
                     77:   if (Startupk2) {
                     78:     strcpy(tname,s);
                     79:     if ((fp = fopen(tname,"r")) == (FILE *) NULL) {
                     80:       strcpy(tname,getLOAD_K_PATH());
                     81:       strcat(tname,s);
                     82:       if ((fp = fopen(tname,"r")) == (FILE *) NULL) {
                     83:        strcpy(tname,LOAD_K_PATH);
                     84:        strcat(tname,s);
                     85:        if ((fp = fopen(tname,"r")) == (FILE *) NULL) {
                     86:          fprintf(stderr,"No startup file.\n");
                     87:        }
                     88:       }
                     89:     }
                     90:     if (fp != (FILE *)NULL) {
                     91:       if (K00_verbose) fprintf(stderr,"Reading startup.k... ");
                     92:       Saki = 0;
                     93:       parseAfile(fp);
                     94:       KCparse();
                     95:       if (K00_verbose) fprintf(stderr,"Done.\n");
                     96:     }
                     97:   }
                     98:
                     99:   clearInop();
                    100:   Interactive = 1;
                    101:   parseAfile(stdin);
                    102:   /*  parseAstring(" sm1(\" 1 1 10 { message } for \" ) "); It works ! */
                    103:   KCparse();
                    104:
                    105:   KSstop(); /* closing */
                    106: }
                    107:
                    108:
                    109:
                    110:
                    111:
                    112:
                    113:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>