25 #define KIND (cclp->look_token->kind)
28 #define ADVANCE cclp->look_token = cclp->look_token->next
43 for (i = 0; qa[i]; i++)
47 for (; q; q = q->
next)
72 static void strxcat(
char *n,
const char *src,
int len)
110 p->
u.
t.attr_list = 0;
157 for (attr = rpn->
u.
t.attr_list; attr; attr = attr1)
183 for (; *list >= 0; list++)
201 n->
next = p->
u.
t.attr_list;
202 p->
u.
t.attr_list = n;
225 for (n = p->
u.
t.attr_list; n; n = n->
next)
249 for (; *aliases; aliases++)
251 const char *cp = *aliases;
253 for (i = 0; *cp && *cp == input[i]; i++, cp++)
262 #define REGEX_CHARS "^[]{}()|.*+?!$"
263 #define CCL_CHARS "#?\\"
267 const char **truncation_aliases,
268 const char **mask_aliases)
273 for (j = 0; j < src_len; j++)
276 if (j > 0 && src_str[j-1] ==
'\\')
278 else if (src_str[j] ==
'"')
279 quote_mode = !quote_mode;
280 else if (!quote_mode &&
284 else if (!quote_mode &&
293 char *dst_term,
int regex_trunc,
int z3958_trunc,
294 const char **truncation_aliases,
295 const char **mask_aliases,
296 int is_first,
int is_last,
297 int *left_trunc,
int *right_trunc)
302 for (j = 0; j < src_len; j++)
305 if (j > 0 && src_str[j-1] ==
'\\')
307 if (regex_trunc && strchr(
REGEX_CHARS "\\", src_str[j]))
308 strcat(dst_term,
"\\");
309 else if (z3958_trunc && strchr(
CCL_CHARS "\\", src_str[j]))
310 strcat(dst_term,
"\\");
311 strxcat(dst_term, src_str + j, 1);
313 else if (src_str[j] ==
'"')
314 quote_mode = !quote_mode;
315 else if (!quote_mode &&
322 strcat(dst_term,
".*");
323 else if (z3958_trunc)
324 strcat(dst_term,
"?");
325 else if (is_first && j == 0)
327 else if (is_last && j == src_len - 1)
335 else if (!quote_mode &&
340 strcat(dst_term,
".");
341 else if (z3958_trunc)
342 strcat(dst_term,
"#");
349 else if (src_str[j] !=
'\\')
351 if (regex_trunc && strchr(
REGEX_CHARS, src_str[j]))
352 strcat(dst_term,
"\\");
353 else if (z3958_trunc && strchr(
CCL_CHARS, src_str[j]))
354 strcat(dst_term,
"\\");
355 strxcat(dst_term, src_str + j, 1);
372 int structure_value = -1;
378 int is_ccl_masked = 0;
380 struct ccl_token *lookahead = lookahead0;
381 const char **truncation_aliases;
382 const char *t_default[2];
383 const char **mask_aliases;
384 const char *m_default[2];
389 if (!truncation_aliases)
391 truncation_aliases = t_default;
399 mask_aliases = m_default;
403 for (i = 0; i < no; i++)
411 lookahead = lookahead->
next;
413 lookahead = lookahead0;
416 p->
u.
t.attr_list = NULL;
425 for (i = 0; qa && qa[i]; i++)
429 if (attr->
type == 1 && attr_use && attr != attr_use)
445 if (structure_value != -1)
457 if (structure_value == -1 && (
480 p->
u.
t.term = (
char *)
xmalloc(term_len * 2 + 2);
482 p->
u.
t.term[0] =
'\0';
484 for (i = 0; i < no; i++)
486 const char *src_str = lookahead->
name;
487 size_t src_len = lookahead->
len;
494 if (
append_term(cclp, src_str, src_len, p->
u.
t.term, regex_trunc,
495 z3958_trunc, truncation_aliases, mask_aliases,
497 &left_trunc, &right_trunc))
502 lookahead = lookahead->
next;
504 if (left_trunc && right_trunc)
515 else if (right_trunc)
537 else if (regex_trunc)
541 else if (z3958_trunc)
563 for (i = 0; qa && qa[i]; i++)
567 if (attr->
type == 1 && i == 0)
572 is_phrase, auto_group);
584 is_phrase, auto_group);
595 for (l = 1; l <= sz && l <= sub_len; l++)
625 int *term_list,
int multi)
630 size_t i, sz, sub_len;
632 lookahead = lookahead->
next;
643 lookahead = lookahead->
next;
654 for (i = 0; i < sz; i++)
669 int *term_list,
int multi)
693 if (and_list || or_list || !multi)
699 lookahead = lookahead->
next;
703 for (no = 0; no < max &&
is_term_ok(lookahead->
kind, term_list); no++)
705 int this_is_phrase = 0;
706 for (i = 0; i<lookahead->
len; i++)
707 if (lookahead->
name[i] ==
' ')
711 if (no > 0 && (is_phrase || is_phrase != this_is_phrase))
713 is_phrase = this_is_phrase;
715 else if (this_is_phrase || no > 0)
717 lookahead = lookahead->
next;
723 is_phrase, auto_group);
724 for (i = 0; i < no; i++)
764 static int list[] = {
818 quote_mode = !quote_mode;
844 else if (cclp->
look_token->
len > 2 && i < cclp->look_token->len)
966 const char **field_str;
978 for (lookahead = cclp->
look_token; lookahead != la;
979 lookahead=lookahead->
next)
982 for (i=0; qa[i]; i++)
990 if (!strcmp(field_str[0],
"or"))
992 else if (!strcmp(field_str[0],
"merge"))
998 lookahead = look_start;
999 while (lookahead != la)
1004 lookahead->
len, seq)) != 0)
1026 lookahead = lookahead->
next;
1028 lookahead = lookahead->
next;
1038 lookahead = look_start;
1039 for (i = 0; lookahead != la; i++)
1042 lookahead->
len, seq);
1045 if (!ap[i] && seq > 0)
1055 lookahead = lookahead->
next;
1057 lookahead = lookahead->
next;
1096 static int list[] = {
1115 p_prox->
u.
t.attr_list = 0;
1127 pn->
u.
p[2] = p_prox;
1180 lookahead = lookahead->
next;
1185 lookahead = lookahead->
next;
1197 for(seq = 0; ;seq++)
1311 int *error,
int *pos)
#define CCL_ERR_UNKNOWN_QUAL
#define CCL_RPN_ATTR_STRING
#define CCL_BIB1_TRU_CAN_NONE
#define CCL_ERR_TRUNC_NOT_RIGHT
#define CCL_BIB1_REL_ORDER
#define CCL_ERR_SETNAME_EXPECTED
#define CCL_ERR_TRUNC_NOT_BOTH
#define CCL_BIB1_TRU_CAN_LEFT
#define CCL_ERR_DOUBLE_QUAL
#define CCL_ERR_RP_EXPECTED
#define CCL_ERR_TRUNC_NOT_EMBED
#define CCL_ERR_TRUNC_NOT_SINGLE
#define CCL_ERR_BAD_RELATION
#define CCL_ERR_EQ_EXPECTED
#define CCL_BIB1_TRU_CAN_Z3958
#define CCL_RPN_ATTR_NUMERIC
#define CCL_BIB1_REL_PORDER
#define CCL_BIB1_REL_OMIT_EQUALS
#define CCL_ERR_TRUNC_NOT_LEFT
#define CCL_ERR_TERM_EXPECTED
#define CCL_BIB1_STR_AUTO_GROUP
#define CCL_BIB1_TRU_CAN_REGEX
#define CCL_BIB1_TRU_CAN_BOTH
#define CCL_ERR_OP_EXPECTED
#define CCL_BIB1_TRU_CAN_RIGHT
ccl_rpn_kind
node type or RPN tree generated by the CCL parser
#define CCL_BIB1_STR_OR_LIST
#define CCL_BIB1_STR_AND_LIST
#define CCL_BIB1_STR_SPLIT_LIST
static struct ccl_rpn_node * ccl_term_multi_use(CCL_parser cclp, struct ccl_token *lookahead0, ccl_qualifier_t *qa, size_t no, int is_phrase, int auto_group)
static struct ccl_rpn_node * qualifier_relation(CCL_parser cclp, ccl_qualifier_t *ap)
static struct ccl_rpn_node * split_recur(CCL_parser cclp, ccl_qualifier_t *qa, struct ccl_token **ar, size_t sz, size_t sub_len)
static struct ccl_rpn_node * search_term_split_list(CCL_parser cclp, ccl_qualifier_t *qa, int *term_list, int multi)
static int has_ccl_masking(const char *src_str, size_t src_len, const char **truncation_aliases, const char **mask_aliases)
static void strxcat(char *n, const char *src, int len)
struct ccl_rpn_node * ccl_find_str(CCL_bibset bibset, const char *str, int *error, int *pos)
parse CCL find string using CCL profile return RPN tree
struct ccl_rpn_node * ccl_parser_find_str(CCL_parser cclp, const char *str)
parse CCL find string with parser and return RPN tree
static struct ccl_rpn_node * qualifiers_order(CCL_parser cclp, ccl_qualifier_t *ap, char *attset)
static struct ccl_rpn_node * ccl_term_one_use(CCL_parser cclp, struct ccl_token *lookahead0, struct ccl_rpn_attr *attr_use, ccl_qualifier_t *qa, size_t no, int is_phrase, int auto_group)
static struct ccl_rpn_node * search_term(CCL_parser cclp, ccl_qualifier_t *qa)
static struct ccl_rpn_node * search_terms2(CCL_parser cclp, ccl_qualifier_t *qa)
void ccl_rpn_delete(struct ccl_rpn_node *rpn)
void ccl_set_attr_numeric(struct ccl_rpn_node *p, const char *set, int type, int value)
static char * copy_token_name(struct ccl_token *tp)
struct ccl_rpn_node * ccl_parser_find_token(CCL_parser cclp, struct ccl_token *list)
static struct ccl_rpn_node * ccl_rpn_node_mkbool(struct ccl_rpn_node *l, struct ccl_rpn_node *r, enum ccl_rpn_kind op)
static struct ccl_rpn_node * search_term_x(CCL_parser cclp, ccl_qualifier_t *qa, int *term_list, int multi)
static struct ccl_rpn_node * qualifier_list(CCL_parser cclp, struct ccl_token *la, ccl_qualifier_t *qa)
static struct ccl_rpn_node * search_terms(CCL_parser cclp, ccl_qualifier_t *qa)
static int is_term_ok(int look, int *list)
void ccl_add_attr_numeric(struct ccl_rpn_node *p, const char *set, int type, int value)
void ccl_add_attr_string(struct ccl_rpn_node *p, const char *set, int type, char *value)
static int append_term(CCL_parser cclp, const char *src_str, size_t src_len, char *dst_term, int regex_trunc, int z3958_trunc, const char **truncation_aliases, const char **mask_aliases, int is_first, int is_last, int *left_trunc, int *right_trunc)
static struct ccl_rpn_node * search_elements(CCL_parser cclp, ccl_qualifier_t *qa)
static struct ccl_rpn_attr * add_attr_node(struct ccl_rpn_node *p, const char *set, int type)
static size_t cmp_operator(const char **aliases, const char *input)
struct ccl_rpn_node * ccl_rpn_node_create(enum ccl_rpn_kind kind)
static int qual_val_type(ccl_qualifier_t *qa, int type, int value, char **attset)
static struct ccl_rpn_node * find_spec(CCL_parser cclp, ccl_qualifier_t *qa)
CCL header with private definitions.
ccl_qualifier_t ccl_qual_search(CCL_parser cclp, const char *name, size_t name_len, int seq)
const char * ccl_qual_get_name(ccl_qualifier_t q)
struct ccl_rpn_attr * ccl_qual_get_attr(ccl_qualifier_t q)
struct ccl_token * ccl_parser_tokenize(CCL_parser cclp, const char *command)
void ccl_token_del(struct ccl_token *list)
struct ccl_token * ccl_token_add(struct ccl_token *at)
const char ** ccl_qual_search_special(CCL_bibset b, const char *name)
CCL_parser ccl_parser_create(CCL_bibset bibset)
void ccl_parser_destroy(CCL_parser p)
static int node(struct cql_node *cn, void(*pr)(const char *buf, void *client_data), void *client_data)
struct ccl_token * look_token
attribute node (type, value) pair as used in RPN
char * str
string attribute value
int kind
attribute value type (numeric or string)
int numeric
numeric attribute value
int type
attribute type, Bib-1: 1=use, 2=relation, 3=position, etc
union ccl_rpn_attr::@7 value
struct ccl_rpn_attr * next
next attribute
struct ccl_rpn_node * p[3]
Boolean including proximity 0=left, 1=right, 2=prox parms.
struct ccl_rpn_node::@8::@9 t
Attributes + Term.
enum ccl_rpn_kind kind
node type, one of CCL_RPN_AND, CCL_RPN_OR, etc
const char * ws_prefix_buf
#define xstrdup(s)
utility macro which calls xstrdup_f
#define xfree(x)
utility macro which calls xfree_f
#define xmalloc(x)
utility macro which calls malloc_f