source: git/MP/mpviewer/leaf.c @ f78374

fieker-DuValspielwiese
Last change on this file since f78374 was 678cfd, checked in by Olaf Bachmann <obachman@…>, 27 years ago
This commit was generated by cvs2svn to compensate for changes in r337, which included commits to RCS files with non-trunk default branches. git-svn-id: file:///usr/local/Singular/svn/trunk@338 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*******    File: leaf.c    *******/
2
3#include "gmp.h"
4#include "MP.h"
5#include "node.h"
6#include "label.h"
7#include "leaf.h"
8
9/******************************************************************
10 *   FUNCTION: display_data_node
11 *   ARGUMENT: dnp - a pointer to the root of a subtree.
12 *   RETURN:   int indicating if dnp is a data node
13 *             1 = data node ouput done
14 *             0 = not a know data node
15 *   PURPOSE:  Output the data node dnp to stdout
16 ******************************************************************/
17
18int display_data_node(dnp)
19node_t  *dnp;
20{ char   c;
21  /* Treat a data node */
22  switch(dnp->type)
23  {   case MP_Sint32Type: 
24            printf("%d", (long) *((long *)dnp->data));
25            return 1;
26      case MP_Uint32Type: 
27            printf("%u", (long) *((long *)dnp->data));
28            return 1;
29      case MP_Sint8Type:
30            printf("%d", *(dnp->data));
31            return 1;
32      case MP_Uint8Type:
33            printf("%u", *((MP_Uint8_t *)dnp->data));
34            return 1;
35      case MP_BooleanType:
36            c = (*((MP_Boolean_t *)dnp->data) == 1) ? 'T' : 'F';
37            printf("%c", c);
38            return 1;
39      case MP_Real32Type: 
40            printf("%20.10G", (float) *((float *)dnp->data));
41            return 1;
42      case MP_Real64Type: 
43            printf("%20.15lG",   (double) *((double *)dnp->data));
44            return 1;
45      case MP_CommonLatinIdentifierType: 
46            printf("%c", *(dnp->data));
47            return 1;
48      case MP_CommonGreekIdentifierType: 
49            printf("%c", *(dnp->data));
50            return 1;
51      case MP_IdentifierType: 
52            printf("%s", dnp->data);
53            return 1;
54      case MP_ConstantType: 
55            printf("%s", dnp->data);
56            return 1;
57      case MP_CommonConstantType: 
58            printf("%d", *((MP_Common_t *)dnp->data));
59            return 1;
60      case MP_StringType: 
61            printf("%s", dnp->data);
62            return 1;
63      case MP_MetaType: 
64            printf("%s", dnp->data);
65            return 1;
66      case MP_RawType: 
67            printf("%s\n", dnp->data);
68            return 1;
69      case MP_ApIntType: 
70            mpz_out_str(stdout,10, (mpz_ptr)dnp->data); 
71            return 1;
72      case MP_ApRealType: 
73            mpf_out_str(stdout, 10, 0, (mpf_ptr)dnp->data);
74            return 1;
75  }
76  return(0);
77  /*  consider printing annotation on data with (note data annotation) */
78}
79
80/******************************************************************
81 *   FUNCTION: is_data_node
82 *   ARGUMENT: dnp - a pointer to the root of a subtree.
83 *   RETURN:   0 or 1
84 *   PURPOSE:  predicate function
85 ******************************************************************/
86
87int is_data_node(dnp)
88node_t  *dnp;
89{ switch(dnp->type)
90  {   case MP_Sint32Type: 
91      case MP_Uint32Type: 
92      case MP_Sint8Type:
93      case MP_Uint8Type:
94      case MP_BooleanType:
95      case MP_Real32Type: 
96      case MP_Real64Type: 
97      case MP_CommonLatinIdentifierType: 
98      case MP_CommonGreekIdentifierType: 
99      case MP_IdentifierType: 
100      case MP_ConstantType: 
101      case MP_CommonConstantType: 
102      case MP_StringType: 
103      case MP_MetaType: 
104      case MP_RawType: 
105      case MP_ApIntType: 
106      case MP_ApRealType: 
107            return 1;
108  }
109  return(0);
110}
111
112/* checks for a negative term */
113int is_neg(dnp)
114node_t  *dnp;
115{ return (dnp->type == MP_OperatorType &&
116          *(dnp->data) == '-' &&
117          dnp->num_children == 1);
118}
Note: See TracBrowser for help on using the repository browser.