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

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

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

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