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

1.1       ohara       1: /* -*- mode: C; coding: euc-japan -*- */
1.2     ! ohara       2: /* $OpenXM: OpenXM/src/ox_toolkit/print.c,v 1.1 2000/10/10 05:23:21 ohara Exp $ */
1.1       ohara       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:
1.2     ! ohara      52:         fprintf(stderr, "\nprint_cmo() does not know how to print cmo of type %d.\n", tag);
1.1       ohara      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);
1.2     ! ohara      64:        fprintf(stderr, "[%d]", list_length(this));
1.1       ohara      65:     while(!list_endof(this, cp)) {
                     66:         fprintf(stderr, ", ");
                     67:         print_cmo(cp->cmo);
                     68:         cp=list_next(cp);
                     69:     }
                     70:     fprintf(stderr, ")");
                     71: }
                     72:
                     73: static void print_cmo_mathcap(cmo_mathcap* c)
                     74: {
                     75:     fprintf(stderr, ", ");
                     76:     print_cmo(c->ob);
                     77:     fprintf(stderr, ")");
                     78: }
                     79:
                     80: static void print_cmo_string(cmo_string* c)
                     81: {
                     82:     fprintf(stderr, ", \"%s\")", c->s);
                     83: }
                     84:

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