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