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