[BACK]Return to print.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / ox_toolkit

Annotation of OpenXM/src/ox_toolkit/print.c, Revision 1.1

1.1     ! ohara       1: /* -*- mode: C; coding: euc-japan -*- */
        !             2: /* $OpenXM$ */
        !             3:
        !             4: /*
        !             5: Functions in this module print a given CMO to console.
        !             6: These functions are used for debugging.
        !             7: */
        !             8:
        !             9: #include <stdio.h>
        !            10: #include <stdlib.h>
        !            11: #include "ox_toolkit.h"
        !            12: #include "parse.h"
        !            13:
        !            14: static void print_cmo_int32(cmo_int32* c);
        !            15: static void print_cmo_list(cmo_list* li);
        !            16: static void print_cmo_mathcap(cmo_mathcap* c);
        !            17: static void print_cmo_string(cmo_string* c);
        !            18:
        !            19: void print_cmo(cmo* c)
        !            20: {
        !            21:     int tag = c->tag;
        !            22:
        !            23:     symbol_t symp = lookup_by_tag(tag);
        !            24:     if (symp != NULL) {
        !            25:         fprintf(stderr, "(%s", symp->key);
        !            26:     }else {
        !            27:         fprintf(stderr, "(%d", tag);
        !            28:     }
        !            29:
        !            30:     switch(tag) {
        !            31:     case CMO_LIST:
        !            32:         print_cmo_list((cmo_list *)c);
        !            33:         break;
        !            34:     case CMO_INT32:
        !            35:         print_cmo_int32((cmo_int32 *)c);
        !            36:         break;
        !            37:     case CMO_MATHCAP:
        !            38:     case CMO_INDETERMINATE:
        !            39:     case CMO_RING_BY_NAME:
        !            40:     case CMO_ERROR2:
        !            41:         print_cmo_mathcap((cmo_mathcap *)c);
        !            42:         break;
        !            43:     case CMO_STRING:
        !            44:         print_cmo_string((cmo_string *)c);
        !            45:         break;
        !            46:     case CMO_NULL:
        !            47:     case CMO_ZERO:
        !            48:     case CMO_DMS_GENERIC:
        !            49:         fprintf(stderr, ")");
        !            50:         break;
        !            51:     default:
        !            52:         fprintf(stderr, "print_cmo() does not know how to print.\n");
        !            53:     }
        !            54: }
        !            55:
        !            56: static void print_cmo_int32(cmo_int32* c)
        !            57: {
        !            58:     fprintf(stderr, ", %d)", c->i);
        !            59: }
        !            60:
        !            61: static void print_cmo_list(cmo_list* this)
        !            62: {
        !            63:     cell* cp = list_first(this);
        !            64:     while(!list_endof(this, cp)) {
        !            65:         fprintf(stderr, ", ");
        !            66:         print_cmo(cp->cmo);
        !            67:         cp=list_next(cp);
        !            68:     }
        !            69:     fprintf(stderr, ")");
        !            70: }
        !            71:
        !            72: static void print_cmo_mathcap(cmo_mathcap* c)
        !            73: {
        !            74:     fprintf(stderr, ", ");
        !            75:     print_cmo(c->ob);
        !            76:     fprintf(stderr, ")");
        !            77: }
        !            78:
        !            79: static void print_cmo_string(cmo_string* c)
        !            80: {
        !            81:     fprintf(stderr, ", \"%s\")", c->s);
        !            82: }
        !            83:

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