Annotation of OpenXM/src/ox_toolkit/print.c, Revision 1.4
1.1 ohara 1: /* -*- mode: C; coding: euc-japan -*- */
1.4 ! ohara 2: /* $OpenXM: OpenXM/src/ox_toolkit/print.c,v 1.3 2003/01/11 11:42:32 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.4 ! ohara 25: ox_printf("(%s", symp->key);
1.1 ohara 26: }else {
1.4 ! ohara 27: ox_printf("(%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.4 ! ohara 49: ox_printf(")");
1.1 ohara 50: break;
51: default:
1.4 ! ohara 52: ox_printf("\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.4 ! ohara 58: ox_printf(", %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.4 ! ohara 64: ox_printf("[%d]", list_length(this));
1.1 ohara 65: while(!list_endof(this, cp)) {
1.4 ! ohara 66: ox_printf(", ");
1.1 ohara 67: print_cmo(cp->cmo);
68: cp=list_next(cp);
69: }
1.4 ! ohara 70: ox_printf(")");
1.1 ohara 71: }
72:
73: static void print_cmo_mathcap(cmo_mathcap* c)
74: {
1.4 ! ohara 75: ox_printf(", ");
1.1 ohara 76: print_cmo(c->ob);
1.4 ! ohara 77: ox_printf(")");
1.1 ohara 78: }
79:
80: static void print_cmo_string(cmo_string* c)
81: {
1.4 ! ohara 82: ox_printf(", \"%s\")", c->s);
1.1 ohara 83: }
84:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>