/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2010 Index Data
+ * Copyright (C) 1995-2012 Index Data
* See the file LICENSE for details.
*/
/**
* \file ccltoken.c
* \brief Implements CCL lexical analyzer (scanner)
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <string.h>
#include <stdlib.h>
-#include <ctype.h>
-
+#include <yaz/yaz-iconv.h>
#include "cclp.h"
/*
case '%':
case '!':
last->kind = CCL_TOK_PROX;
- while (isdigit(*cp))
+ while (yaz_isdigit(*cp))
{
++ last->len;
cp++;
else
last->kind = CCL_TOK_REL;
break;
- case '\"':
+ default:
+ --cp;
+ --last->len;
+
last->kind = CCL_TOK_TERM;
last->name = (const char *) cp;
- last->len = 0;
- while (*cp && *cp != '\"')
- {
- cp++;
- ++ last->len;
- }
- if (*cp == '\"')
- cp++;
- break;
- default:
- if (!strchr("(),%!><= \t\n\r", cp[-1]))
+ while (*cp && !strchr("(),%!><= \t\n\r", *cp))
{
- while (*cp && !strchr("(),%!><= \t\n\r", *cp))
+ if (*cp == '\\' && cp[1])
{
cp++;
++ last->len;
}
+ else if (*cp == '"')
+ {
+ while (*cp)
+ {
+ cp++;
+ ++ last->len;
+ if (*cp == '\\' && cp[1])
+ {
+ cp++;
+ ++ last->len;
+ }
+ else if (*cp == '"')
+ break;
+ }
+ }
+ if (!*cp)
+ break;
+ cp++;
+ ++ last->len;
}
- 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;
}