The constructions 'qualifier rel term ...' implemented.
[egate.git] / ccl / cclsh.c
1 /* CCL shell.
2  * Europagate 1995
3  *
4  * $Log: cclsh.c,v $
5  * Revision 1.3  1995/02/14 10:25:57  adam
6  * The constructions 'qualifier rel term ...' implemented.
7  *
8  * Revision 1.2  1995/02/13  15:15:07  adam
9  * Added handling of qualifiers. Not finished yet.
10  *
11  * Revision 1.1  1995/02/13  12:35:21  adam
12  * First version of CCL. Qualifiers aren't handled yet.
13  *
14  */
15
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <assert.h>
19
20 #include "ccl.h"
21
22 static int debug = 0;
23 static char *prog;
24
25 static int ti_attr[] = {
26     CCL_BIB1_USE, 5,
27     CCL_BIB1_STR, CCL_BIB1_STR_WP
28 };
29
30 static int au_attr[] = {
31     CCL_BIB1_USE, 1,
32     CCL_BIB1_STR, CCL_BIB1_STR_WP
33 };
34
35 static int pd_attr[] = {
36     CCL_BIB1_USE, 31,
37     CCL_BIB1_REL, CCL_BIB1_REL_ORDER
38 };
39
40 int main (int argc, char **argv)
41 {
42     CCL_bibset bibset;
43
44     prog = *argv;
45     bibset = ccl_qual_mk ();    
46     while (--argc > 0)
47     {
48         ++argv;
49         if (**++argv == '-')
50         {
51             switch (argv[0][1])
52             {
53             case 'd':
54                 debug = 1;
55                 break;
56             default:
57                 fprintf (stderr, "%s: unknown option '%s'\n",
58                     prog, *argv);
59                 exit (1);
60             }
61         }
62         else
63         {
64             fprintf (stderr, "%s: no filenames, please\n", prog);
65             exit (1);
66         }
67     }
68     ccl_qual_add (bibset, "ti", sizeof(ti_attr)/(2*sizeof(int)), ti_attr);
69     ccl_qual_add (bibset, "au", sizeof(au_attr)/(2*sizeof(int)), au_attr);
70     ccl_qual_add (bibset, "pd", sizeof(pd_attr)/(2*sizeof(int)), pd_attr);
71     while (1)
72     {
73         char buf[80];
74         int error, pos;
75         struct ccl_rpn_node *rpn;
76
77         printf ("CCLSH>"); fflush (stdout);
78         if (!fgets (buf, 79, stdin))
79             break;
80         rpn = ccl_find_str (bibset, buf, &error, &pos);
81         if (error)
82         {
83             printf ("%*s^ - ", 6+pos, " ");
84             printf ("%s\n", ccl_err_msg (error));
85         }
86         else
87         {
88             assert (rpn);
89             ccl_pr_tree (rpn);
90             putchar ('\n');
91         }
92     }
93     putchar ('\n');
94     return 0;
95 }
96
97