2 * Copyright (c) 1995, the EUROPAGATE consortium (see below).
4 * The EUROPAGATE consortium members are:
6 * University College Dublin
7 * Danmarks Teknologiske Videnscenter
8 * An Chomhairle Leabharlanna
9 * Consejo Superior de Investigaciones Cientificas
11 * Permission to use, copy, modify, distribute, and sell this software and
12 * its documentation, in whole or in part, for any purpose, is hereby granted,
15 * 1. This copyright and permission notice appear in all copies of the
16 * software and its documentation. Notices of copyright or attribution
17 * which appear at the beginning of any file must remain unchanged.
19 * 2. The names of EUROPAGATE or the project partners may not be used to
20 * endorse or promote products derived from this software without specific
21 * prior written permission.
23 * 3. Users of this software (implementors and gateway operators) agree to
24 * inform the EUROPAGATE consortium of their use of the software. This
25 * information will be used to evaluate the EUROPAGATE project and the
26 * software, and to plan further developments. The consortium may use
27 * the information in later publications.
29 * 4. Users of this software agree to make their best efforts, when
30 * documenting their use of the software, to acknowledge the EUROPAGATE
31 * consortium, and the role played by the software in their work.
33 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
34 * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
35 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
36 * IN NO EVENT SHALL THE EUROPAGATE CONSORTIUM OR ITS MEMBERS BE LIABLE
37 * FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF
38 * ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
39 * OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND
40 * ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
41 * USE OR PERFORMANCE OF THIS SOFTWARE.
44 /* CCL find (to rpn conversion)
47 * $Id: cclfind.c,v 1.3 2004-08-11 20:13:36 adam Exp $
51 * Revision 1.16 1996/01/08 08:41:13 adam
52 * Removed unused function.
54 * Revision 1.15 1995/07/20 08:14:34 adam
55 * Qualifiers were observed too often. Instead tokens are treated as
56 * qualifiers only when separated by comma.
58 * Revision 1.14 1995/05/16 09:39:26 adam
61 * Revision 1.13 1995/04/17 09:31:42 adam
62 * Improved handling of qualifiers. Aliases or reserved words.
64 * Revision 1.12 1995/03/20 15:27:43 adam
67 * Revision 1.11 1995/02/23 08:31:59 adam
70 * Revision 1.9 1995/02/16 13:20:06 adam
73 * Revision 1.8 1995/02/14 19:59:42 adam
74 * Removed a syntax error.
76 * Revision 1.7 1995/02/14 19:55:10 adam
77 * Header files ccl.h/cclp.h are gone! They have been merged an
78 * moved to ../include/ccl.h.
79 * Node kind(s) in ccl_rpn_node have changed names.
81 * Revision 1.6 1995/02/14 16:20:55 adam
82 * Qualifiers are read from a file now.
84 * Revision 1.5 1995/02/14 14:12:41 adam
85 * Ranges for ordered qualfiers implemented (e.g. pd=1980-1990).
87 * Revision 1.4 1995/02/14 13:16:29 adam
88 * Left and/or right truncation implemented.
90 * Revision 1.3 1995/02/14 10:25:56 adam
91 * The constructions 'qualifier rel term ...' implemented.
93 * Revision 1.2 1995/02/13 15:15:07 adam
94 * Added handling of qualifiers. Not finished yet.
96 * Revision 1.1 1995/02/13 12:35:20 adam
97 * First version of CCL. Qualifiers aren't handled yet.
106 /* returns type of current lookahead */
107 #define KIND (cclp->look_token->kind)
109 /* move one token forward */
110 #define ADVANCE cclp->look_token = cclp->look_token->next
113 * qual_val_type: test for existance of attribute type/value pair.
114 * qa: Attribute array
115 * type: Type of attribute to search for
116 * value: Value of attribute to seach for
117 * return: 1 if found; 0 otherwise.
119 static int qual_val_type (struct ccl_rpn_attr **qa, int type, int value,
123 struct ccl_rpn_attr *q;
127 for (i = 0; (q=qa[i]); i++)
130 if (q->type == type && q->kind == CCL_RPN_ATTR_NUMERIC &&
131 q->value.numeric == value)
143 * strxcat: concatenate strings.
144 * n: Null-terminated Destination string
145 * src: Source string to be appended (not null-terminated)
146 * len: Length of source string.
148 static void strxcat (char *n, const char *src, int len)
158 * copy_token_name: Return copy of CCL token name
159 * tp: Pointer to token info.
160 * return: malloc(3) allocated copy of token name.
162 static char *copy_token_name (struct ccl_token *tp)
164 char *str = (char *)xmalloc (tp->len + 1);
166 memcpy (str, tp->name, tp->len);
172 * mk_node: Create RPN node.
173 * kind: Type of node.
174 * return: pointer to allocated node.
176 static struct ccl_rpn_node *mk_node (int kind)
178 struct ccl_rpn_node *p;
179 p = (struct ccl_rpn_node *)xmalloc (sizeof(*p));
186 * ccl_rpn_delete: Delete RPN tree.
187 * rpn: Pointer to tree.
189 void ccl_rpn_delete (struct ccl_rpn_node *rpn)
191 struct ccl_rpn_attr *attr, *attr1;
199 ccl_rpn_delete (rpn->u.p[0]);
200 ccl_rpn_delete (rpn->u.p[1]);
203 xfree (rpn->u.t.term);
204 for (attr = rpn->u.t.attr_list; attr; attr = attr1)
207 if (attr->kind == CCL_RPN_ATTR_STRING)
208 xfree(attr->value.str);
215 xfree (rpn->u.setname);
218 ccl_rpn_delete (rpn->u.p[0]);
219 ccl_rpn_delete (rpn->u.p[1]);
225 static struct ccl_rpn_node *find_spec (CCL_parser cclp,
226 struct ccl_rpn_attr **qa);
228 static int is_term_ok (int look, int *list)
230 for (;*list >= 0; list++)
236 static struct ccl_rpn_node *search_terms (CCL_parser cclp,
237 struct ccl_rpn_attr **qa);
239 static struct ccl_rpn_attr *add_attr_node (struct ccl_rpn_node *p,
240 const char *set, int type)
242 struct ccl_rpn_attr *n;
244 n = (struct ccl_rpn_attr *)xmalloc (sizeof(*n));
248 n->set = (char*) xmalloc (strlen(set)+1);
249 strcpy (n->set, set);
254 n->next = p->u.t.attr_list;
255 p->u.t.attr_list = n;
257 n->kind = CCL_RPN_ATTR_NUMERIC;
258 n->value.numeric = 0;
263 * add_attr_numeric: Add attribute (type/value) to RPN term node.
264 * p: RPN node of type term.
265 * type: Type of attribute
266 * value: Value of attribute
267 * set: Attribute set name
269 static void add_attr_numeric (struct ccl_rpn_node *p, const char *set,
272 struct ccl_rpn_attr *n;
274 n = add_attr_node(p, set, type);
275 n->kind = CCL_RPN_ATTR_NUMERIC;
276 n->value.numeric = value;
279 static void add_attr_string (struct ccl_rpn_node *p, const char *set,
280 int type, char *value)
282 struct ccl_rpn_attr *n;
284 n = add_attr_node(p, set, type);
285 n->kind = CCL_RPN_ATTR_STRING;
286 n->value.str = xstrdup(value);
291 * search_term: Parse CCL search term.
293 * qa: Qualifier attributes already applied.
294 * term_list: tokens we accept as terms in context
295 * multi: whether we accept "multiple" tokens
296 * return: pointer to node(s); NULL on error.
298 static struct ccl_rpn_node *search_term_x (CCL_parser cclp,
299 struct ccl_rpn_attr **qa,
300 int *term_list, int multi)
302 struct ccl_rpn_node *p_top = 0;
303 struct ccl_token *lookahead = cclp->look_token;
307 const char *truncation_aliases;
310 ccl_qual_search_special(cclp->bibset, "truncation");
311 if (!truncation_aliases)
312 truncation_aliases = "?";
314 if (qual_val_type (qa, CCL_BIB1_STR, CCL_BIB1_STR_AND_LIST, 0))
316 if (qual_val_type (qa, CCL_BIB1_STR, CCL_BIB1_STR_OR_LIST, 0))
320 struct ccl_rpn_node *p;
326 int relation_value = -1;
327 int position_value = -1;
328 int structure_value = -1;
329 int truncation_value = -1;
330 int completeness_value = -1;
333 if (and_list || or_list || !multi)
336 /* ignore commas when dealing with and-lists .. */
337 if (and_list && lookahead && lookahead->kind == CCL_TOK_COMMA)
339 lookahead = lookahead->next;
343 /* go through each TERM token. If no truncation attribute is yet
344 met, then look for left/right truncation markers (?) and
345 set left_trunc/right_trunc/mid_trunc accordingly */
346 for (no = 0; no < max && is_term_ok(lookahead->kind, term_list); no++)
348 for (i = 0; i<lookahead->len; i++)
349 if (lookahead->name[i] == ' ')
351 else if (strchr(truncation_aliases, lookahead->name[i]))
353 if (no == 0 && i == 0 && lookahead->len >= 1)
355 else if (!is_term_ok(lookahead->next->kind, term_list) &&
356 i == lookahead->len-1 && i >= 1)
361 len += 1+lookahead->len;
362 lookahead = lookahead->next;
366 break; /* no more terms . stop . */
372 p = mk_node (CCL_RPN_OR);
374 p = mk_node (CCL_RPN_AND);
376 p = mk_node (CCL_RPN_AND);
381 /* create the term node, but wait a moment before adding the term */
382 p = mk_node (CCL_RPN_TERM);
383 p->u.t.attr_list = NULL;
386 /* make the top node point to us.. */
393 /* go through all attributes and add them to the attribute list */
394 for (i=0; qa && qa[i]; i++)
396 struct ccl_rpn_attr *attr;
398 for (attr = qa[i]; attr; attr = attr->next)
401 case CCL_RPN_ATTR_STRING:
402 add_attr_string(p, attr->set, attr->type,
405 case CCL_RPN_ATTR_NUMERIC:
406 if (attr->value.numeric > 0)
407 { /* deal only with REAL attributes (positive) */
411 if (relation_value != -1)
413 relation_value = attr->value.numeric;
416 if (position_value != -1)
418 position_value = attr->value.numeric;
421 if (structure_value != -1)
423 structure_value = attr->value.numeric;
426 if (truncation_value != -1)
428 truncation_value = attr->value.numeric;
429 left_trunc = right_trunc = mid_trunc = 0;
432 if (completeness_value != -1)
434 completeness_value = attr->value.numeric;
437 add_attr_numeric(p, attr->set, attr->type,
438 attr->value.numeric);
442 /* len now holds the number of characters in the RPN term */
443 /* no holds the number of CCL tokens (1 or more) */
445 if (structure_value == -1 &&
446 qual_val_type (qa, CCL_BIB1_STR, CCL_BIB1_STR_WP, &attset))
447 { /* no structure attribute met. Apply either structure attribute
448 WORD or PHRASE depending on number of CCL tokens */
449 if (no == 1 && no_spaces == 0)
450 add_attr_numeric (p, attset, CCL_BIB1_STR, 2);
452 add_attr_numeric (p, attset, CCL_BIB1_STR, 1);
455 /* make the RPN token */
456 p->u.t.term = (char *)xmalloc (len);
457 ccl_assert (p->u.t.term);
458 p->u.t.term[0] = '\0';
459 for (i = 0; i<no; i++)
461 const char *src_str = cclp->look_token->name;
462 int src_len = cclp->look_token->len;
464 if (i == 0 && left_trunc)
469 if (i == no-1 && right_trunc)
473 int len = strlen(p->u.t.term);
475 !strchr("-+", *src_str) &&
476 !strchr("-+", p->u.t.term[len-1]))
478 strcat (p->u.t.term, " ");
481 strxcat (p->u.t.term, src_str, src_len);
484 if (left_trunc && right_trunc)
486 if (!qual_val_type (qa, CCL_BIB1_TRU, CCL_BIB1_TRU_CAN_BOTH,
489 cclp->error_code = CCL_ERR_TRUNC_NOT_BOTH;
493 add_attr_numeric (p, attset, CCL_BIB1_TRU, 3);
495 else if (right_trunc)
497 if (!qual_val_type (qa, CCL_BIB1_TRU, CCL_BIB1_TRU_CAN_RIGHT,
500 cclp->error_code = CCL_ERR_TRUNC_NOT_RIGHT;
504 add_attr_numeric (p, attset, CCL_BIB1_TRU, 1);
508 if (!qual_val_type (qa, CCL_BIB1_TRU, CCL_BIB1_TRU_CAN_LEFT,
511 cclp->error_code = CCL_ERR_TRUNC_NOT_LEFT;
515 add_attr_numeric (p, attset, CCL_BIB1_TRU, 2);
519 if (qual_val_type (qa, CCL_BIB1_TRU, CCL_BIB1_TRU_CAN_NONE,
521 add_attr_numeric (p, attset, CCL_BIB1_TRU, 100);
527 cclp->error_code = CCL_ERR_TERM_EXPECTED;
531 static struct ccl_rpn_node *search_term (CCL_parser cclp,
532 struct ccl_rpn_attr **qa)
534 static int list[] = {CCL_TOK_TERM, CCL_TOK_COMMA, -1};
535 return search_term_x(cclp, qa, list, 0);
538 static struct ccl_rpn_node *qualifiers2 (CCL_parser cclp,
539 struct ccl_rpn_attr **ap)
544 if (!qual_val_type(ap, CCL_BIB1_REL, CCL_BIB1_REL_ORDER, &attset))
546 /* unordered relation */
547 struct ccl_rpn_node *p;
548 if (KIND != CCL_TOK_EQ)
550 cclp->error_code = CCL_ERR_EQ_EXPECTED;
554 if (KIND == CCL_TOK_LP)
557 if (!(p = find_spec (cclp, ap)))
561 if (KIND != CCL_TOK_RP)
563 cclp->error_code = CCL_ERR_RP_EXPECTED;
570 p = search_terms (cclp, ap);
573 /* ordered relation ... */
575 if (cclp->look_token->len == 1)
577 if (cclp->look_token->name[0] == '<')
579 else if (cclp->look_token->name[0] == '=')
581 else if (cclp->look_token->name[0] == '>')
584 else if (cclp->look_token->len == 2)
586 if (!memcmp (cclp->look_token->name, "<=", 2))
588 else if (!memcmp (cclp->look_token->name, ">=", 2))
590 else if (!memcmp (cclp->look_token->name, "<>", 2))
594 cclp->error_code = CCL_ERR_BAD_RELATION;
597 struct ccl_rpn_node *p;
599 ADVANCE; /* skip relation */
600 if (KIND == CCL_TOK_TERM &&
601 cclp->look_token->next && cclp->look_token->next->len == 1 &&
602 cclp->look_token->next->name[0] == '-')
604 struct ccl_rpn_node *p1;
605 if (!(p1 = search_term (cclp, ap)))
607 ADVANCE; /* skip '-' */
608 if (KIND == CCL_TOK_TERM) /* = term - term ? */
610 struct ccl_rpn_node *p2;
612 if (!(p2 = search_term (cclp, ap)))
617 p = mk_node (CCL_RPN_AND);
619 add_attr_numeric (p1, attset, CCL_BIB1_REL, 4);
621 add_attr_numeric (p2, attset, CCL_BIB1_REL, 2);
626 add_attr_numeric (p1, attset, CCL_BIB1_REL, 4);
630 else if (cclp->look_token->len == 1 &&
631 cclp->look_token->name[0] == '-') /* = - term ? */
634 if (!(p = search_term (cclp, ap)))
636 add_attr_numeric (p, attset, CCL_BIB1_REL, 2);
639 else if (KIND == CCL_TOK_LP)
642 if (!(p = find_spec (cclp, ap)))
644 if (KIND != CCL_TOK_RP)
646 cclp->error_code = CCL_ERR_RP_EXPECTED;
655 if (!(p = search_terms (cclp, ap)))
657 add_attr_numeric (p, attset, CCL_BIB1_REL, rel);
660 cclp->error_code = CCL_ERR_TERM_EXPECTED;
666 * qualifiers1: Parse CCL qualifiers and search terms.
668 * la: Token pointer to RELATION token.
669 * qa: Qualifier attributes already applied.
670 * return: pointer to node(s); NULL on error.
672 static struct ccl_rpn_node *qualifiers1 (CCL_parser cclp, struct ccl_token *la,
673 struct ccl_rpn_attr **qa)
675 struct ccl_token *lookahead = cclp->look_token;
676 struct ccl_token *look_start = cclp->look_token;
677 struct ccl_rpn_attr **ap;
678 struct ccl_rpn_node *node = 0;
679 const char *field_str;
687 cclp->error_code = CCL_ERR_DOUBLE_QUAL;
691 for (lookahead = cclp->look_token; lookahead != la;
692 lookahead=lookahead->next)
695 for (i=0; qa[i]; i++)
697 ap = (struct ccl_rpn_attr **)xmalloc ((no ? (no+1) : 2) * sizeof(*ap));
700 field_str = ccl_qual_search_special(cclp->bibset, "field");
703 if (!strcmp (field_str, "or"))
705 else if (!strcmp (field_str, "merge"))
710 /* consider each field separately and OR */
711 lookahead = look_start;
712 while (lookahead != la)
716 while ((ap[0] = ccl_qual_search (cclp, lookahead->name,
717 lookahead->len, seq)) != 0)
719 struct ccl_rpn_node *node_sub;
720 cclp->look_token = la;
722 node_sub = qualifiers2(cclp, ap);
725 ccl_rpn_delete (node);
731 struct ccl_rpn_node *node_this = mk_node(CCL_RPN_OR);
732 node_this->u.p[0] = node;
733 node_this->u.p[1] = node_sub;
742 cclp->look_token = lookahead;
743 cclp->error_code = CCL_ERR_UNKNOWN_QUAL;
747 lookahead = lookahead->next;
748 if (lookahead->kind == CCL_TOK_COMMA)
749 lookahead = lookahead->next;
754 /* merge attributes from ALL fields - including inherited ones */
757 struct ccl_rpn_node *node_sub;
759 lookahead = look_start;
760 for (i = 0; lookahead != la; i++)
762 ap[i] = ccl_qual_search (cclp, lookahead->name,
763 lookahead->len, seq);
766 if (!ap[i] && seq > 0)
767 ap[i] = ccl_qual_search (cclp, lookahead->name,
771 cclp->look_token = lookahead;
772 cclp->error_code = CCL_ERR_UNKNOWN_QUAL;
776 lookahead = lookahead->next;
777 if (lookahead->kind == CCL_TOK_COMMA)
778 lookahead = lookahead->next;
782 struct ccl_rpn_attr **qa0 = qa;
792 cclp->look_token = lookahead;
794 node_sub = qualifiers2(cclp, ap);
797 ccl_rpn_delete (node);
802 struct ccl_rpn_node *node_this = mk_node(CCL_RPN_OR);
803 node_this->u.p[0] = node;
804 node_this->u.p[1] = node_sub;
818 * search_terms: Parse CCL search terms - including proximity.
820 * qa: Qualifier attributes already applied.
821 * return: pointer to node(s); NULL on error.
823 static struct ccl_rpn_node *search_terms (CCL_parser cclp,
824 struct ccl_rpn_attr **qa)
826 static int list[] = {
827 CCL_TOK_TERM, CCL_TOK_COMMA,CCL_TOK_EQ, CCL_TOK_REL, CCL_TOK_SET, -1};
828 struct ccl_rpn_node *p1, *p2, *pn;
829 p1 = search_term_x (cclp, qa, list, 1);
834 if (KIND == CCL_TOK_PROX)
836 struct ccl_rpn_node *p_prox = 0;
837 /* ! word order specified */
838 /* % word order not specified */
839 p_prox = mk_node(CCL_RPN_TERM);
840 p_prox->u.t.term = (char *) xmalloc(1 + cclp->look_token->len);
841 memcpy(p_prox->u.t.term, cclp->look_token->name,
842 cclp->look_token->len);
843 p_prox->u.t.term[cclp->look_token->len] = 0;
844 p_prox->u.t.attr_list = 0;
847 p2 = search_term_x (cclp, qa, list, 1);
853 pn = mk_node (CCL_RPN_PROX);
859 else if (is_term_ok(KIND, list))
861 p2 = search_term_x (cclp, qa, list, 1);
867 pn = mk_node (CCL_RPN_PROX);
880 * search_elements: Parse CCL search elements
882 * qa: Qualifier attributes already applied.
883 * return: pointer to node(s); NULL on error.
885 static struct ccl_rpn_node *search_elements (CCL_parser cclp,
886 struct ccl_rpn_attr **qa)
888 struct ccl_rpn_node *p1;
889 struct ccl_token *lookahead;
890 if (KIND == CCL_TOK_LP)
893 p1 = find_spec (cclp, qa);
896 if (KIND != CCL_TOK_RP)
898 cclp->error_code = CCL_ERR_RP_EXPECTED;
905 else if (KIND == CCL_TOK_SET)
908 if (KIND == CCL_TOK_EQ)
910 if (KIND != CCL_TOK_TERM)
912 cclp->error_code = CCL_ERR_SETNAME_EXPECTED;
915 p1 = mk_node (CCL_RPN_SET);
916 p1->u.setname = copy_token_name (cclp->look_token);
920 lookahead = cclp->look_token;
922 while (lookahead->kind==CCL_TOK_TERM)
924 lookahead = lookahead->next;
925 if (lookahead->kind == CCL_TOK_REL || lookahead->kind == CCL_TOK_EQ)
926 return qualifiers1 (cclp, lookahead, qa);
927 if (lookahead->kind != CCL_TOK_COMMA)
929 lookahead = lookahead->next;
932 return search_terms (cclp, qa);
935 struct ccl_rpn_attr *qa[2];
936 struct ccl_rpn_node *node = 0;
938 lookahead = cclp->look_token;
943 struct ccl_rpn_node *node_sub;
944 qa[0] = ccl_qual_search(cclp, "term", 4, seq);
948 cclp->look_token = lookahead;
950 node_sub = search_terms (cclp, qa);
953 ccl_rpn_delete (node);
958 struct ccl_rpn_node *node_this = mk_node(CCL_RPN_OR);
959 node_this->u.p[0] = node;
960 node_this->u.p[1] = node_sub;
961 node_this->u.p[2] = 0;
968 node = search_terms (cclp, 0);
974 * find_spec: Parse CCL find specification
976 * qa: Qualifier attributes already applied.
977 * return: pointer to node(s); NULL on error.
979 static struct ccl_rpn_node *find_spec (CCL_parser cclp,
980 struct ccl_rpn_attr **qa)
982 struct ccl_rpn_node *p1, *p2, *pn;
983 if (!(p1 = search_elements (cclp, qa)))
991 p2 = search_elements (cclp, qa);
997 pn = mk_node (CCL_RPN_AND);
1005 p2 = search_elements (cclp, qa);
1008 ccl_rpn_delete (p1);
1011 pn = mk_node (CCL_RPN_OR);
1019 p2 = search_elements (cclp, qa);
1022 ccl_rpn_delete (p1);
1025 pn = mk_node (CCL_RPN_NOT);
1037 struct ccl_rpn_node *ccl_parser_find (CCL_parser cclp, struct ccl_token *list)
1039 struct ccl_rpn_node *p;
1043 cclp->look_token = list;
1044 p = find_spec (cclp, NULL);
1045 if (p && KIND != CCL_TOK_EOL)
1047 if (KIND == CCL_TOK_RP)
1048 cclp->error_code = CCL_ERR_BAD_RP;
1050 cclp->error_code = CCL_ERR_OP_EXPECTED;
1054 cclp->error_pos = cclp->look_token->name;
1056 cclp->error_code = CCL_ERR_OK;
1058 cclp->error_code = cclp->error_code;
1063 * ccl_find: Parse CCL find - token representation
1064 * bibset: Bibset to be used for the parsing
1065 * list: List of tokens
1066 * error: Pointer to integer. Holds error no. on completion.
1067 * pos: Pointer to char position. Holds approximate error position.
1068 * return: RPN tree on successful completion; NULL otherwise.
1070 struct ccl_rpn_node *ccl_find (CCL_bibset bibset, struct ccl_token *list,
1071 int *error, const char **pos)
1073 struct ccl_rpn_node *p;
1074 CCL_parser cclp = ccl_parser_create ();
1076 cclp->bibset = bibset;
1078 p = ccl_parser_find (cclp, list);
1080 *error = cclp->error_code;
1081 *pos = cclp->error_pos;
1083 ccl_parser_destroy (cclp);
1089 * ccl_find_str: Parse CCL find - string representation
1090 * bibset: Bibset to be used for the parsing
1091 * str: String to be parsed
1092 * error: Pointer to integer. Holds error no. on completion.
1093 * pos: Pointer to char position. Holds approximate error position.
1094 * return: RPN tree on successful completion; NULL otherwise.
1096 struct ccl_rpn_node *ccl_find_str (CCL_bibset bibset, const char *str,
1097 int *error, int *pos)
1099 CCL_parser cclp = ccl_parser_create ();
1100 struct ccl_token *list;
1101 struct ccl_rpn_node *p;
1103 cclp->bibset = bibset;
1105 list = ccl_parser_tokenize (cclp, str);
1106 p = ccl_parser_find (cclp, list);
1108 *error = cclp->error_code;
1110 *pos = cclp->error_pos - str;
1111 ccl_parser_destroy (cclp);
1112 ccl_token_del (list);