Annotation of OpenXM/src/k097/k2.c, Revision 1.6
1.6 ! takayama 1: /* $OpenXM: OpenXM/src/k097/k2.c,v 1.5 2015/09/29 01:52:14 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:
13: char *getLOAD_K_PATH(); /* from d.h */
14:
15: #ifdef CALLASIR
16: #include "ak0.h"
17: #endif
18:
19:
20: extern int DebugCompiler; /* 0: , 1: Displays sendKan[ .... ] */
21: extern int DebugMode;
22: extern int K00_verbose;
23:
24: int Startupk2 = 1;
1.3 takayama 25:
1.1 maekawa 26:
27: main(int argc,char *argv[]) {
28: extern int Saki;
29: extern int Interactive;
30: int i;
31: char *s;
32: char tname[1024];
33: FILE *fp;
34: if (argc >= 2) {
35: for (i=1; i < argc; i++) {
36: if (strcmp(argv[i],"-d") == 0) {
37: fprintf(stderr,"DebugCompiler = 1\n");
38: DebugCompiler = 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");
1.3 takayama 49: fprintf(stderr," 3: k -nostartup (do not load startup.k)\n");
50: fprintf(stderr," 4: k -v (verbose) or k -vv \n");
1.1 maekawa 51: exit(1);
52: }
53: }
54: }
55: #ifdef CALLASIR
1.5 takayama 56: GC_INIT(); /* GC_init(); */
1.1 maekawa 57: KasirKanAsirInit();
58: #endif
59: KSstart(); /******** initialize ***********/
60: /* Call setjmp(EnvOfStackMachine) for error handling. cf. scanner() in
61: Kan/stackmachine.c */
62:
63: fprintf(stderr,"This is kan/k0 Version %s",DATE);
64: fprintf(stderr,"\n");
1.2 takayama 65: fprintf(stderr,"WARNING: This is an EXPERIMENTAL version\n");
1.1 maekawa 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:
1.4 takayama 77: printf("\n\nIn(1)= ");
1.1 maekawa 78: s = "startup.k";
79: if (Startupk2) {
80: strcpy(tname,s);
81: if ((fp = fopen(tname,"r")) == (FILE *) NULL) {
82: strcpy(tname,getLOAD_K_PATH());
83: strcat(tname,s);
84: if ((fp = fopen(tname,"r")) == (FILE *) NULL) {
85: strcpy(tname,LOAD_K_PATH);
86: strcat(tname,s);
87: if ((fp = fopen(tname,"r")) == (FILE *) NULL) {
88: fprintf(stderr,"No startup file.\n");
89: }
90: }
91: }
92: if (fp != (FILE *)NULL) {
93: if (K00_verbose) fprintf(stderr,"Reading startup.k... ");
94: Saki = 0;
95: parseAfile(fp);
96: KCparse();
97: if (K00_verbose) fprintf(stderr,"Done.\n");
98: }
99: }
100:
101: clearInop();
102: Interactive = 1;
103: parseAfile(stdin);
104: /* parseAstring(" sm1(\" 1 1 10 { message } for \" ) "); It works ! */
105: KCparse();
106:
107: KSstop(); /* closing */
108: }
109:
110:
111:
112:
113:
114:
115:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>