cclfind.c File Reference

Implements parsing of a CCL FIND query. More...

#include <stdlib.h>
#include <string.h>
#include "cclp.h"
#include <yaz/ccl.h>

Go to the source code of this file.

Defines

#define KIND   (cclp->look_token->kind)
#define ADVANCE   cclp->look_token = cclp->look_token->next

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_nodeccl_rpn_node_create (enum ccl_rpn_kind kind)
void ccl_rpn_delete (struct ccl_rpn_node *rpn)
static struct ccl_rpn_nodefind_spec (CCL_parser cclp, ccl_qualifier_t *qa)
static int is_term_ok (int look, int *list)
static struct ccl_rpn_nodesearch_terms (CCL_parser cclp, ccl_qualifier_t *qa)
static struct ccl_rpn_attradd_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 struct ccl_rpn_nodesearch_term_x (CCL_parser cclp, ccl_qualifier_t *qa, int *term_list, int multi)
static struct ccl_rpn_nodesearch_term (CCL_parser cclp, ccl_qualifier_t *qa)
static struct ccl_rpn_nodequalifiers_order (CCL_parser cclp, ccl_qualifier_t *ap, char *attset)
static struct ccl_rpn_nodequalifier_relation (CCL_parser cclp, ccl_qualifier_t *ap)
static struct ccl_rpn_nodequalifier_list (CCL_parser cclp, struct ccl_token *la, ccl_qualifier_t *qa)
static struct ccl_rpn_nodesearch_elements (CCL_parser cclp, ccl_qualifier_t *qa)
struct ccl_rpn_nodeccl_parser_find_str (CCL_parser cclp, const char *str)
 parse CCL find string with parser and return RPN tree
struct ccl_rpn_nodeccl_parser_find_token (CCL_parser cclp, struct ccl_token *list)
struct ccl_rpn_nodeccl_find_str (CCL_bibset bibset, const char *str, int *error, int *pos)
 parse CCL find string using CCL profile return RPN tree

Detailed Description

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 Documentation

#define ADVANCE   cclp->look_token = cclp->look_token->next
#define KIND   (cclp->look_token->kind)

Function Documentation

static struct ccl_rpn_attr* add_attr_node ( struct ccl_rpn_node p,
const char *  set,
int  type 
) [static, read]
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 191 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 
)
struct ccl_rpn_node* ccl_find_str ( CCL_bibset  bibset,
const char *  str,
int *  error,
int *  pos 
) [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 1070 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 
) [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 1029 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 
) [read]
void ccl_rpn_delete ( struct ccl_rpn_node rpn  ) 
struct ccl_rpn_node* ccl_rpn_node_create ( enum ccl_rpn_kind  kind  )  [read]

mk_node: Create RPN node. kind: Type of node. return: pointer to allocated node.

Definition at line 92 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 char* copy_token_name ( struct ccl_token tp  )  [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 78 of file cclfind.c.

References ccl_assert, ccl_token::len, ccl_token::name, ccl_rpn_attr::str, and xmalloc.

Referenced by search_elements().

static struct ccl_rpn_node * find_spec ( CCL_parser  cclp,
ccl_qualifier_t qa 
) [static, read]

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 972 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(), qualifier_relation(), qualifiers_order(), and search_elements().

static int is_term_ok ( int  look,
int *  list 
) [static]

Definition at line 156 of file cclfind.c.

Referenced by search_term_x(), and search_terms().

static int qual_val_type ( ccl_qualifier_t qa,
int  type,
int  value,
char **  attset 
) [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 33 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().

static struct ccl_rpn_node* qualifier_list ( CCL_parser  cclp,
struct ccl_token la,
ccl_qualifier_t qa 
) [static, read]

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 662 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, ccl_rpn_node::p, qualifier_relation(), ccl_rpn_node::u, xfree, and xmalloc.

Referenced by search_elements().

static struct ccl_rpn_node* qualifier_relation ( CCL_parser  cclp,
ccl_qualifier_t ap 
) [static, read]
static struct ccl_rpn_node* qualifiers_order ( CCL_parser  cclp,
ccl_qualifier_t ap,
char *  attset 
) [static, read]
static struct ccl_rpn_node* search_elements ( CCL_parser  cclp,
ccl_qualifier_t qa 
) [static, read]
static struct ccl_rpn_node* search_term ( CCL_parser  cclp,
ccl_qualifier_t qa 
) [static, read]

Definition at line 445 of file cclfind.c.

References CCL_TOK_COMMA, CCL_TOK_TERM, and search_term_x().

Referenced by qualifiers_order().

static struct ccl_rpn_node* search_term_x ( CCL_parser  cclp,
ccl_qualifier_t qa,
int *  term_list,
int  multi 
) [static, read]
static struct ccl_rpn_node * search_terms ( CCL_parser  cclp,
ccl_qualifier_t qa 
) [static, read]

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 816 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_term_x(), ccl_rpn_node::t, ccl_rpn_node::u, and xmalloc.

Referenced by qualifier_relation(), qualifiers_order(), and search_elements().

static void strxcat ( char *  n,
const char *  src,
int  len 
) [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 64 of file cclfind.c.

Referenced by search_term_x().

Generated on Tue Aug 17 13:13:19 2010 for YAZ by  doxygen 1.6.3