[BACK]Return to pexpr.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / io

Annotation of OpenXM_contrib2/asir2000/io/pexpr.c, Revision 1.2

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>