|
YAZ
4.2.57
|
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) |
| 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_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 | 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, int is_first, int is_last, int *left_trunc, int *right_trunc) |
| 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 | |
| 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 | |
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.
| #define ADVANCE cclp->look_token = cclp->look_token->next |
Definition at line 28 of file cclfind.c.
Referenced by find_spec(), qualifier_relation(), qualifiers_order(), search_elements(), search_term_x(), search_terms(), and search_terms2().
| #define CCL_CHARS "#?\\" |
Definition at line 231 of file cclfind.c.
Referenced by append_term().
| #define KIND (cclp->look_token->kind) |
Definition at line 25 of file cclfind.c.
Referenced by ccl_parser_find_token(), find_spec(), qualifier_relation(), qualifiers_order(), search_elements(), search_terms(), and search_terms2().
| #define REGEX_CHARS "^[]{}()|.*+?!$" |
Definition at line 230 of file cclfind.c.
Referenced by append_term().
|
staticread |
Definition at line 170 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 232 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 search_term_x().
| 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 195 of file cclfind.c.
References add_attr_node(), CCL_RPN_ATTR_NUMERIC, ccl_rpn_attr::kind, ccl_rpn_attr::numeric, and ccl_rpn_attr::value.
Referenced by qualifiers_order(), and search_term_x().
| void ccl_add_attr_string | ( | struct ccl_rpn_node * | p, |
| const char * | set, | ||
| int | type, | ||
| char * | value | ||
| ) |
Definition at line 205 of file cclfind.c.
References add_attr_node(), CCL_RPN_ATTR_STRING, ccl_rpn_attr::kind, ccl_rpn_attr::str, ccl_rpn_attr::value, and xstrdup.
Referenced by search_term_x().
|
read |
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 1196 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().
|
read |
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 1155 of file cclfind.c.
References ccl_parser_find_token(), ccl_parser_tokenize(), ccl_token_del(), and ccl_rpn_node::p.
|
read |
Definition at line 1164 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 120 of file cclfind.c.
References CCL_RPN_AND, CCL_RPN_ATTR_STRING, ccl_rpn_delete(), 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_rpn_delete(), find_spec(), qualifier_list(), qualifiers_order(), search_elements(), search_term_x(), search_terms(), search_terms2(), and ZOOM_query_ccl2rpn().
|
read |
mk_node: Create RPN node. kind: Type of node. return: pointer to allocated node.
Definition at line 96 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 find_spec(), qualifier_list(), qualifiers_order(), search_elements(), search_term_x(), and search_terms().
|
static |
Definition at line 215 of file cclfind.c.
Referenced by append_term().
|
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 82 of file cclfind.c.
References ccl_assert, ccl_token::len, ccl_token::name, ccl_rpn_attr::str, and xmalloc.
Referenced by search_elements().
|
staticread |
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 1098 of file cclfind.c.
References ADVANCE, CCL_RPN_AND, ccl_rpn_delete(), ccl_rpn_node_create(), CCL_RPN_NOT, CCL_RPN_OR, CCL_TOK_AND, CCL_TOK_NOT, CCL_TOK_OR, KIND, ccl_rpn_node::p, search_elements(), and ccl_rpn_node::u.
Referenced by ccl_parser_find_token(), and search_terms2().
|
static |
Definition at line 160 of file cclfind.c.
Referenced by 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, ccl_rpn_attr::type, and ccl_rpn_attr::value.
Referenced by qualifier_relation(), qualifiers_order(), and search_term_x().
|
staticread |
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 802 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_create(), 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(), ccl_rpn_node::p, qualifier_relation(), ccl_rpn_node::u, xfree, and xmalloc.
Referenced by search_elements().
|
staticread |
Definition at line 777 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().
|
staticread |
Definition at line 624 of file cclfind.c.
References ADVANCE, ccl_add_attr_numeric(), CCL_BIB1_REL, CCL_BIB1_REL_PORDER, CCL_ERR_BAD_RELATION, CCL_ERR_TERM_EXPECTED, CCL_RPN_AND, ccl_rpn_delete(), ccl_rpn_node_create(), 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().
|
staticread |
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 1018 of file cclfind.c.
References ADVANCE, CCL_ERR_SETNAME_EXPECTED, ccl_qual_search(), ccl_rpn_delete(), ccl_rpn_node_create(), 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(), ccl_rpn_node::p, qualifier_list(), search_terms(), ccl_rpn_node::setname, and ccl_rpn_node::u.
Referenced by find_spec().
|
staticread |
Definition at line 586 of file cclfind.c.
References CCL_TOK_COMMA, CCL_TOK_TERM, and search_term_x().
Referenced by qualifiers_order().
|
staticread |
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 330 of file cclfind.c.
References ADVANCE, append_term(), ccl_parser::bibset, ccl_add_attr_numeric(), ccl_add_attr_string(), ccl_assert, CCL_BIB1_COM, CCL_BIB1_POS, CCL_BIB1_REL, CCL_BIB1_STR, CCL_BIB1_STR_AND_LIST, CCL_BIB1_STR_AUTO_GROUP, CCL_BIB1_STR_OR_LIST, 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_TERM_EXPECTED, 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_AND, CCL_RPN_ATTR_NUMERIC, CCL_RPN_ATTR_STRING, ccl_rpn_delete(), ccl_rpn_node_create(), CCL_RPN_OR, CCL_RPN_TERM, CCL_TOK_COMMA, ccl_parser::error_code, is_term_ok(), ccl_token::kind, ccl_rpn_attr::kind, ccl_token::len, ccl_parser::look_token, 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 search_term(), and search_terms2().
|
staticread |
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 956 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().
|
staticread |
Definition at line 593 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 |
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 68 of file cclfind.c.
Referenced by append_term(), and search_term_x().
1.8.1.2