Modified function heads & prototypes.
[yaz-moved-to-github.git] / ccl / cclptree.c
1 /* CCL print rpn tree - infix notation
2  * Europagate, 1995
3  *
4  * $Log: cclptree.c,v $
5  * Revision 1.2  1995-09-27 15:02:44  quinn
6  * Modified function heads & prototypes.
7  *
8  * Revision 1.1  1995/04/10  10:28:20  quinn
9  * Added copy of CCL.
10  *
11  * Revision 1.5  1995/02/23  08:31:59  adam
12  * Changed header.
13  *
14  * Revision 1.3  1995/02/15  17:42:16  adam
15  * Minor changes of the api of this module. FILE* argument added
16  * to ccl_pr_tree.
17  *
18  * Revision 1.2  1995/02/14  19:55:11  adam
19  * Header files ccl.h/cclp.h are gone! They have been merged an
20  * moved to ../include/ccl.h.
21  * Node kind(s) in ccl_rpn_node have changed names.
22  *
23  * Revision 1.1  1995/02/14  10:25:56  adam
24  * The constructions 'qualifier rel term ...' implemented.
25  *
26  */
27
28 #include <stdio.h>
29 #include <assert.h>
30 #include <string.h>
31
32 #include <ccl.h>
33
34 void MDF ccl_pr_tree (struct ccl_rpn_node *rpn, FILE *fd_out)
35 {
36
37     switch (rpn->kind)
38     {
39     case CCL_RPN_TERM:
40         fprintf (fd_out, "\"%s\"", rpn->u.t.term);
41         if (rpn->u.t.attr_list)
42         {
43             struct ccl_rpn_attr *attr;
44             for (attr = rpn->u.t.attr_list; attr; attr = attr->next)
45                 fprintf (fd_out, " %d=%d", attr->type, attr->value);
46         }
47         break;
48     case CCL_RPN_AND:
49         fprintf (fd_out, "(");
50         ccl_pr_tree (rpn->u.p[0], fd_out);
51         fprintf (fd_out, ") and (");
52         ccl_pr_tree (rpn->u.p[1], fd_out);
53         fprintf (fd_out, ")");
54         break;
55     case CCL_RPN_OR:
56         fprintf (fd_out, "(");
57         ccl_pr_tree (rpn->u.p[0], fd_out);
58         fprintf (fd_out, ") or (");
59         ccl_pr_tree (rpn->u.p[1], fd_out);
60         fprintf (fd_out, ")");
61         break;
62     case CCL_RPN_NOT:
63         fprintf (fd_out, "(");
64         ccl_pr_tree (rpn->u.p[0], fd_out);
65         fprintf (fd_out, ") not (");
66         ccl_pr_tree (rpn->u.p[1], fd_out);
67         fprintf (fd_out, ")");
68         break;
69     case CCL_RPN_SET:
70         fprintf (fd_out, "set=%s", rpn->u.setname);
71         break;
72     case CCL_RPN_PROX:
73         fprintf (fd_out, "(");
74         ccl_pr_tree (rpn->u.p[0], fd_out);
75         fprintf (fd_out, ") prox (");
76         ccl_pr_tree (rpn->u.p[1], fd_out);
77         fprintf (fd_out, ")");
78         break;
79     default:
80         assert (0);
81     }
82 }