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

Annotation of OpenXM_contrib2/asir2000/builtin/print.c, Revision 1.4

1.2       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.3       noro       26:  * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.2       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.
                     47:  *
1.4     ! noro       48:  * $OpenXM: OpenXM_contrib2/asir2000/builtin/print.c,v 1.3 2000/08/22 05:03:59 noro Exp $
1.2       noro       49: */
1.1       noro       50: #include "ca.h"
                     51: #include "parse.h"
                     52:
                     53: void Pprint();
1.4     ! noro       54: void Pquotetolist();
1.1       noro       55:
                     56: struct ftab print_tab[] = {
                     57:        {"print",Pprint,-2},
1.4     ! noro       58:        {"quotetolist",Pquotetolist,1},
1.1       noro       59:        {0,0,0},
                     60: };
                     61:
                     62: void Pprint(arg,rp)
                     63: NODE arg;
                     64: pointer *rp;
                     65: {
                     66:        printexpr(CO,ARG0(arg));
                     67:        if ( argc(arg) == 2 )
                     68:                switch ( QTOS((Q)ARG1(arg)) ) {
                     69:                        case 0:
                     70:                                break;
                     71:                        case 2:
                     72:                                fflush(asir_out); break;
                     73:                                break;
                     74:                        case 1: default:
                     75:                                putc('\n',asir_out); break;
                     76:                }
                     77:        else
                     78:                putc('\n',asir_out);
                     79:        *rp = 0;
1.4     ! noro       80: }
        !            81:
        !            82: void fnodetotree();
        !            83:
        !            84: void Pquotetolist(arg,rp)
        !            85: NODE arg;
        !            86: Obj *rp;
        !            87: {
        !            88:        asir_assert(ARG0(arg),O_QUOTE,"quotetolist");
        !            89:        fnodetotree((FNODE)BDY((QUOTE)(ARG0(arg))),rp);
        !            90: }
        !            91:
        !            92: void fnodetotree(f,rp)
        !            93: FNODE f;
        !            94: Obj *rp;
        !            95: {
        !            96:        Obj a1,a2;
        !            97:        NODE n,t,t0;
        !            98:        STRING head;
        !            99:        LIST r,arg;
        !           100:        char *opname;
        !           101:
        !           102:        if ( !f ) {
        !           103:                *rp = 0;
        !           104:                return;
        !           105:        }
        !           106:        switch ( f->id ) {
        !           107:                case I_BOP: case I_COP: I_LOP:
        !           108:                        /* arg list */
        !           109:                        fnodetotree((FNODE)FA1(f),&a1);
        !           110:                        fnodetotree((FNODE)FA2(f),&a2);
        !           111:                        n = mknode(2,a1,a2); MKLIST(arg,n);
        !           112:
        !           113:                        /* head */
        !           114:                        switch ( f->id ) {
        !           115:                                case I_BOP:
        !           116:                                        MKSTR(head,((ARF)FA0(f))->name); break;
        !           117:                                case I_COP:
        !           118:                                        switch( (cid)FA0(f) ) {
        !           119:                                                case C_EQ: opname = "=="; break;
        !           120:                                                case C_NE: opname = "!="; break;
        !           121:                                                case C_GT: opname = ">"; break;
        !           122:                                                case C_LT: opname = "<"; break;
        !           123:                                                case C_GE: opname = ">="; break;
        !           124:                                                case C_LE: opname = "<="; break;
        !           125:                                        }
        !           126:                                        MKSTR(head,opname); break;
        !           127:                                case I_LOP:
        !           128:                                        switch( (lid)FA0(f) ) {
        !           129:                                                case L_EQ: opname = "@=="; break;
        !           130:                                                case L_NE: opname = "@!="; break;
        !           131:                                                case L_GT: opname = "@>"; break;
        !           132:                                                case L_LT: opname = "@<"; break;
        !           133:                                                case L_GE: opname = "@>="; break;
        !           134:                                                case L_LE: opname = "@<="; break;
        !           135:                                                case L_AND: opname = "@&&"; break;
        !           136:                                                case L_OR: opname = "@||"; break;
        !           137:                                                case L_NOT: opname = "@!"; break;
        !           138:                                        }
        !           139:                                        MKSTR(head,opname); break;
        !           140:                        }
        !           141:                        n = mknode(2,head,arg);
        !           142:                        MKLIST(r,n);
        !           143:                        *rp = (Obj)r;
        !           144:                        break;
        !           145:                case I_AND:
        !           146:                        fnodetotree((FNODE)FA0(f),&a1);
        !           147:                        fnodetotree((FNODE)FA1(f),&a2);
        !           148:                        n = mknode(2,a1,a2); MKLIST(arg,n);
        !           149:                        MKSTR(head,"&&");
        !           150:                        n = mknode(2,head,arg);
        !           151:                        MKLIST(r,n);
        !           152:                        *rp = (Obj)r;
        !           153:                        break;
        !           154:                case I_OR:
        !           155:                        fnodetotree((FNODE)FA0(f),&a1);
        !           156:                        fnodetotree((FNODE)FA1(f),&a2);
        !           157:                        n = mknode(2,a1,a2); MKLIST(arg,n);
        !           158:                        MKSTR(head,"||");
        !           159:                        n = mknode(2,head,arg);
        !           160:                        MKLIST(r,n);
        !           161:                        *rp = (Obj)r;
        !           162:                        break;
        !           163:                case I_NOT:
        !           164:                        fnodetotree((FNODE)FA0(f),&a1);
        !           165:                        n = mknode(1,a1); MKLIST(arg,n);
        !           166:                        MKSTR(head,"!");
        !           167:                        n = mknode(2,head,arg);
        !           168:                        MKLIST(r,n);
        !           169:                        *rp = (Obj)r;
        !           170:                        break;
        !           171:                case I_CE:
        !           172:                        fnodetotree((FNODE)FA0(f),&a1);
        !           173:                        fnodetotree((FNODE)FA1(f),&a2);
        !           174:                        n = mknode(2,a1,a2); MKLIST(arg,n);
        !           175:                        MKSTR(head,"?:");
        !           176:                        n = mknode(2,head,arg);
        !           177:                        MKLIST(r,n);
        !           178:                        *rp = (Obj)r;
        !           179:                        break;
        !           180:                case I_EV: case I_LIST:
        !           181:                        n = (NODE)FA0(f);
        !           182:                        for ( t0 = 0; n; n = NEXT(n) ) {
        !           183:                                NEXTNODE(t0,t);
        !           184:                                fnodetotree(BDY(n),&BDY(t));
        !           185:                        }
        !           186:                        if ( t0 )
        !           187:                                NEXT(t) = 0;
        !           188:                        MKLIST(arg,t0);
        !           189:                        switch ( f->id ) {
        !           190:                                case I_LIST:
        !           191:                                        *rp = (Obj)arg; break;
        !           192:                                case I_EV:
        !           193:                                        MKSTR(head,"exponent_vector");
        !           194:                                        n = mknode(2,head,arg);
        !           195:                                        MKLIST(r,n);
        !           196:                                        *rp = (Obj)r;
        !           197:                                        break;
        !           198:                        }
        !           199:                        break;
        !           200:                case I_FUNC:
        !           201:                        fnodetotree((FNODE)FA1(f),&arg);
        !           202:                        MKSTR(head,((FUNC)FA0(f))->name);
        !           203:                        n = mknode(2,head,arg);
        !           204:                        MKLIST(r,n);
        !           205:                        *rp = (Obj)r;
        !           206:                        break;
        !           207:                case I_CAR:
        !           208:                        fnodetotree((FNODE)FA0(f),&arg);
        !           209:                        MKSTR(head,"car");
        !           210:                        n = mknode(2,head,arg);
        !           211:                        MKLIST(r,n);
        !           212:                        *rp = (Obj)r;
        !           213:                        break;
        !           214:                case I_CDR:
        !           215:                        fnodetotree((FNODE)FA0(f),&arg);
        !           216:                        MKSTR(head,"cdr");
        !           217:                        n = mknode(2,head,arg);
        !           218:                        MKLIST(r,n);
        !           219:                        *rp = (Obj)r;
        !           220:                        break;
        !           221:                case I_FORMULA:
        !           222:                        *rp = (Obj)FA0(f);
        !           223:                        break;
        !           224:                default:
        !           225:                        error("fnodetotree : not implemented yet");
        !           226:        }
1.1       noro      227: }

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