Annotation of OpenXM/src/ox_toolkit/print.c, Revision 1.5
1.1 ohara 1: /* -*- mode: C; coding: euc-japan -*- */
1.5 ! ohara 2: /* $OpenXM: OpenXM/src/ox_toolkit/print.c,v 1.4 2003/01/13 12:03:12 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;
1.5 ! ohara 22: char *s = get_symbol_by_tag(tag);
! 23: if (s != NULL) {
! 24: ox_printf("(%s", s);
1.1 ohara 25: }else {
1.4 ohara 26: ox_printf("(%d", tag);
1.1 ohara 27: }
28:
29: switch(tag) {
30: case CMO_LIST:
31: print_cmo_list((cmo_list *)c);
32: break;
33: case CMO_INT32:
34: print_cmo_int32((cmo_int32 *)c);
35: break;
36: case CMO_MATHCAP:
37: case CMO_INDETERMINATE:
38: case CMO_RING_BY_NAME:
39: case CMO_ERROR2:
40: print_cmo_mathcap((cmo_mathcap *)c);
41: break;
42: case CMO_STRING:
43: print_cmo_string((cmo_string *)c);
44: break;
45: case CMO_NULL:
46: case CMO_ZERO:
47: case CMO_DMS_GENERIC:
1.4 ohara 48: ox_printf(")");
1.1 ohara 49: break;
50: default:
1.4 ohara 51: ox_printf("\nprint_cmo() does not know how to print cmo of type %d.\n", tag);
1.1 ohara 52: }
53: }
54:
55: static void print_cmo_int32(cmo_int32* c)
56: {
1.4 ohara 57: ox_printf(", %d)", c->i);
1.1 ohara 58: }
59:
60: static void print_cmo_list(cmo_list* this)
61: {
62: cell* cp = list_first(this);
1.4 ohara 63: ox_printf("[%d]", list_length(this));
1.1 ohara 64: while(!list_endof(this, cp)) {
1.4 ohara 65: ox_printf(", ");
1.1 ohara 66: print_cmo(cp->cmo);
67: cp=list_next(cp);
68: }
1.4 ohara 69: ox_printf(")");
1.1 ohara 70: }
71:
72: static void print_cmo_mathcap(cmo_mathcap* c)
73: {
1.4 ohara 74: ox_printf(", ");
1.1 ohara 75: print_cmo(c->ob);
1.4 ohara 76: ox_printf(")");
1.1 ohara 77: }
78:
79: static void print_cmo_string(cmo_string* c)
80: {
1.4 ohara 81: ox_printf(", \"%s\")", c->s);
1.1 ohara 82: }
83:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>