YAZ
5.34.0
|
Implements parsing of a CCL FIND query. More...
Go to the source code of this file.
Macros | |
#define | KIND (cclp->look_token->kind) |
#define | ADVANCE cclp->look_token = cclp->look_token->next |
#define | REGEX_CHARS "^[]{}()|.*+?!$" |
#define | CCL_CHARS "#?\\" |
Functions | |
static int | qual_val_type (ccl_qualifier_t *qa, int type, int value, char **attset) |
static void | strxcat (char *n, const char *src, int len) |
static char * | copy_token_name (struct ccl_token *tp) |
struct ccl_rpn_node * | ccl_rpn_node_create (enum ccl_rpn_kind kind) |
static struct ccl_rpn_node * | ccl_rpn_node_mkbool (struct ccl_rpn_node *l, struct ccl_rpn_node *r, enum ccl_rpn_kind op) |
void | ccl_rpn_delete (struct ccl_rpn_node *rpn) |
static struct ccl_rpn_node * | find_spec (CCL_parser cclp, ccl_qualifier_t *qa) |
static int | is_term_ok (int look, int *list) |
static struct ccl_rpn_node * | search_terms (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) |
void | ccl_add_attr_numeric (struct ccl_rpn_node *p, const char *set, int type, int value) |
void | ccl_set_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 size_t | cmp_operator (const char **aliases, const char *input) |
static int | has_ccl_masking (const char *src_str, size_t src_len, const char **truncation_aliases, const char **mask_aliases) |
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 * | 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 * | 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 * | 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 struct ccl_rpn_node * | search_term_x (CCL_parser cclp, ccl_qualifier_t *qa, int *term_list, int multi) |
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) |
static struct ccl_rpn_node * | qualifiers_order (CCL_parser cclp, ccl_qualifier_t *ap, char *attset) |
static struct ccl_rpn_node * | qualifier_relation (CCL_parser cclp, ccl_qualifier_t *ap) |
static struct ccl_rpn_node * | qualifier_list (CCL_parser cclp, struct ccl_token *la, ccl_qualifier_t *qa) |
static struct ccl_rpn_node * | search_elements (CCL_parser cclp, ccl_qualifier_t *qa) |
struct ccl_rpn_node * | ccl_parser_find_str (CCL_parser cclp, const char *str) |
parse CCL find string with parser and return RPN tree More... | |
struct ccl_rpn_node * | ccl_parser_find_token (CCL_parser cclp, struct ccl_token *list) |
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 More... | |
Implements parsing of a CCL FIND query.
This source file implements parsing of a CCL Query (ISO8777). The parser uses predictive parsing, but it does several tokens of lookahead in the handling of relational operations.. So it's not really pure.
Definition in file cclfind.c.
|
static |
Definition at line 191 of file cclfind.c.
References ccl_assert, ccl_rpn_attr::next, ccl_rpn_attr::set, ccl_rpn_node::t, type, ccl_rpn_attr::type, ccl_rpn_node::u, xmalloc, and xstrdup.
Referenced by ccl_add_attr_numeric(), and ccl_add_attr_string().
|
static |
Definition at line 292 of file cclfind.c.
References CCL_CHARS, CCL_ERR_TRUNC_NOT_EMBED, CCL_ERR_TRUNC_NOT_SINGLE, cmp_operator(), ccl_parser::error_code, REGEX_CHARS, and strxcat().
Referenced by ccl_term_one_use().
void ccl_add_attr_numeric | ( | struct ccl_rpn_node * | p, |
const char * | set, | ||
int | type, | ||
int | value | ||
) |
add_attr_numeric: Add attribute (type/value) to RPN term node. p: RPN node of type term. type: Type of attribute value: Value of attribute set: Attribute set name
Definition at line 213 of file cclfind.c.
References add_attr_node(), CCL_RPN_ATTR_NUMERIC, ccl_rpn_attr::kind, ccl_rpn_attr::numeric, ccl_rpn_attr::set, type, and ccl_rpn_attr::value.
Referenced by ccl_set_attr_numeric(), and ccl_term_one_use().
void ccl_add_attr_string | ( | struct ccl_rpn_node * | p, |
const char * | set, | ||
int | type, | ||
char * | value | ||
) |
Definition at line 239 of file cclfind.c.
References add_attr_node(), CCL_RPN_ATTR_STRING, ccl_rpn_attr::kind, ccl_rpn_attr::set, ccl_rpn_attr::str, type, ccl_rpn_attr::value, and xstrdup.
Referenced by ccl_term_one_use().
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
ccl_find_str: Parse CCL find - string representation bibset: Bibset to be used for the parsing str: String to be parsed error: Pointer to integer. Holds error no. on completion. pos: Pointer to char position. Holds approximate error position. return: RPN tree on successful completion; NULL otherwise.
Definition at line 1310 of file cclfind.c.
References ccl_parser_create(), ccl_parser_destroy(), ccl_parser_find_token(), ccl_parser_tokenize(), ccl_token_del(), ccl_parser::error_code, ccl_parser::error_pos, and ccl_rpn_node::p.
Referenced by ccl2pqf(), and ZOOM_query_ccl2rpn().
struct ccl_rpn_node* ccl_parser_find_str | ( | CCL_parser | cclp, |
const char * | str | ||
) |
parse CCL find string with parser and return RPN tree
Parses a CCL Find command in a simple C string. Returns CCL parse tree node describing RPN if parsing is successful. If parsing is unsuccesful, NULL is returned and error and pos is set accordingly.
Definition at line 1271 of file cclfind.c.
References ccl_parser_find_token(), ccl_parser_tokenize(), ccl_token_del(), and ccl_rpn_node::p.
struct ccl_rpn_node* ccl_parser_find_token | ( | CCL_parser | cclp, |
struct ccl_token * | list | ||
) |
Definition at line 1280 of file cclfind.c.
References CCL_ERR_BAD_RP, CCL_ERR_OK, CCL_ERR_OP_EXPECTED, ccl_rpn_delete(), CCL_TOK_EOL, CCL_TOK_RP, ccl_parser::error_code, ccl_parser::error_pos, find_spec(), KIND, ccl_parser::look_token, ccl_token::name, and ccl_rpn_node::p.
Referenced by ccl_find_str(), and ccl_parser_find_str().
void ccl_rpn_delete | ( | struct ccl_rpn_node * | rpn | ) |
ccl_rpn_delete: Delete RPN tree. rpn: Pointer to tree.
Definition at line 141 of file cclfind.c.
References CCL_RPN_AND, CCL_RPN_ATTR_STRING, CCL_RPN_NOT, CCL_RPN_OR, CCL_RPN_PROX, CCL_RPN_SET, CCL_RPN_TERM, ccl_rpn_attr::kind, ccl_rpn_node::kind, ccl_rpn_attr::next, ccl_rpn_node::p, ccl_rpn_attr::set, ccl_rpn_node::setname, ccl_rpn_attr::str, ccl_rpn_node::t, ccl_rpn_node::u, ccl_rpn_attr::value, and xfree.
Referenced by ccl_parser_find_token(), ccl_remove_stop_r(), ccl_term_multi_use(), ccl_term_one_use(), find_spec(), qualifier_list(), qualifiers_order(), search_elements(), search_terms(), search_terms2(), split_recur(), and ZOOM_query_ccl2rpn().
struct ccl_rpn_node* ccl_rpn_node_create | ( | enum ccl_rpn_kind | kind | ) |
mk_node: Create RPN node. kind: Type of node. return: pointer to allocated node.
Definition at line 100 of file cclfind.c.
References ccl_assert, CCL_RPN_TERM, ccl_rpn_node::kind, ccl_rpn_node::p, ccl_rpn_node::t, ccl_rpn_node::u, and xmalloc.
Referenced by ccl_rpn_node_mkbool(), ccl_term_one_use(), qualifiers_order(), search_elements(), and search_terms().
|
static |
Definition at line 120 of file cclfind.c.
References ccl_rpn_node_create(), ccl_rpn_node::p, and ccl_rpn_node::u.
Referenced by ccl_term_multi_use(), find_spec(), qualifier_list(), search_elements(), search_term_x(), and split_recur().
void ccl_set_attr_numeric | ( | struct ccl_rpn_node * | p, |
const char * | set, | ||
int | type, | ||
int | value | ||
) |
Definition at line 221 of file cclfind.c.
References ccl_add_attr_numeric(), CCL_RPN_ATTR_NUMERIC, CCL_RPN_ATTR_STRING, ccl_rpn_attr::kind, ccl_rpn_attr::next, ccl_rpn_attr::numeric, ccl_rpn_attr::set, ccl_rpn_attr::str, ccl_rpn_node::t, type, ccl_rpn_attr::type, ccl_rpn_node::u, ccl_rpn_attr::value, xfree, and xstrdup.
Referenced by qualifiers_order().
|
static |
Definition at line 554 of file cclfind.c.
References ccl_qual_get_attr(), ccl_rpn_delete(), ccl_rpn_node_mkbool(), CCL_RPN_OR, ccl_term_one_use(), ccl_rpn_attr::next, ccl_rpn_node::p, and ccl_rpn_attr::type.
Referenced by search_term_x(), and split_recur().
|
static |
Definition at line 362 of file cclfind.c.
References append_term(), ccl_parser::bibset, ccl_add_attr_numeric(), ccl_add_attr_string(), ccl_assert, CCL_BIB1_STR, CCL_BIB1_STR_WP, CCL_BIB1_TRU, CCL_BIB1_TRU_CAN_BOTH, CCL_BIB1_TRU_CAN_LEFT, CCL_BIB1_TRU_CAN_NONE, CCL_BIB1_TRU_CAN_REGEX, CCL_BIB1_TRU_CAN_RIGHT, CCL_BIB1_TRU_CAN_Z3958, CCL_ERR_TRUNC_NOT_BOTH, CCL_ERR_TRUNC_NOT_LEFT, CCL_ERR_TRUNC_NOT_RIGHT, ccl_qual_get_attr(), ccl_qual_get_name(), ccl_qual_search_special(), CCL_RPN_ATTR_NUMERIC, CCL_RPN_ATTR_STRING, ccl_rpn_delete(), ccl_rpn_node_create(), CCL_RPN_TERM, ccl_parser::error_code, has_ccl_masking(), ccl_rpn_attr::kind, ccl_token::len, ccl_token::name, ccl_token::next, ccl_rpn_attr::next, ccl_rpn_attr::numeric, ccl_rpn_node::p, qual_val_type(), ccl_rpn_attr::set, ccl_rpn_attr::str, strxcat(), ccl_rpn_node::t, ccl_rpn_attr::type, ccl_rpn_node::u, ccl_rpn_attr::value, ccl_token::ws_prefix_buf, ccl_token::ws_prefix_len, xmalloc, and xstrdup.
Referenced by ccl_term_multi_use().
|
static |
Definition at line 247 of file cclfind.c.
Referenced by append_term(), and has_ccl_masking().
|
static |
copy_token_name: Return copy of CCL token name tp: Pointer to token info. return: malloc(3) allocated copy of token name.
Definition at line 86 of file cclfind.c.
References ccl_assert, ccl_token::len, ccl_token::name, ccl_rpn_attr::str, and xmalloc.
Referenced by search_elements().
|
static |
find_spec: Parse CCL find specification cclp: CCL Parser qa: Qualifier attributes already applied. return: pointer to node(s); NULL on error.
Definition at line 1226 of file cclfind.c.
References ADVANCE, CCL_RPN_AND, ccl_rpn_delete(), ccl_rpn_node_mkbool(), CCL_RPN_NOT, CCL_RPN_OR, CCL_TOK_AND, CCL_TOK_NOT, CCL_TOK_OR, KIND, and search_elements().
Referenced by ccl_parser_find_token(), and search_terms2().
|
static |
Definition at line 265 of file cclfind.c.
References cmp_operator().
Referenced by ccl_term_one_use().
|
static |
Definition at line 181 of file cclfind.c.
Referenced by search_term_split_list(), search_term_x(), and search_terms().
|
static |
qual_val_type: test for existance of attribute type/value pair. qa: Attribute array type: Type of attribute to search for value: Value of attribute to seach for return: 1 if found; 0 otherwise.
Definition at line 37 of file cclfind.c.
References ccl_qual_get_attr(), CCL_RPN_ATTR_NUMERIC, ccl_rpn_attr::kind, ccl_rpn_attr::next, ccl_rpn_attr::numeric, ccl_rpn_attr::set, type, ccl_rpn_attr::type, and ccl_rpn_attr::value.
Referenced by ccl_term_one_use(), qualifier_relation(), qualifiers_order(), and search_term_x().
|
static |
qualifier_list: Parse CCL qualifiers and search terms. cclp: CCL Parser la: Token pointer to RELATION token. qa: Qualifier attributes already applied. return: pointer to node(s); NULL on error.
Definition at line 958 of file cclfind.c.
References ccl_parser::bibset, ccl_assert, CCL_ERR_DOUBLE_QUAL, CCL_ERR_UNKNOWN_QUAL, ccl_qual_search(), ccl_qual_search_special(), ccl_rpn_delete(), ccl_rpn_node_mkbool(), CCL_RPN_OR, CCL_TOK_COMMA, ccl_parser::error_code, ccl_token::kind, ccl_token::len, ccl_parser::look_token, ccl_token::name, ccl_token::next, node(), qualifier_relation(), xfree, and xmalloc.
Referenced by search_elements().
|
static |
Definition at line 933 of file cclfind.c.
References ADVANCE, CCL_BIB1_REL, CCL_BIB1_REL_ORDER, CCL_BIB1_REL_PORDER, CCL_ERR_EQ_EXPECTED, CCL_TOK_EQ, ccl_parser::error_code, KIND, qual_val_type(), qualifiers_order(), and search_terms().
Referenced by qualifier_list().
|
static |
Definition at line 774 of file cclfind.c.
References ADVANCE, CCL_BIB1_REL, CCL_BIB1_REL_OMIT_EQUALS, CCL_BIB1_REL_PORDER, CCL_ERR_BAD_RELATION, CCL_RPN_AND, ccl_rpn_delete(), ccl_rpn_node_create(), ccl_set_attr_numeric(), CCL_TOK_TERM, ccl_token_add(), ccl_parser::error_code, KIND, ccl_token::kind, ccl_token::len, ccl_parser::look_token, ccl_token::name, ccl_token::next, ccl_rpn_node::p, qual_val_type(), search_term(), search_terms(), and ccl_rpn_node::u.
Referenced by qualifier_relation().
|
static |
search_elements: Parse CCL search elements cclp: CCL Parser qa: Qualifier attributes already applied. return: pointer to node(s); NULL on error.
Definition at line 1156 of file cclfind.c.
References ADVANCE, CCL_ERR_SETNAME_EXPECTED, ccl_qual_search(), ccl_rpn_delete(), ccl_rpn_node_create(), ccl_rpn_node_mkbool(), CCL_RPN_OR, CCL_RPN_SET, CCL_TOK_COMMA, CCL_TOK_EQ, CCL_TOK_LP, CCL_TOK_REL, CCL_TOK_SET, CCL_TOK_TERM, copy_token_name(), ccl_parser::error_code, KIND, ccl_token::kind, ccl_parser::look_token, ccl_token::next, node(), qualifier_list(), search_terms(), ccl_rpn_node::setname, and ccl_rpn_node::u.
Referenced by find_spec().
|
static |
Definition at line 737 of file cclfind.c.
References CCL_TOK_COMMA, CCL_TOK_TERM, and search_term_x().
Referenced by qualifiers_order().
|
static |
Definition at line 623 of file cclfind.c.
References ADVANCE, CCL_ERR_TERM_EXPECTED, ccl_parser::error_code, is_term_ok(), ccl_token::kind, ccl_parser::look_token, ccl_token::next, ccl_rpn_node::p, split_recur(), xfree, and xmalloc.
Referenced by search_term_x().
|
static |
search_term: Parse CCL search term. cclp: CCL Parser qa: Qualifier attributes already applied. term_list: tokens we accept as terms in context multi: whether we accept "multiple" tokens return: pointer to node(s); NULL on error.
Definition at line 667 of file cclfind.c.
References ADVANCE, CCL_BIB1_STR, CCL_BIB1_STR_AND_LIST, CCL_BIB1_STR_AUTO_GROUP, CCL_BIB1_STR_OR_LIST, CCL_BIB1_STR_SPLIT_LIST, CCL_ERR_TERM_EXPECTED, CCL_RPN_AND, ccl_rpn_node_mkbool(), CCL_RPN_OR, ccl_term_multi_use(), CCL_TOK_COMMA, ccl_parser::error_code, is_term_ok(), ccl_token::kind, ccl_token::len, ccl_parser::look_token, ccl_token::name, ccl_token::next, ccl_rpn_node::p, qual_val_type(), and search_term_split_list().
Referenced by search_term(), and search_terms2().
|
static |
search_terms: Parse CCL search terms - including proximity. cclp: CCL Parser qa: Qualifier attributes already applied. return: pointer to node(s); NULL on error.
Definition at line 1094 of file cclfind.c.
References ADVANCE, ccl_rpn_delete(), ccl_rpn_node_create(), CCL_RPN_PROX, CCL_RPN_TERM, CCL_TOK_COMMA, CCL_TOK_EQ, CCL_TOK_PROX, CCL_TOK_REL, CCL_TOK_SET, CCL_TOK_TERM, is_term_ok(), KIND, ccl_token::len, ccl_parser::look_token, ccl_token::name, ccl_rpn_node::p, search_terms2(), ccl_rpn_node::t, ccl_rpn_node::u, and xmalloc.
Referenced by qualifier_relation(), qualifiers_order(), and search_elements().
|
static |
Definition at line 744 of file cclfind.c.
References ADVANCE, CCL_ERR_RP_EXPECTED, ccl_rpn_delete(), CCL_TOK_COMMA, CCL_TOK_EQ, CCL_TOK_LP, CCL_TOK_REL, CCL_TOK_RP, CCL_TOK_SET, CCL_TOK_TERM, ccl_parser::error_code, find_spec(), KIND, ccl_rpn_node::p, and search_term_x().
Referenced by search_terms().
|
static |
Definition at line 588 of file cclfind.c.
References CCL_RPN_AND, ccl_rpn_delete(), ccl_rpn_node_mkbool(), CCL_RPN_OR, and ccl_term_multi_use().
Referenced by search_term_split_list().
|
static |
strxcat: concatenate strings. n: Null-terminated Destination string src: Source string to be appended (not null-terminated) len: Length of source string.
Definition at line 72 of file cclfind.c.
Referenced by append_term(), and ccl_term_one_use().