Annotation of OpenXM_contrib2/asir2000/io/pexpr.c, Revision 1.5
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.5 ! noro 47: * $OpenXM: OpenXM_contrib2/asir2000/io/pexpr.c,v 1.4 2000/08/22 05:04:18 noro Exp $
1.3 noro 48: */
1.1 noro 49: #include "ca.h"
50: #include "al.h"
51: #include "parse.h"
52: #include "comp.h"
53: #include "base.h"
54:
55: #ifndef FPRINT
56: #define FPRINT
57: #endif
58:
1.2 noro 59: #define PRINTHAT (fortran_output?PUTS("**"):PUTS("^"))
1.1 noro 60:
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
74: #define PRINTLM printlm
75: #define PRINTUP2 printup2
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
87: #define PRINTUI printui
88: #define PRINTGF2MAT printgf2mat
89: #define PRINTGFMMAT printgfmmat
1.5 ! noro 90: #define PRINTBYTEARRAY printbytearray
1.1 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
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.1 noro 106:
107: #define TAIL while ( *OUT ) OUT++;
108: #define PUTS(s) strcat(OUT,s)
109: #define PRINTF sprintf
110: #define PRINTN sprintn
111: #define PRINTBF sprintbf
112: #define PRINTCPLX sprintcplx
113: #define PRINTLM sprintlm
114: #define PRINTUP2 sprintup2
115: #define PRINTV sprintv
116: #define PRINTEXPR sprintexpr
117: #define PRINTNUM sprintnum
118: #define PRINTP sprintp
119: #define PRINTR sprintr
120: #define PRINTLIST sprintlist
121: #define PRINTVECT sprintvect
122: #define PRINTMAT sprintmat
123: #define PRINTSTR sprintstr
124: #define PRINTCOMP sprintcomp
125: #define PRINTDP sprintdp
126: #define PRINTUI sprintui
127: #define PRINTGF2MAT sprintgf2mat
128: #define PRINTGFMMAT sprintgfmmat
1.5 ! noro 129: #define PRINTBYTEARRAY sprintbytearray
1.1 noro 130: #define PRINTERR sprinterr
131: #define PRINTLF sprintlf
132: #define PRINTLOP sprintlop
133: #define PRINTFOP sprintfop
134: #define PRINTEOP sprinteop
135: #define PRINTQOP sprintqop
1.2 noro 136: #define PRINTUP sprintup
1.1 noro 137: #endif
138:
139: void PRINTEXPR();
140: void PRINTNUM();
141: void PRINTN();
142: void PRINTV();
143: void PRINTP();
144: void PRINTR();
145: void PRINTLIST();
146: void PRINTVECT();
147: void PRINTMAT();
148: void PRINTSTR();
149: void PRINTCOMP();
150: void PRINTDP();
151: void PRINTUI();
152: void PRINTGF2MAT();
153: void PRINTGFMMAT();
1.5 ! noro 154: void PRINTBYTEARRAY();
1.1 noro 155: void PRINTERR();
156: void PRINTCPLX();
157: void PRINTLM();
158: void PRINTLF();
1.2 noro 159: void PRINTUP2();
1.1 noro 160:
161: #ifdef FPRINT
162: void output_init() {
163: OUT = stdout;
164: sprintf(DFORMAT,"%%0%dd",DLENGTH);
165: }
166:
167: int mmono(p)
168: P p;
169: {
170: if ( NUM(p) )
171: if ( compnum(CO,(Num)p,0) < 0 )
172: return ( 1 );
173: else
174: return ( 0 );
175: else if ( NEXT(DC(p)) )
176: return ( 0 );
177: else
178: return (mmono(COEF(DC(p))));
179: }
180:
181: #if PARI
182: void printbf(a)
183: BF a;
184: {
185: sor(a->body,'g',-1,0);
186: }
187: #endif
188: #endif
189:
190: #ifdef SPRINT
191: void soutput_init(s)
192: char *s;
193: {
194: s[0] = 0; buf = s;
195: }
196:
197: #if PARI
198: void sprintbf(a)
199: BF a;
200: {
1.2 noro 201: char *str;
202: char *GENtostr();
203:
204: str = GENtostr(a->body);
205: TAIL PRINTF(OUT,"%s",str);
206: free(str);
1.1 noro 207: }
208: #endif
209: #endif
210:
211: void PRINTEXPR(vl,p)
212: VL vl;
213: Obj p;
214: {
215: if ( !p ) {
216: PRINTR(vl,(R)p);
217: return;
218: }
219:
220: switch ( OID(p) ) {
221: case O_N:
222: PRINTNUM((Num)p); break;
223: case O_P:
224: PRINTP(vl,(P)p); break;
225: case O_R:
226: PRINTR(vl,(R)p); break;
227: case O_LIST:
228: PRINTLIST(vl,(LIST)p); break;
229: case O_VECT:
230: PRINTVECT(vl,(VECT)p); break;
231: case O_MAT:
232: PRINTMAT(vl,(MAT)p); break;
233: case O_STR:
234: PRINTSTR((STRING)p); break;
235: case O_COMP:
236: PRINTCOMP(vl,(COMP)p); break;
237: case O_DP:
238: PRINTDP(vl,(DP)p); break;
239: case O_USINT:
240: PRINTUI(vl,(USINT)p); break;
241: case O_GF2MAT:
242: PRINTGF2MAT(vl,(GF2MAT)p); break;
243: case O_ERR:
244: PRINTERR(vl,(ERR)p); break;
245: case O_MATHCAP:
246: PRINTLIST(vl,((MATHCAP)p)->body); break;
247: case O_F:
248: PRINTLF(vl,(F)p); break;
249: case O_GFMMAT:
250: PRINTGFMMAT(vl,(GFMMAT)p); break;
1.5 ! noro 251: case O_BYTEARRAY:
! 252: PRINTBYTEARRAY(vl,(BYTEARRAY)p); break;
1.1 noro 253: default:
254: break;
255: }
256: }
257:
258: void PRINTN(n)
259: N n;
260: {
261: register int i,*ptr;
262: N tn;
263:
264: if ( !n ) {
265: PUTS("0");
266: return;
267: }
268: if ( hex_output ) {
269: ptr = BD(n);
270: TAIL PRINTF(OUT,"0x%x",ptr[PL(n)-1]);
271: if ( hex_output < 0 )
272: for ( i = PL(n) - 2; i >= 0; i-- ) {
273: TAIL PRINTF(OUT,"|%08x",ptr[i]);
274: }
275: else
276: for ( i = PL(n) - 2; i >= 0; i-- ) {
277: TAIL PRINTF(OUT,"%08x",ptr[i]);
278: }
279: } else {
280: ntobn(DBASE,n,&tn);
281: ptr = BD(tn);
282: TAIL PRINTF(OUT,"%d",ptr[PL(tn) - 1]);
283: for ( i = PL(tn) - 2; i >= 0; i-- ) {
284: TAIL PRINTF(OUT,DFORMAT,ptr[i]);
285: }
286: }
287: }
288:
289: void PRINTNUM(q)
290: Num q;
291: {
292: if ( !q ) {
293: PUTS("0");
294: return;
295: }
296: switch ( NID(q) ) {
297: case N_Q:
298: if ( SGN((Q)q) == -1 )
299: PUTS("-");
300: PRINTN(NM((Q)q));
301: if ( !INT((Q)q) ) {
302: PUTS("/"); PRINTN(DN((Q)q));
303: }
304: break;
305: case N_R:
306: TAIL PRINTF(OUT,"%g",BDY((Real)q));
307: break;
308: case N_A:
309: PUTS("("); PRINTR(ALG,(R)BDY((Alg)q)); PUTS(")");
310: break;
311: #if PARI
312: case N_B:
313: PRINTBF((BF)q); break;
314: #endif
315: case N_C:
316: PRINTCPLX((C)q); break;
317: case N_M:
318: TAIL PRINTF(OUT,"%d",CONT((MQ)q)); break;
319: case N_LM:
320: PRINTN(((LM)q)->body); break;
321: case N_GF2N:
322: if ( hex_output )
323: PRINTN((N)(((GF2N)q)->body));
324: else
325: PRINTUP2(((GF2N)q)->body);
326: break;
327: case N_GFPN:
328: PRINTUP((UP)(((GFPN)q)->body));
329: break;
330: }
331: }
332:
333: void PRINTCPLX(a)
334: C a;
335: {
336: PUTS("(");
337: if ( a->r )
338: PRINTNUM(a->r);
339: if ( a->i ) {
340: if ( a->r && (compnum(0,a->i,0) > 0) )
341: PUTS("+");
342: PRINTNUM(a->i); PUTS("*@i");
343: }
344: PUTS(")");
345: }
346:
347: void PRINTP(vl,p)
348: VL vl;
349: P p;
350: {
351: V v;
352: DCP dc;
353:
354: if ( !p )
355: PUTS("0");
356: else if ( NUM(p) )
357: PRINTNUM((Num)p);
358: else
359: for ( dc = DC(p), v = VR(p); dc; dc = NEXT(dc) ) {
360: if ( !DEG(dc) )
361: PRINTP(vl,COEF(dc));
362: else {
363: if ( NUM(COEF(dc)) && UNIQ((Q)COEF(dc)) ) {
364: ;
365: } else if ( NUM(COEF(dc)) && MUNIQ((Q)COEF(dc)) )
366: PUTS("-");
367: else if ( NUM(COEF(dc)) || !NEXT(DC(COEF(dc)))) {
368: PRINTP(vl,COEF(dc)); PUTS("*");
369: } else {
370: PUTS("("); PRINTP(vl,COEF(dc)); PUTS(")*");
371: }
372: PRINTV(vl,v);
373: if ( cmpq(DEG(dc),ONE) ) {
1.2 noro 374: PRINTHAT;
1.1 noro 375: if ( INT(DEG(dc)) && SGN(DEG(dc))>0 )
376: PRINTNUM((Num)DEG(dc));
377: else {
378: PUTS("("); PRINTNUM((Num)DEG(dc)); PUTS(")");
379: }
380: }
381: }
382: if ( NEXT(dc) ) {
383: P t;
384:
385: t = COEF(NEXT(dc));
386: if (!DEG(NEXT(dc))) {
387: if ( NUM(t) ) {
388: if ( !mmono(t) )
389: PUTS("+");
390: } else {
391: if (!mmono(COEF(DC(t))))
392: PUTS("+");
393: }
394: } else {
395: if ( !mmono(t) )
396: PUTS("+");
397: }
398: }
399: }
400: }
401:
402: int hideargs;
403:
404: void PRINTV(vl,v)
405: VL vl;
406: V v;
407: {
408: PF pf;
409: PFAD ad;
410: int i;
411:
412: if ( NAME(v) )
413: PUTS(NAME(v));
414: else if ( (vid)v->attr == V_PF ) {
415: pf = ((PFINS)v->priv)->pf; ad = ((PFINS)v->priv)->ad;
416: if ( !strcmp(NAME(pf),"pow") ) {
1.2 noro 417: PUTS("("); PRINTR(vl,(R)ad[0].arg); PUTS(")"); PRINTHAT; PUTS("(");
1.1 noro 418: PRINTR(vl,(R)ad[1].arg); PUTS(")");
419: } else if ( !pf->argc ) {
420: TAIL PRINTF(OUT,"%s",NAME(pf));
421: } else {
422: if ( hideargs ) {
423: for ( i = 0; i < pf->argc; i++ )
424: if ( ad[i].d )
425: break;
426: if ( i < pf->argc ) {
427: TAIL PRINTF(OUT,"%s{%d",NAME(pf),ad[0].d);
428: for ( i = 1; i < pf->argc; i++ ) {
429: TAIL PRINTF(OUT,",%d",ad[i].d);
430: }
431: PUTS("}");
432: } else {
433: TAIL PRINTF(OUT,"%s",NAME(pf));
434: }
435: } else {
436: for ( i = 0; i < pf->argc; i++ )
437: if ( ad[i].d )
438: break;
439: if ( i < pf->argc ) {
440: TAIL PRINTF(OUT,"%s{%d",NAME(pf),ad[0].d);
441: for ( i = 1; i < pf->argc; i++ ) {
442: TAIL PRINTF(OUT,",%d",ad[i].d);
443: }
444: PUTS("}(");
445: } else {
446: TAIL PRINTF(OUT,"%s(",NAME(pf));
447: }
448: PRINTR(vl,(R)ad[0].arg);
449: for ( i = 1; i < pf->argc; i++ ) {
450: PUTS(","); PRINTR(vl,(R)ad[i].arg);
451: }
452: PUTS(")");
453: }
454: }
455: }
456: }
457:
458: void PRINTR(vl,a)
459: VL vl;
460: R a;
461: {
462: if ( !a )
463: PUTS("0");
464: else
465: switch (OID(a)) {
466: case O_N: case O_P:
467: PRINTP(vl,(P)a); break;
468: default:
469: PUTS("("); PRINTP(vl,NM((R)a)); PUTS(")/("); PRINTP(vl,DN((R)a)); PUTS(")");
470: break;
471: }
472: }
473:
474: void PRINTVECT(vl,vect)
475: VL vl;
476: VECT vect;
477: {
478: int i;
479: pointer *ptr;
480:
481: PUTS("[ ");
482: for ( i = 0, ptr = BDY(vect); i < vect->len; i++ ) {
483: PRINTEXPR(vl,ptr[i]); PUTS(" ");
484: }
485: PUTS("]");
486: }
487:
488: void PRINTMAT(vl,mat)
489: VL vl;
490: MAT mat;
491: {
492: int i,j,r,c;
493: pointer *ptr;
494:
495: for ( i = 0, r = mat->row, c = mat->col; i < r; i++ ) {
496: PUTS("[ ");
497: for ( j = 0, ptr = BDY(mat)[i]; j < c; j++ ) {
498: PRINTEXPR(vl,ptr[j]); PUTS(" ");
499: }
500: PUTS("]");
501: if ( i < r - 1 )
502: PUTS("\n");
503: }
504: }
505:
506: void PRINTLIST(vl,list)
507: VL vl;
508: LIST list;
509: {
510: NODE tnode;
511:
512: PUTS("[");
513: for ( tnode = (NODE)list->body; tnode; tnode = NEXT(tnode) ) {
514: PRINTEXPR(vl,tnode->body);
515: if ( NEXT(tnode) )
516: PUTS(",");
517: }
518: PUTS("]");
519: }
520:
521: void PRINTSTR(str)
522: STRING str;
523: {
524: char *p;
525:
526: for ( p = BDY(str); *p; p++ )
527: if ( *p == '"' )
528: PUTS("\"");
529: else {
530: TAIL PRINTF(OUT,"%c",*p);
531: }
532: }
533:
534: void PRINTCOMP(vl,c)
535: VL vl;
536: COMP c;
537: {
538: int n,i;
539:
540: n = getcompsize((int)c->type);
541: PUTS("{");
542: for ( i = 0; i < n; i++ ) {
543: PRINTEXPR(vl,(pointer)c->member[i]);
544: if ( i < n-1 )
545: PUTS(",");
546: }
547: PUTS("}");
548: }
549:
550: void PRINTDP(vl,d)
551: VL vl;
552: DP d;
553: {
554: int n,i;
555: MP m;
556: DL dl;
557:
558: for ( n = d->nv, m = BDY(d); m; m = NEXT(m) ) {
559: PUTS("("); PRINTEXPR(vl,(pointer)m->c); PUTS(")*<<");
560: for ( i = 0, dl = m->dl; i < n-1; i++ ) {
561: TAIL PRINTF(OUT,"%d,",dl->d[i]);
562: }
563: TAIL PRINTF(OUT,"%d",dl->d[i]);
564: PUTS(">>");
565: if ( NEXT(m) )
566: PUTS("+");
567: }
568: }
569:
570: void PRINTUI(vl,u)
571: VL vl;
572: USINT u;
573: {
574: TAIL PRINTF(OUT,"%u",BDY(u));
575: }
576:
577: void PRINTGF2MAT(vl,mat)
578: VL vl;
579: GF2MAT mat;
580: {
581: int row,col,w,i,j,k,m;
582: unsigned int t;
583: unsigned int **b;
584:
585: row = mat->row;
586: col = mat->col;
587: w = (col+BSH-1)/BSH;
588: b = mat->body;
589: for ( i = 0; i < row; i++ ) {
590: for ( j = 0, m = 0; j < w; j++ ) {
591: t = b[i][j];
592: for ( k = 0; m < col && k < BSH; k++, m++ )
593: if ( t & (1<<k) )
594: PUTS("1");
595: else
596: PUTS("0");
597: }
598: PUTS("\n");
599: }
600: }
601:
602: void PRINTGFMMAT(vl,mat)
603: VL vl;
604: GFMMAT mat;
605: {
606: int row,col,i,j;
607: unsigned int t;
608: unsigned int **b;
609:
610: row = mat->row;
611: col = mat->col;
612: b = mat->body;
613: for ( i = 0; i < row; i++ ) {
614: PUTS("[");
615: for ( j = 0; j < col; j++ ) {
616: TAIL PRINTF(OUT,"%8d",b[i][j]);
617: }
618: PUTS("]\n");
619: }
1.5 ! noro 620: }
! 621:
! 622: void PRINTBYTEARRAY(vl,array)
! 623: VL vl;
! 624: BYTEARRAY array;
! 625: {
! 626: int len,i;
! 627: unsigned int t;
! 628: unsigned char *b;
! 629:
! 630: len = array->len;
! 631: b = array->body;
! 632: PUTS("|");
! 633: for ( i = 0; i < len-1; i++ ) {
! 634: TAIL PRINTF(OUT,"%02x ",(unsigned int)b[i]);
! 635: }
! 636: TAIL PRINTF(OUT,"%02x",(unsigned int)b[i]);
! 637: PUTS("|");
1.1 noro 638: }
639:
640: void PRINTERR(vl,e)
641: VL vl;
642: ERR e;
643: {
644: PUTS("error("); PRINTEXPR(vl,e->body); PUTS(")");
645: }
646:
647: void PRINTUP2(p)
648: UP2 p;
649: {
650: int d,i;
651:
1.2 noro 652: if ( !p ) {
653: TAIL PRINTF(OUT,"0");
654: } else {
1.1 noro 655: d = degup2(p);
1.2 noro 656: TAIL PRINTF(OUT,"(");
657: if ( !d ) {
658: TAIL PRINTF(OUT,"1");
659: } else if ( d == 1 ) {
660: TAIL PRINTF(OUT,"@");
661: } else {
662: PUTS("@"); PRINTHAT; TAIL PRINTF(OUT,"%d",d);
663: }
1.1 noro 664: for ( i = d-1; i >= 0; i-- ) {
665: if ( p->b[i/BSH] & (1<<(i%BSH)) )
1.2 noro 666: if ( !i ) {
667: TAIL PRINTF(OUT,"+1");
668: } else if ( i == 1 ) {
669: TAIL PRINTF(OUT,"+@");
670: } else {
671: PUTS("+@"); PRINTHAT; TAIL PRINTF(OUT,"%d",i);
672: }
1.1 noro 673: }
1.2 noro 674: TAIL PRINTF(OUT,")");
1.1 noro 675: }
676: }
677:
678: void PRINTLF(vl,f)
679: VL vl;
680: F f;
681: {
682: switch ( FOP(f) ) {
683: case AL_TRUE:
684: TAIL PRINTF(OUT,"@true");
685: break;
686: case AL_FALSE:
687: TAIL PRINTF(OUT,"@false");
688: break;
689:
690: case AL_OR: case AL_AND:
691: PRINTFOP(vl,f); break;
692: case AL_NOT: case AL_IMPL: case AL_REPL: case AL_EQUIV:
693: PRINTEOP(vl,f); break;
694:
695: case AL_EQUAL: case AL_NEQ: case AL_LESSP:
696: case AL_GREATERP: case AL_LEQ: case AL_GEQ:
697: PRINTLOP(vl,f); break;
698:
699: case AL_EX: case AL_ALL:
700: PRINTQOP(vl,f); break;
701: default:
702: break;
703: }
704: }
705:
706: PRINTFOP(vl,f)
707: VL vl;
708: F f;
709: {
710: char *op;
711: NODE n;
712:
713: op = FOP(f)==AL_OR?" @|| ":" @&& ";
714: n = FJARG(f);
715: PUTS("("); PRINTEXPR(vl,BDY(n)); PUTS(")");
716: for ( n = NEXT(n); n; n = NEXT(n) ) {
717: PUTS(op); PUTS("("); PRINTEXPR(vl,BDY(n)); PUTS(")");
718: }
719: }
720:
721: PRINTEOP(vl,f)
722: VL vl;
723: F f;
724: {
725: oFOP op;
726: char *sop;
727:
728: if ( (op = FOP(f)) == AL_NOT ) {
729: PUTS("(@! "); PRINTEXPR(vl,(Obj)FARG(f)); PUTS(")"); return;
730: }
731: switch ( op ) {
732: case AL_IMPL:
733: sop = " @impl "; break;
734: case AL_REPL:
735: sop = " @repl "; break;
736: case AL_EQUIV:
737: sop = " @equiv "; break;
738: default:
739: break;
740: }
741: PUTS("(");
742: PRINTEXPR(vl,(Obj)FLHS(f));
743: PUTS(sop);
744: PRINTEXPR(vl,(Obj)FRHS(f));
745: PUTS(")");
746: }
747:
748: PRINTLOP(vl,f)
749: VL vl;
750: F f;
751: {
752: char *op;
753:
754: switch ( FOP(f) ) {
755: case AL_EQUAL:
756: op = " @== "; break;
757: case AL_NEQ:
758: op = " @!= "; break;
759: case AL_LESSP:
760: op = " @< "; break;
761: case AL_GREATERP:
762: op = " @> "; break;
763: case AL_LEQ:
764: op = " @<= "; break;
765: case AL_GEQ:
766: op = " @>= "; break;
767: default:
768: error("PRINTLOP : invalid operator");
769: break;
770: }
771: PRINTEXPR(vl,(Obj)FPL(f)); PUTS(op); PUTS("0");
772: }
773:
774: PRINTQOP(vl,f)
775: VL vl;
776: F f;
777: {
778: char *op;
779:
780: op = FOP(f)==AL_EX?"ex":"all";
781: TAIL PRINTF(OUT,"%s(%s,",op,NAME(FQVR(f)));
782: PRINTEXPR(vl,(Obj)FQMAT(f)); PUTS(")");
783: }
784:
785: PRINTUP(n)
786: UP n;
787: {
788: int i,d;
789:
790: if ( !n )
791: PUTS("0");
792: else if ( !n->d )
793: PRINTNUM(n->c[0]);
794: else {
795: d = n->d;
796: PUTS("(");
797: if ( !d ) {
798: PRINTNUM(n->c[d]);
799: } else if ( d == 1 ) {
800: PRINTNUM(n->c[d]);
801: PUTS("*@p");
802: } else {
803: PRINTNUM(n->c[d]);
1.2 noro 804: PUTS("*@p"); PRINTHAT; TAIL PRINTF(OUT,"%d",d);
1.1 noro 805: }
806: for ( i = d-1; i >= 0; i-- ) {
807: if ( n->c[i] ) {
808: PUTS("+("); PRINTNUM(n->c[i]); PUTS(")");
809: if ( i >= 2 ) {
1.2 noro 810: PUTS("*@p"); PRINTHAT; TAIL PRINTF(OUT,"%d",i);
1.1 noro 811: } else if ( i == 1 )
812: PUTS("*@p");
813: }
814: }
815: PUTS(")");
816: }
817: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>