Clean-up the CCL API. Moved some internal structures from ccl.h to
[yaz-moved-to-github.git] / src / cclp.h
1 /*
2  * Copyright (C) 1995-2005, Index Data ApS
3  * See the file LICENSE for details.
4  *
5  * $Id: cclp.h,v 1.1 2007-04-25 20:52:19 adam Exp $
6  */
7
8 #include <yaz/ccl.h>
9
10 #define CCL_TOK_EOL   0
11 #define CCL_TOK_TERM  1
12 #define CCL_TOK_REL   2
13 #define CCL_TOK_EQ    3
14 #define CCL_TOK_PROX  4
15 #define CCL_TOK_LP    5
16 #define CCL_TOK_RP    6
17 #define CCL_TOK_COMMA 7
18 #define CCL_TOK_AND   8
19 #define CCL_TOK_OR    9
20 #define CCL_TOK_NOT   10
21 #define CCL_TOK_SET   11
22
23
24 /** CCL token */
25 struct ccl_token {
26     char kind;
27     size_t len;                 /* length of name below */
28     const char *name;           /* string / name of token */
29     struct ccl_token *next;
30     struct ccl_token *prev;
31     const char *ws_prefix_buf;  /* leading white space buf */
32     size_t ws_prefix_len;       /* leading white space len */
33 };
34
35 /** CCL parser structure */
36 struct ccl_parser {
37     /** current lookahead token */
38     struct ccl_token *look_token;
39     
40     /** holds error code if error occur */
41     int error_code;
42     /** start of CCL string buffer */
43     const char *start_pos;
44     /** if error occurs, this holds position (starting from 0). */
45     const char *error_pos;
46     
47     /** current bibset */
48     CCL_bibset bibset;
49
50     /** names of and operator */
51     char *ccl_token_and;
52     /** names of or operator */
53     char *ccl_token_or;
54     /** names of not operator */
55     char *ccl_token_not;
56     /** names of set operator */
57     char *ccl_token_set;
58     /** 1=CCL parser is case sensitive, 0=case insensitive */
59     int ccl_case_sensitive;
60 };
61
62 /**
63  * Splits CCL command string into individual tokens using
64  * a CCL parser.
65  */
66 YAZ_EXPORT
67 struct ccl_token *ccl_parser_tokenize (CCL_parser cclp, const char *command);
68
69 /** 
70  * Deletes token list
71  */
72 YAZ_EXPORT
73 void ccl_token_del (struct ccl_token *list);
74
75 /**
76  * Add single token after a given onde.
77  */
78 YAZ_EXPORT
79 struct ccl_token *ccl_token_add (struct ccl_token *at);
80
81
82 YAZ_EXPORT
83 struct ccl_rpn_node *ccl_parser_find_token(CCL_parser cclp,
84                                            struct ccl_token *list);
85
86
87
88 /*
89  * Local variables:
90  * c-basic-offset: 4
91  * indent-tabs-mode: nil
92  * End:
93  * vim: shiftwidth=4 tabstop=8 expandtab
94  */
95