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

Annotation of OpenXM_contrib2/asir2000/io/cpexpr.c, Revision 1.12

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

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