version 1.18, 2013/11/06 06:23:23 |
version 1.22, 2021/03/12 06:45:55 |
|
|
/* $OpenXM: OpenXM/src/k097/d.c,v 1.17 2006/05/06 09:40:26 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/k097/d.c,v 1.21 2020/10/07 23:53:25 takayama Exp $ */ |
/* simple.c, 1996, 1/1 --- 1/5 */ |
/* simple.c, 1996, 1/1 --- 1/5 */ |
#include <stdio.h> |
#include <stdio.h> |
#include <ctype.h> |
#include <ctype.h> |
#include <setjmp.h> |
#include <setjmp.h> |
#include <stdlib.h> |
#include <stdlib.h> |
|
#include <unistd.h> |
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/stat.h> |
#include <sys/stat.h> |
#include "d.h" |
#include "d.h" |
Line 49 int Interactive = 1; |
|
Line 50 int Interactive = 1; |
|
static int isThereStdin(); |
static int isThereStdin(); |
#define MARK_CHAR 3 |
#define MARK_CHAR 3 |
|
|
main2(int argc, char *argv[]) { |
void main2(int argc, char *argv[]) { |
FILE *f; |
FILE *f; |
FILE *outf; |
FILE *outf; |
char name[1024]; |
char name[1024]; |
Line 79 main2(int argc, char *argv[]) { |
|
Line 80 main2(int argc, char *argv[]) { |
|
} |
} |
} |
} |
|
|
repl(FILE *inFile,FILE *outFile) { |
void repl(FILE *inFile,FILE *outFile) { |
int c; |
int c; |
int t; |
int t; |
Inop = newObject_d(); |
Inop = newObject_d(); |
Line 160 repl(FILE *inFile,FILE *outFile) { |
|
Line 161 repl(FILE *inFile,FILE *outFile) { |
|
case INCREMENT: printf("\nKClex returns --- ++."); break; |
case INCREMENT: printf("\nKClex returns --- ++."); break; |
case DECREMENT: printf("\nKClex returns --- --."); break; |
case DECREMENT: printf("\nKClex returns --- --."); break; |
case MEMBER: printf("\nKClex returns --- ->."); break; |
case MEMBER: printf("\nKClex returns --- ->."); break; |
case RESIDUEPUT: printf("\nKClex returns --- %=."); break; |
case RESIDUEPUT: printf("\nKClex returns --- %%=."); break; |
case NEGATEPUT: printf("\nKClex returns --- ^=."); break; |
case NEGATEPUT: printf("\nKClex returns --- ^=."); break; |
case MULTPUT: printf("\nKClex returns --- *=."); break; |
case MULTPUT: printf("\nKClex returns --- *=."); break; |
|
|
|
|
/*if (Mydebug) printf("identifier string=[%s]",name);*/ |
/*if (Mydebug) printf("identifier string=[%s]",name);*/ |
if (isdigit(name[0])) { |
if (isdigit(name[0])) { |
/**************************** |
/**************************** |
/**case : machine integer. |
**case : machine integer. |
KClval = newObject_d(); |
KClval = newObject_d(); |
KClval->tag = Sinteger; |
KClval->tag = Sinteger; |
sscanf(name,"%d",&(KClval->lc.ival));*************/ |
sscanf(name,"%d",&(KClval->lc.ival));*************/ |
|
|
break; |
break; |
} /* else : Identifier case.*/ |
} /* else : Identifier case.*/ |
|
|
if (d = isReserved(name)) { |
if ((d = isReserved(name))) { |
if (Replace) printf0(name); |
if (Replace) printf0(name); |
return(d); |
return(d); |
} else { |
} else { |
|
|
|
|
} |
} |
|
|
KCerror(char *s) /* You need this function. Otherwise, you get core. */ |
int KCerror(char *s) /* You need this function. Otherwise, you get core. */ |
{ |
{ |
K00recoverFromError(); |
K00recoverFromError(); |
fprintf(stderr,"\nSyntax Error in the line %d:%s\n",Linenumber,s); |
fprintf(stderr,"\nSyntax Error in the line %d:%s\n",Linenumber,s); |
Line 610 KCerror(char *s) /* You need this function. Otherwis |
|
Line 611 KCerror(char *s) /* You need this function. Otherwis |
|
exit(1); |
exit(1); |
} |
} |
|
|
readcomment() { |
int readcomment() { |
int c; |
int c; |
while (1) { |
while (1) { |
c = fsgetc(Inop); |
c = fsgetc(Inop); |
Line 674 char *readstring() { |
|
Line 675 char *readstring() { |
|
} |
} |
|
|
|
|
readchar() { |
int readchar() { |
int c; |
int c; |
if (Replace) putchar0('\''); |
if (Replace) putchar0('\''); |
c = fsgetc(Inop); /* 'c.' '\.c' */ |
c = fsgetc(Inop); /* 'c.' '\.c' */ |
|
|
return(c); |
return(c); |
} |
} |
|
|
putchar0(c) |
void putchar0(c) |
int c; |
int c; |
{ |
{ |
if (c > 0) fputc(c,outfile); |
if (c > 0) fputc(c,outfile); |
} |
} |
|
|
printf0(s) |
void printf0(s) |
char *s; |
char *s; |
{ |
{ |
int i = 0; |
int i = 0; |
while (s[i] != '\0') putchar0(s[i++]); |
while (s[i] != '\0') putchar0(s[i++]); |
} |
} |
|
|
printf1(s) |
void printf1(s) |
char *s; |
char *s; |
{ |
{ |
int i = 0; |
int i = 0; |
|
|
while (s[i] != '\0') putchar0(s[i++]); |
while (s[i] != '\0') putchar0(s[i++]); |
} |
} |
|
|
isReserved(s) |
int isReserved(s) |
char *s; |
char *s; |
{ |
{ |
char *r[] = {"auto","break","case","char","const","continue", |
char *r[] = {"auto","break","case","char","const","continue", |
|
|
|
|
} |
} |
|
|
shouldReplace(s) |
int shouldReplace(s) |
char *s; |
char *s; |
{ |
{ |
char *r[] = {"dummy"}; |
char *r[] = {"dummy"}; |
Line 939 int fsgetc(objectp op) { |
|
Line 940 int fsgetc(objectp op) { |
|
|
|
int fsungetc(int c,objectp op) { |
int fsungetc(int c,objectp op) { |
fprintf(stderr,"Sorry. fsungetc has not yet implemented.\n"); |
fprintf(stderr,"Sorry. fsungetc has not yet implemented.\n"); |
|
return -1; |
} |
} |
|
|
void clearInop() { |
void clearInop() { |
Line 1021 objectp checkIfTheFileExists(objectp op) { |
|
Line 1023 objectp checkIfTheFileExists(objectp op) { |
|
} |
} |
} |
} |
} |
} |
close(fp); |
fclose(fp); |
op = newObject_d(); |
op = newObject_d(); |
op->tag = Sstring; |
op->tag = Sstring; |
s = (char *)GC_malloc(sizeof(char)*(strlen(fname)+1)); |
s = (char *)GC_malloc(sizeof(char)*(strlen(fname)+1)); |
Line 1089 void loadFileWithCpp(objectp op) |
|
Line 1091 void loadFileWithCpp(objectp op) |
|
} |
} |
/* printf("%s\n",outfile); */ |
/* printf("%s\n",outfile); */ |
if ((char *)strstr(cpp,"/asir/bin/cpp.exe") == NULL) { |
if ((char *)strstr(cpp,"/asir/bin/cpp.exe") == NULL) { |
#if defined(__APPLE_CC__) |
#if defined(__clang__) || defined(__FreeBSD__) |
|
/* cpp of the FreeBSD is the cpp of the clang, but gcc is selected by configure. |
|
echo | gcc -dM -E - |
|
*/ |
sprintf(tmpName,"cpp -E -P %s | sed -e 's/^#.*//g' >%s",sfile,outfile); |
sprintf(tmpName,"cpp -E -P %s | sed -e 's/^#.*//g' >%s",sfile,outfile); |
#else |
#else |
argv[0] = cpp; |
argv[0] = cpp; |
Line 1106 void loadFileWithCpp(objectp op) |
|
Line 1111 void loadFileWithCpp(objectp op) |
|
argv[3] = cygwinPathToWinPath(outfile); |
argv[3] = cygwinPathToWinPath(outfile); |
argv[4] = NULL; |
argv[4] = NULL; |
} |
} |
#if defined(__APPLE_CC__) |
#if defined(__clang__) || defined(__FreeBSD__) |
system(tmpName); |
system(tmpName); |
#else |
#else |
n=oxForkExecBlocked(argv); |
n=oxForkExecBlocked(argv); |
Line 1134 void showStringBuff(objectp op) |
|
Line 1139 void showStringBuff(objectp op) |
|
if (K00_verbose) { |
if (K00_verbose) { |
fprintf(stderr,"stringBuff ptr = %d, ",ptr); |
fprintf(stderr,"stringBuff ptr = %d, ",ptr); |
fprintf(stderr,"sb[ptr] = %x,%d",(sb->str)[ptr],(sb->str)[ptr]); |
fprintf(stderr,"sb[ptr] = %x,%d",(sb->str)[ptr],(sb->str)[ptr]); |
fprintf(stderr,"Saki(yomi) = %x \n",Saki,Saki); |
fprintf(stderr,"Saki(yomi) = %x,%d \n",Saki,Saki); |
} |
} |
if (ptr == 0 && Saki == -1) { |
if (ptr == 0 && Saki == -1) { |
fprintf(stderr," ; was expected.\n"); |
fprintf(stderr," ; was expected.\n"); |