[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.10

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

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