Annotation of OpenXM/src/k097/k2.c, Revision 1.2
1.2 ! takayama 1: /* $OpenXM$ */
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;
23: int FactorA = 0; /* sm1(" (aa) run "); does not work. */
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],"-f") == 0) {
38: fprintf(stderr,"Loading factor-a.sm1\n");
39: FactorA = 1;
40: }else if (strcmp(argv[i],"-nostartup") == 0) {
41: fprintf(stderr,"Do not load startup.k\n");
42: Startupk2 = 0;
43: }else if (strcmp(argv[i],"-v") == 0) {
44: K00_verbose = 1;
45: }else if (strcmp(argv[i],"-vv") == 0) {
46: K00_verbose = 2;
47: }else{
48: fprintf(stderr,"Usage: 1: k\n");
49: fprintf(stderr," 2: k -d (DebugCompiler=1)\n");
50: fprintf(stderr," 3: k -f (load factor-a.sm1)\n");
51: fprintf(stderr," 4: k -nostartup (do not load startup.k)\n");
52: fprintf(stderr," 5: k -v (verbose) or k -vv \n");
53: exit(1);
54: }
55: }
56: }
57: #ifdef CALLASIR
58: GC_init();
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: if (FactorA) execFile("factor-b.sm1");
79:
80: printf("\n\nIn(1)=");
81: s = "startup.k";
82: if (Startupk2) {
83: strcpy(tname,s);
84: if ((fp = fopen(tname,"r")) == (FILE *) NULL) {
85: strcpy(tname,getLOAD_K_PATH());
86: strcat(tname,s);
87: if ((fp = fopen(tname,"r")) == (FILE *) NULL) {
88: strcpy(tname,LOAD_K_PATH);
89: strcat(tname,s);
90: if ((fp = fopen(tname,"r")) == (FILE *) NULL) {
91: fprintf(stderr,"No startup file.\n");
92: }
93: }
94: }
95: if (fp != (FILE *)NULL) {
96: if (K00_verbose) fprintf(stderr,"Reading startup.k... ");
97: Saki = 0;
98: parseAfile(fp);
99: KCparse();
100: if (K00_verbose) fprintf(stderr,"Done.\n");
101: }
102: }
103:
104: clearInop();
105: Interactive = 1;
106: parseAfile(stdin);
107: /* parseAstring(" sm1(\" 1 1 10 { message } for \" ) "); It works ! */
108: KCparse();
109:
110: KSstop(); /* closing */
111: }
112:
113:
114:
115:
116:
117:
118:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>