X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fccltoken.c;h=a793f8bedf7510a04fe7d23f1842233814b6b3da;hp=79d6efc8d5f4840525ad210f1bff227de48943d3;hb=0f073baf2183a54f2a5691e697fde68c9a5f50c5;hpb=88d3bedf772316f87e1996f655ccf8d1e2589755 diff --git a/src/ccltoken.c b/src/ccltoken.c index 79d6efc..a793f8b 100644 --- a/src/ccltoken.c +++ b/src/ccltoken.c @@ -6,6 +6,9 @@ * \file ccltoken.c * \brief Implements CCL lexical analyzer (scanner) */ +#if HAVE_CONFIG_H +#include +#endif #include #include @@ -79,6 +82,7 @@ struct ccl_token *ccl_parser_tokenize(CCL_parser cclp, const char *command) last->next->prev = last; last = last->next; } + last->left_trunc = last->right_trunc = 0; last->ws_prefix_buf = (const char *) cp0; last->ws_prefix_len = cp - cp0; last->next = NULL; @@ -121,53 +125,66 @@ struct ccl_token *ccl_parser_tokenize(CCL_parser cclp, const char *command) else last->kind = CCL_TOK_REL; break; - case '\"': - last->kind = CCL_TOK_TERM; - last->name = (const char *) cp; - last->len = 0; - while (*cp && *cp != '\"') + default: + --cp; + --last->len; + if (*cp == '?') { + last->left_trunc = 1; cp++; - ++ last->len; } - if (*cp == '\"') - cp++; - break; - default: - if (!strchr("(),%!><= \t\n\r", cp[-1])) + if (*cp == '"') { - while (*cp && !strchr("(),%!><= \t\n\r", *cp)) + cp++; + last->kind = CCL_TOK_TERM; + last->name = (const char *) cp; + while (*cp && *cp != '"') { cp++; ++ last->len; } + if (*cp) + cp++; + } + else + { + last->kind = CCL_TOK_TERM; + last->name = (const char *) cp; + while (*cp && !strchr("(),%!><=? \t\n\r", *cp)) + { + ++ last->len; + cp++; + } + aliases = ccl_qual_search_special(cclp->bibset, "and"); + if (!aliases) + aliases = cclp->ccl_token_and; + if (token_cmp(cclp, aliases, last)) + last->kind = CCL_TOK_AND; + + aliases = ccl_qual_search_special(cclp->bibset, "or"); + if (!aliases) + aliases = cclp->ccl_token_or; + if (token_cmp(cclp, aliases, last)) + last->kind = CCL_TOK_OR; + + aliases = ccl_qual_search_special(cclp->bibset, "not"); + if (!aliases) + aliases = cclp->ccl_token_not; + if (token_cmp(cclp, aliases, last)) + last->kind = CCL_TOK_NOT; + + aliases = ccl_qual_search_special(cclp->bibset, "set"); + if (!aliases) + aliases = cclp->ccl_token_set; + + if (token_cmp(cclp, aliases, last)) + last->kind = CCL_TOK_SET; + } + if (*cp == '?') + { + last->right_trunc = 1; + cp++; } - last->kind = CCL_TOK_TERM; - - aliases = ccl_qual_search_special(cclp->bibset, "and"); - if (!aliases) - aliases = cclp->ccl_token_and; - if (token_cmp(cclp, aliases, last)) - last->kind = CCL_TOK_AND; - - aliases = ccl_qual_search_special(cclp->bibset, "or"); - if (!aliases) - aliases = cclp->ccl_token_or; - if (token_cmp(cclp, aliases, last)) - last->kind = CCL_TOK_OR; - - aliases = ccl_qual_search_special(cclp->bibset, "not"); - if (!aliases) - aliases = cclp->ccl_token_not; - if (token_cmp(cclp, aliases, last)) - last->kind = CCL_TOK_NOT; - - aliases = ccl_qual_search_special(cclp->bibset, "set"); - if (!aliases) - aliases = cclp->ccl_token_set; - - if (token_cmp(cclp, aliases, last)) - last->kind = CCL_TOK_SET; } } return first; @@ -184,6 +201,7 @@ struct ccl_token *ccl_token_add(struct ccl_token *at) n->next->prev = n; n->kind = CCL_TOK_TERM; + n->left_trunc = n->right_trunc = 0; n->name = 0; n->len = 0; n->ws_prefix_buf = 0;