Annotation of OpenXM/src/ox_toolkit/print.c, Revision 1.3
1.1 ohara 1: /* -*- mode: C; coding: euc-japan -*- */
1.3 ! ohara 2: /* $OpenXM: OpenXM/src/ox_toolkit/print.c,v 1.2 2000/11/18 05:46:10 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) {
1.3 ! ohara 25: fprintf(ox_stderr, "(%s", symp->key);
1.1 ohara 26: }else {
1.3 ! ohara 27: fprintf(ox_stderr, "(%d", tag);
1.1 ohara 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:
1.3 ! ohara 49: fprintf(ox_stderr, ")");
1.1 ohara 50: break;
51: default:
1.3 ! ohara 52: fprintf(ox_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: {
1.3 ! ohara 58: fprintf(ox_stderr, ", %d)", c->i);
1.1 ohara 59: }
60:
61: static void print_cmo_list(cmo_list* this)
62: {
63: cell* cp = list_first(this);
1.3 ! ohara 64: fprintf(ox_stderr, "[%d]", list_length(this));
1.1 ohara 65: while(!list_endof(this, cp)) {
1.3 ! ohara 66: fprintf(ox_stderr, ", ");
1.1 ohara 67: print_cmo(cp->cmo);
68: cp=list_next(cp);
69: }
1.3 ! ohara 70: fprintf(ox_stderr, ")");
1.1 ohara 71: }
72:
73: static void print_cmo_mathcap(cmo_mathcap* c)
74: {
1.3 ! ohara 75: fprintf(ox_stderr, ", ");
1.1 ohara 76: print_cmo(c->ob);
1.3 ! ohara 77: fprintf(ox_stderr, ")");
1.1 ohara 78: }
79:
80: static void print_cmo_string(cmo_string* c)
81: {
1.3 ! ohara 82: fprintf(ox_stderr, ", \"%s\")", c->s);
1.1 ohara 83: }
84:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>