version 1.8, 2004/03/02 09:30:48 |
version 1.12, 2004/03/03 12:27:31 |
|
|
/* $OpenXM: OpenXM/src/kxx/ox_texmacs.c,v 1.7 2004/03/02 09:10:04 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kxx/ox_texmacs.c,v 1.11 2004/03/03 09:44:39 takayama Exp $ */ |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <setjmp.h> |
#include <setjmp.h> |
Line 70 static int startEngine(int type,char *msg); |
|
Line 70 static int startEngine(int type,char *msg); |
|
*/ |
*/ |
FILE *Dfp; |
FILE *Dfp; |
|
|
main() { |
main(int argc,char *argv[]) { |
char *s; |
char *s; |
char *r; |
char *r; |
char *sys; |
char *sys; |
|
|
int vmode=1; |
int vmode=1; |
char *openxm_home; |
char *openxm_home; |
char *asir_config; |
char *asir_config; |
|
int i; |
|
|
openxm_home = (char *) getenv("OpenXM_HOME"); |
openxm_home = (char *) getenv("OpenXM_HOME"); |
asir_config = (char *) getenv("ASIR_CONFIG"); |
asir_config = (char *) getenv("ASIR_CONFIG"); |
|
|
#endif |
#endif |
|
|
/* Set consts */ |
/* Set consts */ |
sys = "asir> "; |
|
Quiet = 1; |
Quiet = 1; |
|
for (i=1; i<argc; i++) { |
|
if (strcmp(argv[i],"--sm1") == 0) { |
|
TM_Engine = SM1; |
|
}else if (strcmp(argv[i],"--asir") == 0) { |
|
TM_Engine = ASIR; |
|
}else if (strcmp(argv[i],"--k0") == 0) { |
|
TM_Engine = K0; |
|
}else{ |
|
/* printv("Unknown option\n"); */ |
|
} |
|
} |
|
|
/* Initialize kanlib (gc is also initialized) */ |
/* Initialize kanlib (gc is also initialized) */ |
KSstart(); |
KSstart(); |
|
|
else printv("Output is too large.\n"); |
else printv("Output is too large.\n"); |
}else{ |
}else{ |
KSexecuteString(" ox.engine 1 oxpops "); /* Discard the result. */ |
KSexecuteString(" ox.engine 1 oxpops "); /* Discard the result. */ |
|
/* Push and pop dummy data to wait until the computation finishes. */ |
|
KSexecuteString(" ox.engine 0 oxpushcmo ox.engine oxpopcmo "); |
|
ob = KSpop(); |
printv(""); |
printv(""); |
} |
} |
} |
} |
Line 241 static char *readString(FILE *fp, char *prolog, char * |
|
Line 255 static char *readString(FILE *fp, char *prolog, char * |
|
s[n++] = c; s[n] = 0; m++; |
s[n++] = c; s[n] = 0; m++; |
INC_BUF ; |
INC_BUF ; |
} |
} |
if (s[n-1] == '$' && TM_Engine == ASIR) TM_do_not_print = 1; |
|
else TM_do_not_print = 0; |
|
/* Check the escape sequence */ |
/* Check the escape sequence */ |
if (strcmp(&(s[start]),"!quit;") == 0) { |
if (strcmp(&(s[start]),"!quit;") == 0) { |
printv("Terminated the process ox_texmacs.\n"); |
printv("Terminated the process ox_texmacs.\n"); |
exit(0); |
exit(0); |
} |
} |
/* Check the escape sequence to change the globa env. */ |
/* Check the escape sequence to change the global env. */ |
if (strcmp(&(s[start]),"!verbatim;") == 0) { |
if (strcmp(&(s[start]),"!verbatim;") == 0) { |
printv("Output mode is changed to verbatim mode."); |
printv("Output mode is changed to verbatim mode."); |
Format=0; |
Format=0; |
Line 275 static char *readString(FILE *fp, char *prolog, char * |
|
Line 287 static char *readString(FILE *fp, char *prolog, char * |
|
return NULL; |
return NULL; |
} |
} |
|
|
|
/* Set TM_do_no_print */ |
|
if (s[n-1] == '$' && TM_Engine == ASIR) { |
|
TM_do_not_print = 1; s[n-1] = ' '; |
|
} else if (s[n-1] == ';' && TM_Engine == SM1) { |
|
TM_do_not_print = 1; s[n-1] = ' '; |
|
} else TM_do_not_print = 0; |
|
|
for (i=0; i < strlen(epilog); i++) { |
for (i=0; i < strlen(epilog); i++) { |
s[n++] = epilog[i]; s[n] = 0; |
s[n++] = epilog[i]; s[n] = 0; |
INC_BUF ; |
INC_BUF ; |
Line 319 static int startEngine(int type,char *msg) { |
|
Line 338 static int startEngine(int type,char *msg) { |
|
if (type == SM1) { |
if (type == SM1) { |
if (!TM_sm1Started) KSexecuteString(" sm1connectr "); |
if (!TM_sm1Started) KSexecuteString(" sm1connectr "); |
KSexecuteString(" /ox.engine oxsm1.ccc def "); |
KSexecuteString(" /ox.engine oxsm1.ccc def "); |
|
/* Initialize the setting of sm1. */ |
|
KSexecuteString(" oxsm1.ccc ( [(cmoLispLike) 0] extension ) oxsubmit "); |
|
KSexecuteString(" oxsm1.ccc ( ox_server_mode ) oxsubmit "); |
|
KSexecuteString(" oxsm1.ccc ( ( ) message (------------- Message from sm1 ----------------)message ) oxsubmit "); |
TM_sm1Started = 1; |
TM_sm1Started = 1; |
|
/* Welcome message. BUG. Copyright should be returned by a function. */ |
|
printf("Kan/StackMachine1 1991 April --- 2004.\n"); |
|
printf("This software may be freely distributed as is with no warranty expressed. \n"); |
|
printf("See OpenXM/Copyright/Copyright.generic\n"); |
|
printf("Info: http://www.math.kobe-u.ac.jp/KAN, kan@math.kobe-u.ac.jp.\n"); |
|
printf("0 usages to show a list of functions. \n(keyword) usages to see a short description\n"); |
printf("%s\n",msg); |
printf("%s\n",msg); |
}else if (type == K0) { |
}else if (type == K0) { |
if (!TM_k0Started) KSexecuteString(" k0connectr "); |
if (!TM_k0Started) KSexecuteString(" k0connectr "); |
Line 341 static int startEngine(int type,char *msg) { |
|
Line 370 static int startEngine(int type,char *msg) { |
|
KSexecuteString(" oxasir.ccc (if(1) { ctrl(\"message\",0); } else { ; } ;) oxsubmit oxasir.ccc oxpopcmo "); |
KSexecuteString(" oxasir.ccc (if(1) { ctrl(\"message\",0); } else { ; } ;) oxsubmit oxasir.ccc oxpopcmo "); |
/* bug; if ctrl is written with Xm_helpdir = ... without oxpopcmo, then it does |
/* bug; if ctrl is written with Xm_helpdir = ... without oxpopcmo, then it does |
not work. */ |
not work. */ |
|
KSexecuteString(" oxasir.ccc (print(\"----------- Messages from asir ------------------------------\")$ ) oxsubmit oxasir.ccc oxpopcmo "); |
} |
} |
printf("%s",DATA_END); |
printf("%s",DATA_END); |
fflush(NULL); |
fflush(NULL); |