| version 1.4, 2002/02/24 10:27:21 |
version 1.12, 2020/10/07 23:53:25 |
|
|
| /* $OpenXM: OpenXM/src/k097/ki.c,v 1.3 2001/01/28 02:40:04 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/k097/ki.c,v 1.11 2016/03/31 06:34:29 takayama Exp $ */ |
| /* ki.c ( kx interpreter ) */ |
/* ki.c ( kx interpreter ) */ |
| |
|
| #include <stdio.h> |
#include <stdio.h> |
|
|
| #include "gradedset.h" |
#include "gradedset.h" |
| #include <setjmp.h> |
#include <setjmp.h> |
| #include <signal.h> |
#include <signal.h> |
| |
#include <string.h> |
| |
#include <stdlib.h> |
| |
#include "mysig.h" |
| |
|
| |
#include "ki.h" |
| |
|
| char *getLOAD_K_PATH(); /* from d.h */ |
char *getLOAD_K_PATH(); /* from d.h */ |
| |
|
| #if defined(__CYGWIN__) |
#if defined(__CYGWIN__) |
| Line 39 int K00_verbose = 0; |
|
| Line 44 int K00_verbose = 0; |
|
| |
|
| extern int DebugMode; |
extern int DebugMode; |
| |
|
| sendKan(int p) { |
int sendKan(int p) { |
| static int n = 2; |
static int n = 2; |
| extern int Interactive; |
extern int Interactive; |
| struct object obj; |
struct object obj = OINIT; |
| int result; |
int result; |
| signal(SIGINT,SIG_IGN); /* Don't jump to ctrlC(). */ |
extern int InSendmsg2; |
| if (p == 10) {printf("In(%d)= ",n++); return;} |
result=0; |
| |
mysignal(SIGINT,SIG_IGN); /* Don't jump to ctrlC(). */ |
| |
if (p == 10) {printf("In(%d)= ",n++); return 0;} |
| if (p == 0 && DebugCompiler) printf("sendKan[%s]\n",Kbuff); |
if (p == 0 && DebugCompiler) printf("sendKan[%s]\n",Kbuff); |
| /* printf("sendKan[%s]\n",Kbuff); */ |
/* printf("sendKan[%s]\n",Kbuff); */ |
| if (strlen(Kbuff) != 0) { |
if (strlen(Kbuff) != 0) { |
| signal(SIGINT,SIG_DFL); |
mysignal(SIGINT,SIG_DFL); |
| result = KSexecuteString(Kbuff); |
result = KSexecuteString(Kbuff); |
| /* fprintf(stderr,"r=%d ",result); */ |
/* fprintf(stderr,"r=%d ",result); */ |
| signal(SIGINT,SIG_IGN); /* Reset SIGINT. Don't jump to ctrlC(). */ |
mysignal(SIGINT,SIG_IGN); /* Reset SIGINT. Don't jump to ctrlC(). */ |
| } |
} |
| /* fprintf(stderr,"r=%d ",result); */ |
/* fprintf(stderr,"r=%d ",result); */ |
| if (result == -1) { |
if (result == -1) { |
| K00recoverFromError(); |
K00recoverFromError(); InSendmsg2 = 0; |
| fprintf(stderr,"--- Engine error or interrupt : "); |
fprintf(stderr,"--- Engine error or interrupt : "); |
| if (DebugMode) { |
if (DebugMode) { |
| signal(SIGINT,SIG_DFL); |
mysignal(SIGINT,SIG_DFL); |
| KSexecuteString("db.DebugStack setstack "); |
KSexecuteString("db.DebugStack setstack "); |
| signal(SIGINT,SIG_IGN); /* Reset SIGINT. Don't jump to ctrlC(). */ |
mysignal(SIGINT,SIG_IGN); /* Reset SIGINT. Don't jump to ctrlC(). */ |
| obj = KSpop(); |
obj = KSpop(); |
| signal(SIGINT,SIG_DFL); |
mysignal(SIGINT,SIG_DFL); |
| KSexecuteString("stdstack "); |
KSexecuteString("stdstack "); |
| signal(SIGINT,SIG_IGN); /* Reset SIGINT. Don't jump to ctrlC(). */ |
mysignal(SIGINT,SIG_IGN); /* Reset SIGINT. Don't jump to ctrlC(). */ |
| if (obj.tag == Sdollar) { |
if (obj.tag == Sdollar) { |
| fprintf(stderr,"%s\n",obj.lc.str); |
fprintf(stderr,"%s\n",obj.lc.str); |
| fprintf(stderr,"\n"); |
fprintf(stderr,"\n"); |
|
|
| #define AFO |
#define AFO |
| #ifdef AFO |
#ifdef AFO |
| if (SETJMP(KCenvOfParser)) { |
if (SETJMP(KCenvOfParser)) { |
| |
InSendmsg2=0; |
| fprintf(stderr,"Error: Goto the top level.\n"); |
fprintf(stderr,"Error: Goto the top level.\n"); |
| parseAfile(stdin); |
parseAfile(stdin); |
| KCparse(); |
KCparse(); |
|
|
| if (strlen(s)+Kpt >= Ksize) { |
if (strlen(s)+Kpt >= Ksize) { |
| Ksize = Ksize*2; |
Ksize = Ksize*2; |
| t = (char *)GC_malloc(sizeof(char)*Ksize); |
t = (char *)GC_malloc(sizeof(char)*Ksize); |
| if (t == (char *)NULL) { fprintf(stderr,"No memory."); exit();} |
if (t == (char *)NULL) { fprintf(stderr,"No memory."); exit(1);} |
| strcpy(t,Kbuff); Kbuff = t; |
strcpy(t,Kbuff); Kbuff = t; |
| } |
} |
| strcpy(&(Kbuff[Kpt]),s); |
strcpy(&(Kbuff[Kpt]),s); |
| Line 125 void *mymalloc(int n) |
|
| Line 133 void *mymalloc(int n) |
|
| return((void *)GC_malloc(n)); |
return((void *)GC_malloc(n)); |
| } |
} |
| |
|
| execFile(char *s) |
int execFile(char *s) |
| { |
{ |
| FILE *fp; |
FILE *fp; |
| #define TMP_SIZE 1024 |
#define TMP_SIZE 1024 |
| Line 155 execFile(char *s) |
|
| Line 163 execFile(char *s) |
|
| fprintf(stderr,"Fatal error: Cannot open the system macro %s in %s, %s, %s nor %s.\n", |
fprintf(stderr,"Fatal error: Cannot open the system macro %s in %s, %s, %s nor %s.\n", |
| s,tname2,tname3,tname4,tname); |
s,tname2,tname3,tname4,tname); |
| exit(11); |
exit(11); |
| return; |
return 0; |
| } |
} |
| } |
} |
| } |
} |