Annotation of OpenXM_contrib2/asir2000/io/spexpr.c, Revision 1.7
1.3 noro 1: /*
2: * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
3: * All rights reserved.
4: *
5: * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
6: * non-exclusive and royalty-free license to use, copy, modify and
7: * redistribute, solely for non-commercial and non-profit purposes, the
8: * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
9: * conditions of this Agreement. For the avoidance of doubt, you acquire
10: * only a limited right to use the SOFTWARE hereunder, and FLL or any
11: * third party developer retains all rights, including but not limited to
12: * copyrights, in and to the SOFTWARE.
13: *
14: * (1) FLL does not grant you a license in any way for commercial
15: * purposes. You may use the SOFTWARE only for non-commercial and
16: * non-profit purposes only, such as academic, research and internal
17: * business use.
18: * (2) The SOFTWARE is protected by the Copyright Law of Japan and
19: * international copyright treaties. If you make copies of the SOFTWARE,
20: * with or without modification, as permitted hereunder, you shall affix
21: * to all such copies of the SOFTWARE the above copyright notice.
22: * (3) An explicit reference to this SOFTWARE and its copyright owner
23: * shall be made on your publication or presentation in any form of the
24: * results obtained by use of the SOFTWARE.
25: * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
1.4 noro 26: * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.3 noro 27: * for such modification or the source code of the modified part of the
28: * SOFTWARE.
29: *
30: * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
31: * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
32: * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
33: * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
34: * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
35: * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
36: * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
37: * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
38: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
39: * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
40: * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
41: * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
42: * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
43: * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
44: * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
45: * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
46: * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
1.7 ! noro 47: * $OpenXM: OpenXM_contrib2/asir2000/io/spexpr.c,v 1.6 2000/12/13 10:54:09 noro Exp $
1.3 noro 48: */
1.1 noro 49: #include "ca.h"
1.2 noro 50: #include "al.h"
1.1 noro 51: #include "parse.h"
52: #include "comp.h"
53: #include "base.h"
54:
55: #ifndef SPRINT
56: #define SPRINT
57: #endif
58:
1.2 noro 59: #define PRINTHAT (fortran_output?PUTS("**"):PUTS("^"))
60:
1.1 noro 61: #ifdef FPRINT
62: FILE *asir_out;
63: #define OUT asir_out
64: char DFORMAT[BUFSIZ];
1.2 noro 65: int hex_output;
66: int fortran_output;
1.1 noro 67:
68: #define TAIL
69: #define PUTS(s) fputs(s,OUT)
70: #define PRINTF fprintf
71: #define PRINTN printn
72: #define PRINTBF printbf
73: #define PRINTCPLX printcplx
1.2 noro 74: #define PRINTLM printlm
75: #define PRINTUP2 printup2
1.1 noro 76: #define PRINTV printv
77: #define PRINTEXPR printexpr
78: #define PRINTNUM printnum
79: #define PRINTP printp
80: #define PRINTR printr
81: #define PRINTLIST printlist
82: #define PRINTVECT printvect
83: #define PRINTMAT printmat
84: #define PRINTSTR printstr
85: #define PRINTCOMP printcomp
86: #define PRINTDP printdp
1.2 noro 87: #define PRINTUI printui
88: #define PRINTGF2MAT printgf2mat
89: #define PRINTGFMMAT printgfmmat
1.5 noro 90: #define PRINTBYTEARRAY printbytearray
1.2 noro 91: #define PRINTERR printerr
92: #define PRINTLF printlf
93: #define PRINTLOP printlop
94: #define PRINTFOP printfop
95: #define PRINTEOP printeop
96: #define PRINTQOP printqop
97: #define PRINTUP printup
1.1 noro 98: #endif
99:
100: #ifdef SPRINT
101: static char *buf;
102: #define OUT buf
103: extern char DFORMAT[BUFSIZ];
1.2 noro 104: extern int hex_output;
105: extern int fortran_output;
1.6 noro 106: extern int double_output;
1.1 noro 107:
108: #define TAIL while ( *OUT ) OUT++;
109: #define PUTS(s) strcat(OUT,s)
110: #define PRINTF sprintf
111: #define PRINTN sprintn
112: #define PRINTBF sprintbf
113: #define PRINTCPLX sprintcplx
1.2 noro 114: #define PRINTLM sprintlm
115: #define PRINTUP2 sprintup2
1.1 noro 116: #define PRINTV sprintv
117: #define PRINTEXPR sprintexpr
118: #define PRINTNUM sprintnum
119: #define PRINTP sprintp
120: #define PRINTR sprintr
121: #define PRINTLIST sprintlist
122: #define PRINTVECT sprintvect
123: #define PRINTMAT sprintmat
124: #define PRINTSTR sprintstr
125: #define PRINTCOMP sprintcomp
126: #define PRINTDP sprintdp
1.2 noro 127: #define PRINTUI sprintui
128: #define PRINTGF2MAT sprintgf2mat
129: #define PRINTGFMMAT sprintgfmmat
1.5 noro 130: #define PRINTBYTEARRAY sprintbytearray
1.2 noro 131: #define PRINTERR sprinterr
132: #define PRINTLF sprintlf
133: #define PRINTLOP sprintlop
134: #define PRINTFOP sprintfop
135: #define PRINTEOP sprinteop
136: #define PRINTQOP sprintqop
137: #define PRINTUP sprintup
1.1 noro 138: #endif
139:
140: void PRINTEXPR();
141: void PRINTNUM();
142: void PRINTN();
143: void PRINTV();
144: void PRINTP();
145: void PRINTR();
146: void PRINTLIST();
147: void PRINTVECT();
148: void PRINTMAT();
149: void PRINTSTR();
150: void PRINTCOMP();
151: void PRINTDP();
1.2 noro 152: void PRINTUI();
153: void PRINTGF2MAT();
154: void PRINTGFMMAT();
1.5 noro 155: void PRINTBYTEARRAY();
1.2 noro 156: void PRINTERR();
1.1 noro 157: void PRINTCPLX();
1.2 noro 158: void PRINTLM();
159: void PRINTLF();
160: void PRINTUP2();
1.1 noro 161:
162: #ifdef FPRINT
163: void output_init() {
164: OUT = stdout;
165: sprintf(DFORMAT,"%%0%dd",DLENGTH);
166: }
167:
168: int mmono(p)
169: P p;
170: {
171: if ( NUM(p) )
172: if ( compnum(CO,(Num)p,0) < 0 )
173: return ( 1 );
174: else
175: return ( 0 );
176: else if ( NEXT(DC(p)) )
177: return ( 0 );
178: else
179: return (mmono(COEF(DC(p))));
180: }
181:
182: #if PARI
1.2 noro 183: void printbf(a)
1.1 noro 184: BF a;
185: {
1.7 ! noro 186: sor(a->body,double_output ? 'f' : 'g',-1,0);
1.1 noro 187: }
188: #endif
189: #endif
190:
191: #ifdef SPRINT
192: void soutput_init(s)
193: char *s;
194: {
195: s[0] = 0; buf = s;
196: }
197:
198: #if PARI
199: void sprintbf(a)
200: BF a;
201: {
202: char *str;
203: char *GENtostr();
204:
205: str = GENtostr(a->body);
206: TAIL PRINTF(OUT,"%s",str);
207: free(str);
208: }
209: #endif
210: #endif
211:
212: void PRINTEXPR(vl,p)
213: VL vl;
214: Obj p;
215: {
216: if ( !p ) {
217: PRINTR(vl,(R)p);
218: return;
219: }
220:
221: switch ( OID(p) ) {
222: case O_N:
223: PRINTNUM((Num)p); break;
224: case O_P:
225: PRINTP(vl,(P)p); break;
226: case O_R:
227: PRINTR(vl,(R)p); break;
228: case O_LIST:
229: PRINTLIST(vl,(LIST)p); break;
230: case O_VECT:
231: PRINTVECT(vl,(VECT)p); break;
232: case O_MAT:
233: PRINTMAT(vl,(MAT)p); break;
234: case O_STR:
235: PRINTSTR((STRING)p); break;
236: case O_COMP:
237: PRINTCOMP(vl,(COMP)p); break;
238: case O_DP:
239: PRINTDP(vl,(DP)p); break;
1.2 noro 240: case O_USINT:
241: PRINTUI(vl,(USINT)p); break;
242: case O_GF2MAT:
243: PRINTGF2MAT(vl,(GF2MAT)p); break;
244: case O_ERR:
245: PRINTERR(vl,(ERR)p); break;
246: case O_MATHCAP:
247: PRINTLIST(vl,((MATHCAP)p)->body); break;
248: case O_F:
249: PRINTLF(vl,(F)p); break;
250: case O_GFMMAT:
251: PRINTGFMMAT(vl,(GFMMAT)p); break;
1.5 noro 252: case O_BYTEARRAY:
253: PRINTBYTEARRAY(vl,(BYTEARRAY)p); break;
1.1 noro 254: default:
255: break;
256: }
257: }
258:
259: void PRINTN(n)
260: N n;
261: {
262: register int i,*ptr;
263: N tn;
264:
265: if ( !n ) {
266: PUTS("0");
267: return;
268: }
1.2 noro 269: if ( hex_output ) {
270: ptr = BD(n);
271: TAIL PRINTF(OUT,"0x%x",ptr[PL(n)-1]);
272: if ( hex_output < 0 )
273: for ( i = PL(n) - 2; i >= 0; i-- ) {
274: TAIL PRINTF(OUT,"|%08x",ptr[i]);
275: }
276: else
277: for ( i = PL(n) - 2; i >= 0; i-- ) {
278: TAIL PRINTF(OUT,"%08x",ptr[i]);
279: }
280: } else {
281: ntobn(DBASE,n,&tn);
282: ptr = BD(tn);
283: TAIL PRINTF(OUT,"%d",ptr[PL(tn) - 1]);
284: for ( i = PL(tn) - 2; i >= 0; i-- ) {
285: TAIL PRINTF(OUT,DFORMAT,ptr[i]);
286: }
1.1 noro 287: }
288: }
289:
290: void PRINTNUM(q)
291: Num q;
292: {
293: if ( !q ) {
294: PUTS("0");
295: return;
296: }
297: switch ( NID(q) ) {
298: case N_Q:
299: if ( SGN((Q)q) == -1 )
300: PUTS("-");
301: PRINTN(NM((Q)q));
302: if ( !INT((Q)q) ) {
303: PUTS("/"); PRINTN(DN((Q)q));
304: }
305: break;
306: case N_R:
1.6 noro 307: TAIL PRINTF(OUT,double_output?"%f":"%g",BDY((Real)q));
1.1 noro 308: break;
309: case N_A:
310: PUTS("("); PRINTR(ALG,(R)BDY((Alg)q)); PUTS(")");
311: break;
312: #if PARI
313: case N_B:
314: PRINTBF((BF)q); break;
315: #endif
316: case N_C:
317: PRINTCPLX((C)q); break;
318: case N_M:
1.2 noro 319: TAIL PRINTF(OUT,"%d",CONT((MQ)q)); break;
320: case N_LM:
321: PRINTN(((LM)q)->body); break;
322: case N_GF2N:
323: if ( hex_output )
324: PRINTN((N)(((GF2N)q)->body));
325: else
326: PRINTUP2(((GF2N)q)->body);
327: break;
328: case N_GFPN:
329: PRINTUP((UP)(((GFPN)q)->body));
1.1 noro 330: break;
331: }
332: }
333:
334: void PRINTCPLX(a)
335: C a;
336: {
337: PUTS("(");
338: if ( a->r )
339: PRINTNUM(a->r);
340: if ( a->i ) {
341: if ( a->r && (compnum(0,a->i,0) > 0) )
342: PUTS("+");
343: PRINTNUM(a->i); PUTS("*@i");
344: }
345: PUTS(")");
346: }
347:
348: void PRINTP(vl,p)
349: VL vl;
350: P p;
351: {
352: V v;
353: DCP dc;
354:
355: if ( !p )
356: PUTS("0");
357: else if ( NUM(p) )
358: PRINTNUM((Num)p);
359: else
360: for ( dc = DC(p), v = VR(p); dc; dc = NEXT(dc) ) {
361: if ( !DEG(dc) )
362: PRINTP(vl,COEF(dc));
363: else {
364: if ( NUM(COEF(dc)) && UNIQ((Q)COEF(dc)) ) {
365: ;
366: } else if ( NUM(COEF(dc)) && MUNIQ((Q)COEF(dc)) )
367: PUTS("-");
368: else if ( NUM(COEF(dc)) || !NEXT(DC(COEF(dc)))) {
369: PRINTP(vl,COEF(dc)); PUTS("*");
370: } else {
371: PUTS("("); PRINTP(vl,COEF(dc)); PUTS(")*");
372: }
373: PRINTV(vl,v);
374: if ( cmpq(DEG(dc),ONE) ) {
1.2 noro 375: PRINTHAT;
1.1 noro 376: if ( INT(DEG(dc)) && SGN(DEG(dc))>0 )
377: PRINTNUM((Num)DEG(dc));
378: else {
379: PUTS("("); PRINTNUM((Num)DEG(dc)); PUTS(")");
380: }
381: }
382: }
383: if ( NEXT(dc) ) {
384: P t;
385:
386: t = COEF(NEXT(dc));
387: if (!DEG(NEXT(dc))) {
388: if ( NUM(t) ) {
389: if ( !mmono(t) )
390: PUTS("+");
391: } else {
392: if (!mmono(COEF(DC(t))))
393: PUTS("+");
394: }
395: } else {
396: if ( !mmono(t) )
397: PUTS("+");
398: }
399: }
400: }
401: }
402:
1.2 noro 403: int hideargs;
404:
1.1 noro 405: void PRINTV(vl,v)
406: VL vl;
407: V v;
408: {
409: PF pf;
410: PFAD ad;
411: int i;
412:
413: if ( NAME(v) )
414: PUTS(NAME(v));
415: else if ( (vid)v->attr == V_PF ) {
416: pf = ((PFINS)v->priv)->pf; ad = ((PFINS)v->priv)->ad;
417: if ( !strcmp(NAME(pf),"pow") ) {
1.2 noro 418: PUTS("("); PRINTR(vl,(R)ad[0].arg); PUTS(")"); PRINTHAT; PUTS("(");
1.1 noro 419: PRINTR(vl,(R)ad[1].arg); PUTS(")");
420: } else if ( !pf->argc ) {
421: TAIL PRINTF(OUT,"%s",NAME(pf));
422: } else {
1.2 noro 423: if ( hideargs ) {
424: for ( i = 0; i < pf->argc; i++ )
425: if ( ad[i].d )
426: break;
427: if ( i < pf->argc ) {
428: TAIL PRINTF(OUT,"%s{%d",NAME(pf),ad[0].d);
429: for ( i = 1; i < pf->argc; i++ ) {
430: TAIL PRINTF(OUT,",%d",ad[i].d);
431: }
432: PUTS("}");
433: } else {
434: TAIL PRINTF(OUT,"%s",NAME(pf));
435: }
436: } else {
437: for ( i = 0; i < pf->argc; i++ )
438: if ( ad[i].d )
439: break;
440: if ( i < pf->argc ) {
441: TAIL PRINTF(OUT,"%s{%d",NAME(pf),ad[0].d);
442: for ( i = 1; i < pf->argc; i++ ) {
443: TAIL PRINTF(OUT,",%d",ad[i].d);
444: }
445: PUTS("}(");
446: } else {
447: TAIL PRINTF(OUT,"%s(",NAME(pf));
448: }
449: PRINTR(vl,(R)ad[0].arg);
1.1 noro 450: for ( i = 1; i < pf->argc; i++ ) {
1.2 noro 451: PUTS(","); PRINTR(vl,(R)ad[i].arg);
1.1 noro 452: }
1.2 noro 453: PUTS(")");
1.1 noro 454: }
455: }
456: }
457: }
458:
459: void PRINTR(vl,a)
460: VL vl;
461: R a;
462: {
463: if ( !a )
464: PUTS("0");
465: else
466: switch (OID(a)) {
467: case O_N: case O_P:
468: PRINTP(vl,(P)a); break;
469: default:
470: PUTS("("); PRINTP(vl,NM((R)a)); PUTS(")/("); PRINTP(vl,DN((R)a)); PUTS(")");
471: break;
472: }
473: }
474:
475: void PRINTVECT(vl,vect)
476: VL vl;
477: VECT vect;
478: {
479: int i;
480: pointer *ptr;
481:
482: PUTS("[ ");
483: for ( i = 0, ptr = BDY(vect); i < vect->len; i++ ) {
484: PRINTEXPR(vl,ptr[i]); PUTS(" ");
485: }
486: PUTS("]");
487: }
488:
489: void PRINTMAT(vl,mat)
490: VL vl;
491: MAT mat;
492: {
493: int i,j,r,c;
494: pointer *ptr;
495:
496: for ( i = 0, r = mat->row, c = mat->col; i < r; i++ ) {
497: PUTS("[ ");
498: for ( j = 0, ptr = BDY(mat)[i]; j < c; j++ ) {
499: PRINTEXPR(vl,ptr[j]); PUTS(" ");
500: }
501: PUTS("]");
502: if ( i < r - 1 )
503: PUTS("\n");
504: }
505: }
506:
507: void PRINTLIST(vl,list)
508: VL vl;
509: LIST list;
510: {
511: NODE tnode;
512:
513: PUTS("[");
514: for ( tnode = (NODE)list->body; tnode; tnode = NEXT(tnode) ) {
515: PRINTEXPR(vl,tnode->body);
516: if ( NEXT(tnode) )
517: PUTS(",");
518: }
519: PUTS("]");
520: }
521:
522: void PRINTSTR(str)
523: STRING str;
524: {
525: char *p;
526:
527: for ( p = BDY(str); *p; p++ )
528: if ( *p == '"' )
529: PUTS("\"");
530: else {
531: TAIL PRINTF(OUT,"%c",*p);
532: }
533: }
534:
535: void PRINTCOMP(vl,c)
536: VL vl;
537: COMP c;
538: {
539: int n,i;
540:
541: n = getcompsize((int)c->type);
542: PUTS("{");
543: for ( i = 0; i < n; i++ ) {
544: PRINTEXPR(vl,(pointer)c->member[i]);
545: if ( i < n-1 )
546: PUTS(",");
547: }
548: PUTS("}");
549: }
550:
551: void PRINTDP(vl,d)
552: VL vl;
553: DP d;
554: {
555: int n,i;
556: MP m;
557: DL dl;
558:
559: for ( n = d->nv, m = BDY(d); m; m = NEXT(m) ) {
560: PUTS("("); PRINTEXPR(vl,(pointer)m->c); PUTS(")*<<");
561: for ( i = 0, dl = m->dl; i < n-1; i++ ) {
562: TAIL PRINTF(OUT,"%d,",dl->d[i]);
563: }
564: TAIL PRINTF(OUT,"%d",dl->d[i]);
565: PUTS(">>");
566: if ( NEXT(m) )
567: PUTS("+");
1.2 noro 568: }
569: }
570:
571: void PRINTUI(vl,u)
572: VL vl;
573: USINT u;
574: {
575: TAIL PRINTF(OUT,"%u",BDY(u));
576: }
577:
578: void PRINTGF2MAT(vl,mat)
579: VL vl;
580: GF2MAT mat;
581: {
582: int row,col,w,i,j,k,m;
583: unsigned int t;
584: unsigned int **b;
585:
586: row = mat->row;
587: col = mat->col;
588: w = (col+BSH-1)/BSH;
589: b = mat->body;
590: for ( i = 0; i < row; i++ ) {
591: for ( j = 0, m = 0; j < w; j++ ) {
592: t = b[i][j];
593: for ( k = 0; m < col && k < BSH; k++, m++ )
594: if ( t & (1<<k) )
595: PUTS("1");
596: else
597: PUTS("0");
598: }
599: PUTS("\n");
600: }
601: }
602:
603: void PRINTGFMMAT(vl,mat)
604: VL vl;
605: GFMMAT mat;
606: {
607: int row,col,i,j;
608: unsigned int t;
609: unsigned int **b;
610:
611: row = mat->row;
612: col = mat->col;
613: b = mat->body;
614: for ( i = 0; i < row; i++ ) {
615: PUTS("[");
616: for ( j = 0; j < col; j++ ) {
617: TAIL PRINTF(OUT,"%8d",b[i][j]);
618: }
619: PUTS("]\n");
620: }
1.5 noro 621: }
622:
623: void PRINTBYTEARRAY(vl,array)
624: VL vl;
625: BYTEARRAY array;
626: {
627: int len,i;
628: unsigned int t;
629: unsigned char *b;
630:
631: len = array->len;
632: b =array->body;
633: PUTS("|");
634: for ( i = 0; i < len-1; i++ ) {
635: TAIL PRINTF(OUT,"%02x ",b[i]);
636: }
637: TAIL PRINTF(OUT,"%02x",b[i]);
638: PUTS("|");
1.2 noro 639: }
640:
641: void PRINTERR(vl,e)
642: VL vl;
643: ERR e;
644: {
645: PUTS("error("); PRINTEXPR(vl,e->body); PUTS(")");
646: }
647:
648: void PRINTUP2(p)
649: UP2 p;
650: {
651: int d,i;
652:
653: if ( !p ) {
654: TAIL PRINTF(OUT,"0");
655: } else {
656: d = degup2(p);
657: TAIL PRINTF(OUT,"(");
658: if ( !d ) {
659: TAIL PRINTF(OUT,"1");
660: } else if ( d == 1 ) {
661: TAIL PRINTF(OUT,"@");
662: } else {
663: PUTS("@"); PRINTHAT; TAIL PRINTF(OUT,"%d",d);
664: }
665: for ( i = d-1; i >= 0; i-- ) {
666: if ( p->b[i/BSH] & (1<<(i%BSH)) )
667: if ( !i ) {
668: TAIL PRINTF(OUT,"+1");
669: } else if ( i == 1 ) {
670: TAIL PRINTF(OUT,"+@");
671: } else {
672: PUTS("+@"); PRINTHAT; TAIL PRINTF(OUT,"%d",i);
673: }
674: }
675: TAIL PRINTF(OUT,")");
676: }
677: }
678:
679: void PRINTLF(vl,f)
680: VL vl;
681: F f;
682: {
683: switch ( FOP(f) ) {
684: case AL_TRUE:
685: TAIL PRINTF(OUT,"@true");
686: break;
687: case AL_FALSE:
688: TAIL PRINTF(OUT,"@false");
689: break;
690:
691: case AL_OR: case AL_AND:
692: PRINTFOP(vl,f); break;
693: case AL_NOT: case AL_IMPL: case AL_REPL: case AL_EQUIV:
694: PRINTEOP(vl,f); break;
695:
696: case AL_EQUAL: case AL_NEQ: case AL_LESSP:
697: case AL_GREATERP: case AL_LEQ: case AL_GEQ:
698: PRINTLOP(vl,f); break;
699:
700: case AL_EX: case AL_ALL:
701: PRINTQOP(vl,f); break;
702: default:
703: break;
704: }
705: }
706:
707: PRINTFOP(vl,f)
708: VL vl;
709: F f;
710: {
711: char *op;
712: NODE n;
713:
714: op = FOP(f)==AL_OR?" @|| ":" @&& ";
715: n = FJARG(f);
716: PUTS("("); PRINTEXPR(vl,BDY(n)); PUTS(")");
717: for ( n = NEXT(n); n; n = NEXT(n) ) {
718: PUTS(op); PUTS("("); PRINTEXPR(vl,BDY(n)); PUTS(")");
719: }
720: }
721:
722: PRINTEOP(vl,f)
723: VL vl;
724: F f;
725: {
726: oFOP op;
727: char *sop;
728:
729: if ( (op = FOP(f)) == AL_NOT ) {
730: PUTS("(@! "); PRINTEXPR(vl,(Obj)FARG(f)); PUTS(")"); return;
731: }
732: switch ( op ) {
733: case AL_IMPL:
734: sop = " @impl "; break;
735: case AL_REPL:
736: sop = " @repl "; break;
737: case AL_EQUIV:
738: sop = " @equiv "; break;
739: default:
740: break;
741: }
742: PUTS("(");
743: PRINTEXPR(vl,(Obj)FLHS(f));
744: PUTS(sop);
745: PRINTEXPR(vl,(Obj)FRHS(f));
746: PUTS(")");
747: }
748:
749: PRINTLOP(vl,f)
750: VL vl;
751: F f;
752: {
753: char *op;
754:
755: switch ( FOP(f) ) {
756: case AL_EQUAL:
757: op = " @== "; break;
758: case AL_NEQ:
759: op = " @!= "; break;
760: case AL_LESSP:
761: op = " @< "; break;
762: case AL_GREATERP:
763: op = " @> "; break;
764: case AL_LEQ:
765: op = " @<= "; break;
766: case AL_GEQ:
767: op = " @>= "; break;
768: default:
769: error("PRINTLOP : invalid operator");
770: break;
771: }
772: PRINTEXPR(vl,(Obj)FPL(f)); PUTS(op); PUTS("0");
773: }
774:
775: PRINTQOP(vl,f)
776: VL vl;
777: F f;
778: {
779: char *op;
780:
781: op = FOP(f)==AL_EX?"ex":"all";
782: TAIL PRINTF(OUT,"%s(%s,",op,NAME(FQVR(f)));
783: PRINTEXPR(vl,(Obj)FQMAT(f)); PUTS(")");
784: }
785:
786: PRINTUP(n)
787: UP n;
788: {
789: int i,d;
790:
791: if ( !n )
792: PUTS("0");
793: else if ( !n->d )
794: PRINTNUM(n->c[0]);
795: else {
796: d = n->d;
797: PUTS("(");
798: if ( !d ) {
799: PRINTNUM(n->c[d]);
800: } else if ( d == 1 ) {
801: PRINTNUM(n->c[d]);
802: PUTS("*@p");
803: } else {
804: PRINTNUM(n->c[d]);
805: PUTS("*@p"); PRINTHAT; TAIL PRINTF(OUT,"%d",d);
806: }
807: for ( i = d-1; i >= 0; i-- ) {
808: if ( n->c[i] ) {
809: PUTS("+("); PRINTNUM(n->c[i]); PUTS(")");
810: if ( i >= 2 ) {
811: PUTS("*@p"); PRINTHAT; TAIL PRINTF(OUT,"%d",i);
812: } else if ( i == 1 )
813: PUTS("*@p");
814: }
815: }
816: PUTS(")");
1.1 noro 817: }
818: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>