=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/Kan/parserpass0.c,v retrieving revision 1.1 retrieving revision 1.6 diff -u -p -r1.1 -r1.6 --- OpenXM/src/kan96xx/Kan/parserpass0.c 1999/10/08 02:12:02 1.1 +++ OpenXM/src/kan96xx/Kan/parserpass0.c 2020/10/06 11:33:46 1.6 @@ -1,3 +1,4 @@ +/* $OpenXM: OpenXM/src/kan96xx/Kan/parserpass0.c,v 1.5 2013/11/06 06:23:24 takayama Exp $ */ /* parserpass0.c */ /* In this preprocessor, for example, the expression x^2+y^2-4+x y; @@ -6,6 +7,8 @@ */ /* 1992/03/05 */ #include +#include +#include #include "datatype.h" #include "extern2.h" @@ -35,7 +38,7 @@ static struct tokens flush(); static int get0() -/* get a letter from String0 */ + /* get a letter from String0 */ { int c; c = String0[Strp0++]; @@ -44,9 +47,9 @@ static int get0() } else return(c); } -static put0(c) -int c; -/* put a letter on Buf0 */ +static void put0(c) + int c; + /* put a letter on Buf0 */ { char *new; int i; Buf0[Exist0++] = c; @@ -84,15 +87,15 @@ static struct tokens flush() return(r); } -static isSpace0(c) -int c; +static int isSpace0(c) + int c; { if (c <= ' ') return(1); else return(0); } static int isSymbol0(c) -int c; + int c; { if ((c == '+') || (c == '-') || @@ -107,14 +110,14 @@ int c; } static int isNumber0(c) -int c; + int c; { if ((c>='0') && (c<='9')) return(1); else return(0); } static struct tokens getoken_pass0(kind) -actionType kind; + actionType kind; { static int c; static struct tokens rnull; @@ -132,33 +135,33 @@ actionType kind; else return(rnull); } else if (isSpace0(c)) { if (Exist0) { - c = get0(); return(flush()); + c = get0(); return(flush()); }else { - while (isSpace0(c=get0())) ; + while (isSpace0(c=get0())) ; } } else if (isSymbol0(c)) { if (Exist0) return(flush()); else { - put0(c); - c = get0(); - return(flush()); + put0(c); + c = get0(); + return(flush()); } } else if (isNumber0(c)) { put0(c); c = get0(); while (isNumber0(c)) { - put0(c); - c = get0(); + put0(c); + c = get0(); } return(flush()); } else { /* identifier */ put0(c); c =get0(); while ((!isSymbol0(c)) && - (!isSpace0(c)) && - (c != EOF)) { - put0(c); - c = get0(); + (!isSpace0(c)) && + (c != EOF)) { + put0(c); + c = get0(); } return(flush()); } @@ -170,16 +173,16 @@ static char Buftmp[STRBUFMAX]; static char *Buf = Buftmp; static int Buflimit = STRBUFMAX; -static putstr(str,kind) -char str[]; /* string to be outputted */ -actionType kind; /* kind is INIT or PUT */ +static int putstr(str,kind) + char str[]; /* string to be outputted */ + actionType kind; /* kind is INIT or PUT */ { static int ptr; int i; int k; char *newbuf; if (kind == INIT) { ptr = 0; - return; + return 0; } i=0; @@ -191,23 +194,24 @@ actionType kind; /* kind is INIT or PUT */ fprintf(stderr,"Increasing Buf to %d.\n",2*Buflimit); newbuf = (char *) sGC_malloc(2*Buflimit); if (newbuf == (char *)NULL) { - fprintf(stderr,"\nNo memory in putstr() in parserpass0.c\n"); - exit(20); + fprintf(stderr,"\nNo memory in putstr() in parserpass0.c\n"); + exit(20); } for (k=0; kx[i]) == 0) { - sprintf(work,"x%d",i); - putstr(work,PUT); - i = -1; - break; /* break for */ - } - if (strcmp(ptoken.token,ringp->D[i]) == 0) { - sprintf(work,"d%d",i); - putstr(work,PUT); - i = -1; - break; /* break for */ - } + if (strcmp(ptoken.token,ringp->x[i]) == 0) { + sprintf(work,"x%d",i); + putstr(work,PUT); + i = -1; + break; /* break for */ + } + if (strcmp(ptoken.token,ringp->D[i]) == 0) { + sprintf(work,"d%d",i); + putstr(work,PUT); + i = -1; + break; /* break for */ + } } if (strlen(ptoken.token)>0 && (ptoken.token)[0] == '@') { - putstr(ptoken.token,PUT); - i = -1; + putstr(ptoken.token,PUT); + i = -1; } if (i != -1) { /* very dirty code */ - fprintf(stderr,"\n Undefined identifier %s. \n",ptoken.token); - putstr(ptoken.token,PUT); + fprintf(stderr,"\n Undefined identifier %s. \n",ptoken.token); + putstr(ptoken.token,PUT); } /* end of input translations */ }else { if (ptoken.token != (char *)NULL) { - putstr(ptoken.token,PUT); + putstr(ptoken.token,PUT); } } /* if ctoken.token is ";" then end */ @@ -286,10 +290,10 @@ struct ring *ringp; } if (((ptoken.kind == ID) || (ptoken.kind == KAZU) || (ptoken.kind == ')')) - && - ((ctoken.kind == ID) || (ctoken.kind == KAZU) || (ctoken.kind == '('))) + && + ((ctoken.kind == ID) || (ctoken.kind == KAZU) || (ctoken.kind == '('))) { - putstr(" * ",PUT); + putstr(" * ",PUT); } if (ptoken.token != (char *)NULL) sGC_free(ptoken.token); ptoken = ctoken; @@ -299,14 +303,14 @@ struct ring *ringp; /* -main() { - char str[200]; - struct ring r; - static char *x[]={"x","y","z"}; - static char *D[]={"Dx","Dy","Dz"}; - r.n = 3; - r.x = x; r.D = D; - gets(str); - printf("%s\n",str2strPass0(str,&r)); -} + main() { + char str[200]; + struct ring r; + static char *x[]={"x","y","z"}; + static char *D[]={"Dx","Dy","Dz"}; + r.n = 3; + r.x = x; r.D = D; + gets(str); + printf("%s\n",str2strPass0(str,&r)); + } */