From: Adam Dickmeiss Date: Wed, 10 Mar 2004 16:34:29 +0000 (+0000) Subject: Update CQL parser to use CQL 1.1 modifiers for booleans and X-Git-Tag: YAZ.2.0.16.debian.1~17 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=42f18e58ed67f77727cde23bcee44dbd32ed242a;p=yaz-moved-to-github.git Update CQL parser to use CQL 1.1 modifiers for booleans and relations. Add CQL regression cases. --- diff --git a/CHANGELOG b/CHANGELOG index 0c22fbe..1d882b4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,10 @@ Possible compatibility problems with earlier versions marked with '*'. +Update CQL parser to use new CQL 1.1 modifiers for booleans and +relations. + +Add CQL test cases. + --- 2.0.15 2004/03/01 Another fix for decoding of XML packed records. diff --git a/Makefile.am b/Makefile.am index f54ec43..8b7416f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,10 +1,10 @@ ## Copyright (C) 1994-2003, Index Data ## All rights reserved. -## $Id: Makefile.am,v 1.24 2004-02-09 12:38:57 adam Exp $ +## $Id: Makefile.am,v 1.25 2004-03-10 16:34:29 adam Exp $ AUTOMAKE_OPTIONS = foreign -SUBDIRS = src include test util client ztest zoom doc etc +SUBDIRS = src include util test client ztest zoom doc etc aclocaldir=$(datadir)/aclocal diff --git a/include/yaz/cql.h b/include/yaz/cql.h index b9b5f4d..6d6782c 100644 --- a/include/yaz/cql.h +++ b/include/yaz/cql.h @@ -1,5 +1,5 @@ -/* $Id: cql.h,v 1.5 2003-12-16 14:36:28 adam Exp $ - Copyright (C) 2002-2003 +/* $Id: cql.h,v 1.6 2004-03-10 16:34:29 adam Exp $ + Copyright (C) 2002-2004 Index Data Aps This file is part of the YAZ toolkit. @@ -100,11 +100,6 @@ struct cql_node { struct cql_node *modifiers; struct cql_node *prefixes; } boolean; - struct { - char *name; - char *value; - struct cql_node *next; - } mod; } u; }; @@ -134,10 +129,6 @@ struct cql_node *cql_node_prefix(struct cql_node *n, const char *prefix, const char *uri); YAZ_EXPORT -struct cql_node *cql_node_mk_mod(const char *name, - const char *value); - -YAZ_EXPORT struct cql_node *cql_node_dup (struct cql_node *cp); YAZ_EXPORT struct cql_node *cql_parser_result(CQL_parser cp); diff --git a/src/Makefile.am b/src/Makefile.am index 8964796..9f3052d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ ## Copyright (C) 1994-2003, Index Data ## All rights reserved. -## $Id: Makefile.am,v 1.6 2004-02-09 09:54:58 adam Exp $ +## $Id: Makefile.am,v 1.7 2004-03-10 16:34:29 adam Exp $ if ISTHR thrlib=libyazthread.la @@ -60,7 +60,7 @@ libyaz_la_SOURCES=version.c options.c log.c marcdisp.c oid.c wrbuf.c \ opacdisp.c cclfind.c ccltoken.c cclerrms.c cclqual.c cclptree.c \ cclqfile.c cclstr.c \ cql.y cqlstdio.c cqltransform.c cqlutil.c xcqlutil.c cqlstring.c \ - cqlstrer.c lexer.h \ + cqlstrer.c \ eventl.c seshigh.c statserv.c requestq.c tcpdchk.c \ eventl.h service.c service.h session.h libyaz_la_LDFLAGS=-version-info $(YAZ_VERSION_INFO) diff --git a/src/cql.y b/src/cql.y index c98696d..0a81738 100644 --- a/src/cql.y +++ b/src/cql.y @@ -1,5 +1,5 @@ -/* $Id: cql.y,v 1.1 2003-10-27 12:21:30 adam Exp $ - Copyright (C) 2002-2003 +/* $Id: cql.y,v 1.2 2004-03-10 16:34:29 adam Exp $ + Copyright (C) 2002-2004 Index Data Aps This file is part of the YAZ toolkit. @@ -45,12 +45,12 @@ See the file LICENSE. %pure_parser %token TERM AND OR NOT PROX GE LE NE -%expect 8 +%expect 9 %% top: { - $$.rel = cql_node_mk_sc("srw.serverChoice", "scr", 0); + $$.rel = cql_node_mk_sc("cql.serverChoice", "scr", 0); ((CQL_parser) parm)->top = 0; } cqlQuery1 { cql_node_destroy($$.rel); @@ -68,14 +68,14 @@ cqlQuery1: cqlQuery cqlQuery: searchClause | - cqlQuery boolean { - $$.rel = $0.rel; + cqlQuery boolean modifiers { + $$.rel = $0.rel; } searchClause { struct cql_node *cn = cql_node_mk_boolean($2.buf); - cn->u.boolean.modifiers = $2.rel; + cn->u.boolean.modifiers = $3.cql; cn->u.boolean.left = $1.cql; - cn->u.boolean.right = $4.cql; + cn->u.boolean.right = $5.cql; $$.cql = cn; } @@ -95,12 +95,12 @@ searchClause: $$.cql = st; } | - index relation { - $$.rel = $2.rel; - $$.rel->u.st.index = strdup($1.buf); + index relation modifiers { + $$.rel = cql_node_mk_sc($1.buf, $2.buf, 0); + $$.rel->u.st.modifiers = $3.cql; } searchClause { - $$.cql = $4.cql; - cql_node_destroy($2.rel); + $$.cql = $5.cql; + cql_node_destroy($4.rel); } | '>' searchTerm '=' searchTerm { $$.rel = $0.rel; @@ -117,91 +117,40 @@ searchClause: /* unary NOT search TERM here .. */ boolean: - AND | OR | NOT | PROX proxqualifiers { - $$ = $1; - $$.rel = $2.rel; - } + AND | OR | NOT | PROX ; -proxqualifiers: - Prelation { - $$.rel = cql_node_mk_proxargs ($1.buf, 0, 0, 0); - } -| - PrelationO Pdistance { - $$.rel = cql_node_mk_proxargs ($1.buf, $2.buf, 0, 0); - } -| - PrelationO PdistanceO Punit { - $$.rel = cql_node_mk_proxargs ($1.buf, $2.buf, $3.buf, 0); - } -| - PrelationO PdistanceO PunitO Pordering { - $$.rel = cql_node_mk_proxargs ($1.buf, $2.buf, $3.buf, $4.buf); - } -| -{ $$.rel = 0; } -; - -Punit: '/' searchTerm { - $$ = $2; - } -; - -PunitO: '/' searchTerm { - $$ = $2; - } -| -'/' { $$.buf[0] = 0; } -; -Prelation: '/' baseRelation { - $$ = $2; -} -; -PrelationO: '/' baseRelation { - $$ = $2; -} -| '/' { $$.buf[0] = 0; } -; -Pdistance: '/' searchTerm { - $$ = $2; -} -; - -PdistanceO: '/' searchTerm { - $$ = $2; -} -| '/' { $$.buf[0] = 0; } -; -Pordering: '/' searchTerm { - $$ = $2; -} -; - -relation: baseRelation modifiers { - struct cql_node *st = cql_node_mk_sc(/* index */ 0, - /* relation */ $1.buf, - /* term */ 0); +modifiers: modifiers '/' searchTerm +{ + struct cql_node *mod = cql_node_mk_sc($3.buf, "=", 0); - st->u.st.modifiers = $2.cql; - $$.rel = st; + mod->u.st.modifiers = $1.cql; + $$.cql = mod; } -; - -modifiers: '/' searchTerm modifiers -{ - struct cql_node *mod = cql_node_mk_mod(0, $2.buf); +| +modifiers '/' searchTerm mrelation searchTerm +{ + struct cql_node *mod = cql_node_mk_sc($3.buf, $4.buf, $5.buf); - mod->u.mod.next = $3.cql; + mod->u.st.modifiers = $1.cql; $$.cql = mod; } -| +| { $$.cql = 0; } ; -baseRelation: +mrelation: + '=' +| '>' +| '<' +| GE +| LE +| NE +; + +relation: '=' | '>' | '<' @@ -229,7 +178,111 @@ int yyerror(char *s) return 0; } -#include "lexer.h" +/* + * bison lexer for CQL. + */ + +static void putb(YYSTYPE *lval, CQL_parser cp, int c) +{ + if (lval->len+1 >= lval->size) + { + char *nb = nmem_malloc(cp->nmem, (lval->size = lval->len * 2 + 20)); + memcpy (nb, lval->buf, lval->len); + lval->buf = nb; + } + if (c) + lval->buf[lval->len++] = c; + lval->buf[lval->len] = '\0'; +} + + +int yylex(YYSTYPE *lval, void *vp) +{ + CQL_parser cp = (CQL_parser) vp; + int c; + lval->cql = 0; + lval->rel = 0; + lval->len = 0; + lval->size = 10; + lval->buf = nmem_malloc(cp->nmem, lval->size); + lval->buf[0] = '\0'; + do + { + c = cp->getbyte(cp->client_data); + if (c == 0) + return 0; + if (c == '\n') + return 0; + } while (isspace(c)); + if (strchr("()=>') + { + c1 = cp->getbyte(cp->client_data); + if (c1 == '=') + { + putb(lval, cp, c1); + return GE; + } + else + cp->ungetbyte(c1, cp->client_data); + } + else if (c == '<') + { + c1 = cp->getbyte(cp->client_data); + if (c1 == '=') + { + putb(lval, cp, c1); + return LE; + } + else if (c1 == '>') + { + putb(lval, cp, c1); + return NE; + } + else + cp->ungetbyte(c1, cp->client_data); + } + return c; + } + if (c == '"') + { + while ((c = cp->getbyte(cp->client_data)) != EOF && c != '"') + { + if (c == '\\') + c = cp->getbyte(cp->client_data); + putb(lval, cp, c); + } + putb(lval, cp, 0); + } + else + { + putb(lval, cp, c); + while ((c = cp->getbyte(cp->client_data)) != 0 && + !strchr(" \n()=<>/", c)) + { + if (c == '\\') + c = cp->getbyte(cp->client_data); + putb(lval, cp, c); + } +#if YYDEBUG + printf ("got %s\n", lval->buf); +#endif + if (c != 0) + cp->ungetbyte(c, cp->client_data); + if (!strcmp(lval->buf, "and")) + return AND; + if (!strcmp(lval->buf, "or")) + return OR; + if (!strcmp(lval->buf, "not")) + return NOT; + if (!strncmp(lval->buf, "prox", 4)) + return PROX; + } + return TERM; +} int cql_parser_stream(CQL_parser cp, @@ -237,6 +290,7 @@ int cql_parser_stream(CQL_parser cp, void (*ungetbyte)(int b, void *client_data), void *client_data) { + nmem_reset(cp->nmem); cp->getbyte = getbyte; cp->ungetbyte = ungetbyte; cp->client_data = client_data; diff --git a/src/cqltransform.c b/src/cqltransform.c index 22f3fe5..52cb21f 100644 --- a/src/cqltransform.c +++ b/src/cqltransform.c @@ -1,4 +1,4 @@ -/* $Id: cqltransform.c,v 1.6 2003-12-19 12:16:19 mike Exp $ +/* $Id: cqltransform.c,v 1.7 2004-03-10 16:34:29 adam Exp $ Copyright (C) 2002-2003 Index Data Aps @@ -172,7 +172,10 @@ int cql_pr_attr(cql_transform_t ct, const char *category, if (errcode && !ct->error) { ct->error = errcode; - ct->addinfo = strdup(val); + if (val) + ct->addinfo = strdup(val); + else + ct->addinfo = 0; } return 0; } @@ -369,17 +372,17 @@ static const char *cql_get_ns(cql_transform_t ct, for (i = prefix_level; !ns && --i >= 0; ) { struct cql_node *cn_prefix = prefix_ar[i]; - for (; cn_prefix; cn_prefix = cn_prefix->u.mod.next) + for (; cn_prefix; cn_prefix = cn_prefix->u.st.modifiers) { - if (*prefix && cn_prefix->u.mod.name && - !strcmp(prefix, cn_prefix->u.mod.name)) + if (*prefix && cn_prefix->u.st.index && + !strcmp(prefix, cn_prefix->u.st.index)) { - ns = cn_prefix->u.mod.value; + ns = cn_prefix->u.st.term; break; } - else if (!*prefix && !cn_prefix->u.mod.name) + else if (!*prefix && !cn_prefix->u.st.index) { - ns = cn_prefix->u.mod.value; + ns = cn_prefix->u.st.term; break; } } @@ -469,9 +472,9 @@ void cql_transform_r(cql_transform_t ct, if (cn->u.st.modifiers) { struct cql_node *mod = cn->u.st.modifiers; - for (; mod; mod = mod->u.mod.next) + for (; mod; mod = mod->u.st.modifiers) { - cql_pr_attr(ct, "relationModifier.", mod->u.mod.value, 0, + cql_pr_attr(ct, "relationModifier.", mod->u.st.term, 0, pr, client_data, 20); } } @@ -524,13 +527,13 @@ int cql_transform(cql_transform_t ct, { if (!memcmp(e->pattern, "set.", 4)) { - *pp = cql_node_mk_mod(e->pattern+4, e->value); - pp = &(*pp)->u.mod.next; + *pp = cql_node_mk_sc(e->pattern+4, "=", e->value); + pp = &(*pp)->u.st.modifiers; } else if (!strcmp(e->pattern, "set")) { - *pp = cql_node_mk_mod(0, e->value); - pp = &(*pp)->u.mod.next; + *pp = cql_node_mk_sc(e->value, 0, 0); + pp = &(*pp)->u.st.modifiers; } } cql_transform_r (ct, cn, pr, client_data, prefix_ar, 1); diff --git a/src/cqlutil.c b/src/cqlutil.c index baa54ad..1b842b1 100644 --- a/src/cqlutil.c +++ b/src/cqlutil.c @@ -1,5 +1,5 @@ -/* $Id: cqlutil.c,v 1.1 2003-10-27 12:21:30 adam Exp $ - Copyright (C) 2002-2003 +/* $Id: cqlutil.c,v 1.2 2004-03-10 16:34:29 adam Exp $ + Copyright (C) 2002-2004 Index Data Aps This file is part of the YAZ toolkit. @@ -33,11 +33,6 @@ struct cql_node *cql_node_dup (struct cql_node *cp) cn->u.st.modifiers = cql_node_dup(cp->u.st.modifiers); cn->u.st.prefixes = cql_node_dup(cp->u.st.prefixes); break; - case CQL_NODE_MOD: - cn = cql_node_mk_mod(cp->u.mod.name, - cp->u.mod.value); - cn->u.mod.next = cql_node_dup(cp->u.mod.next); - break; case CQL_NODE_BOOL: cn = cql_node_mk_boolean(cp->u.boolean.value); cn->u.boolean.left = cql_node_dup(cp->u.boolean.left); @@ -67,22 +62,6 @@ struct cql_node *cql_node_mk_sc(const char *index, return p; } -struct cql_node *cql_node_mk_mod(const char *name, - const char *value) -{ - struct cql_node *p = (struct cql_node *) malloc(sizeof(*p)); - p->which = CQL_NODE_MOD; - - p->u.mod.name = 0; - if (name) - p->u.mod.name = strdup(name); - p->u.mod.value = 0; - if (value) - p->u.mod.value = strdup(value); - p->u.mod.next = 0; - return p; -} - struct cql_node *cql_node_mk_boolean(const char *op) { struct cql_node *p = (struct cql_node *) malloc(sizeof(*p)); @@ -111,43 +90,13 @@ struct cql_node *cql_node_prefix(struct cql_node *n, const char *prefix, } if (cpp) { - struct cql_node *cp = cql_node_mk_mod(prefix, uri); - cp->u.mod.next = *cpp; + struct cql_node *cp = cql_node_mk_sc(prefix, "=", uri); + cp->u.st.modifiers = *cpp; *cpp = cp; } return n; } -struct cql_node *cql_node_mk_proxargs(const char *relation, - const char *distance, - const char *unit, - const char *ordering) -{ - struct cql_node *m = 0, *m1; - - if (ordering && *ordering) - m = cql_node_mk_mod("ordering", ordering); - if (unit && *unit) - { - m1 = cql_node_mk_mod("unit", unit); - m1->u.mod.next = m; - m = m1; - } - if (distance && *distance) - { - m1 = cql_node_mk_mod("distance", distance); - m1->u.mod.next = m; - m = m1; - } - if (relation && *relation) - { - m1 = cql_node_mk_mod("relation", relation); - m1->u.mod.next = m; - m = m1; - } - return m; -} - void cql_node_destroy(struct cql_node *cn) { if (!cn) @@ -161,16 +110,12 @@ void cql_node_destroy(struct cql_node *cn) cql_node_destroy(cn->u.st.modifiers); cql_node_destroy(cn->u.st.prefixes); break; - case CQL_NODE_MOD: - free (cn->u.mod.name); - free (cn->u.mod.value); - cql_node_destroy(cn->u.mod.next); - break; case CQL_NODE_BOOL: free (cn->u.boolean.value); cql_node_destroy(cn->u.boolean.left); cql_node_destroy(cn->u.boolean.right); cql_node_destroy(cn->u.boolean.prefixes); + cql_node_destroy(cn->u.boolean.modifiers); } free (cn); } diff --git a/src/lexer.h b/src/lexer.h deleted file mode 100644 index 6c8a3b4..0000000 --- a/src/lexer.h +++ /dev/null @@ -1,113 +0,0 @@ -/* $Id: lexer.h,v 1.1 2003-10-27 12:21:30 adam Exp $ - Copyright (C) 2002-2003 - Index Data Aps - -This file is part of the YAZ toolkit. - -See the file LICENSE. -*/ - -static void putb(YYSTYPE *lval, CQL_parser cp, int c) -{ - if (lval->len+1 >= lval->size) - { - char *nb = nmem_malloc(cp->nmem, (lval->size = lval->len * 2 + 20)); - memcpy (nb, lval->buf, lval->len); - lval->buf = nb; - } - if (c) - lval->buf[lval->len++] = c; - lval->buf[lval->len] = '\0'; -} - -/* - * bison lexer for CQL. - */ - -int yylex(YYSTYPE *lval, void *vp) -{ - CQL_parser cp = (CQL_parser) vp; - int c; - lval->cql = 0; - lval->rel = 0; - lval->len = 0; - lval->size = 10; - lval->buf = nmem_malloc(cp->nmem, lval->size); - lval->buf[0] = '\0'; - do - { - c = cp->getbyte(cp->client_data); - if (c == 0) - return 0; - if (c == '\n') - return 0; - } while (isspace(c)); - if (strchr("()=>') - { - c1 = cp->getbyte(cp->client_data); - if (c1 == '=') - { - putb(lval, cp, c1); - return GE; - } - else - cp->ungetbyte(c1, cp->client_data); - } - else if (c == '<') - { - c1 = cp->getbyte(cp->client_data); - if (c1 == '=') - { - putb(lval, cp, c1); - return LE; - } - else if (c1 == '>') - { - putb(lval, cp, c1); - return NE; - } - else - cp->ungetbyte(c1, cp->client_data); - } - return c; - } - if (c == '"') - { - while ((c = cp->getbyte(cp->client_data)) != EOF && c != '"') - { - if (c == '\\') - c = cp->getbyte(cp->client_data); - putb(lval, cp, c); - } - putb(lval, cp, 0); - } - else - { - putb(lval, cp, c); - while ((c = cp->getbyte(cp->client_data)) != 0 && - !strchr(" \n()=<>/", c)) - { - if (c == '\\') - c = cp->getbyte(cp->client_data); - putb(lval, cp, c); - } -#if YYDEBUG - printf ("got %s\n", lval->buf); -#endif - if (c != 0) - cp->ungetbyte(c, cp->client_data); - if (!strcmp(lval->buf, "and")) - return AND; - if (!strcmp(lval->buf, "or")) - return OR; - if (!strcmp(lval->buf, "not")) - return NOT; - if (!strncmp(lval->buf, "prox", 4)) - return PROX; - } - return TERM; -} diff --git a/src/xcqlutil.c b/src/xcqlutil.c index 9c38de1..b884b6e 100644 --- a/src/xcqlutil.c +++ b/src/xcqlutil.c @@ -1,5 +1,5 @@ -/* $Id: xcqlutil.c,v 1.1 2003-10-27 12:21:36 adam Exp $ - Copyright (C) 2002-2003 +/* $Id: xcqlutil.c,v 1.2 2004-03-10 16:34:29 adam Exp $ + Copyright (C) 2002-2004 Index Data Aps This file is part of the YAZ toolkit. @@ -57,19 +57,19 @@ static void prefixes(struct cql_node *cn, if (cn) { pr_n("\n", pr, client_data, level); - for (; cn; cn = cn->u.mod.next) + for (; cn; cn = cn->u.st.modifiers) { pr_n("\n", pr, client_data, level+2); - if (cn->u.mod.name) + if (cn->u.st.index) { pr_n("", pr, client_data, level+4); - pr_cdata(cn->u.mod.name, pr, client_data); + pr_cdata(cn->u.st.index, pr, client_data); pr_n("\n", pr, client_data, 0); } - if (cn->u.mod.value) + if (cn->u.st.term) { pr_n("", pr, client_data, level+4); - pr_cdata(cn->u.mod.value, pr, client_data); + pr_cdata(cn->u.st.term, pr, client_data); pr_n("\n", pr, client_data, 0); } pr_n("\n", pr, client_data, level+2); @@ -78,6 +78,37 @@ static void prefixes(struct cql_node *cn, } } +static void cql_to_xml_mod(struct cql_node *m, + void (*pr)(const char *buf, void *client_data), + void *client_data, int level) +{ + if (m) + { + pr_n("\n", pr, client_data, level); + for (; m; m = m->u.st.modifiers) + { + pr_n("\n", pr, client_data, level+2); + pr_n("", pr, client_data, level+4); + pr_cdata(m->u.st.index, pr, client_data); + pr_n("\n", pr, client_data, 0); + if (m->u.st.relation) + { + pr_n("", pr, client_data, level+4); + pr_cdata(m->u.st.relation, pr, client_data); + pr_n("\n", pr, client_data, 0); + } + if (m->u.st.term) + { + pr_n("", pr, client_data, level+4); + pr_cdata(m->u.st.term, pr, client_data); + pr_n("\n", pr, client_data, 0); + } + pr_n("\n", pr, client_data, level+2); + } + pr_n("\n", pr, client_data, level); + } +} + static void cql_to_xml_r(struct cql_node *cn, void (*pr)(const char *buf, void *client_data), void *client_data, int level) @@ -97,22 +128,14 @@ static void cql_to_xml_r(struct cql_node *cn, } if (cn->u.st.relation) { - struct cql_node *m = cn->u.st.modifiers; pr_n("\n", pr, client_data, level+2); pr_n("", pr, client_data, level+4); pr_cdata(cn->u.st.relation, pr, client_data); pr_n("\n", pr, client_data, 0); - if (m) - { - pr_n("\n", pr, client_data, level+4); - for (; m; m = m->u.mod.next) - { - pr_n("", pr, client_data, level+6); - pr_cdata(m->u.mod.value, pr, client_data); - pr_n("\n", pr, client_data, 0); - } - pr_n("\n", pr, client_data, level+4); - } + + cql_to_xml_mod(cn->u.st.modifiers, + pr, client_data, level+4); + pr_n("\n", pr, client_data, level+2); } if (cn->u.st.term) @@ -128,31 +151,15 @@ static void cql_to_xml_r(struct cql_node *cn, prefixes(cn->u.st.prefixes, pr, client_data, level+2); if (cn->u.boolean.value) { - struct cql_node *m = cn->u.boolean.modifiers; pr_n("\n", pr, client_data, level+2); pr_n("", pr, client_data, level+4); pr_cdata(cn->u.boolean.value, pr, client_data); pr_n("\n", pr, client_data, 0); - if (m) - { - pr_n("\n", pr, client_data, level+4); - for (; m; m = m->u.mod.next) - { - pr_n("", pr, client_data, level+6); - pr_cdata(m->u.mod.name, pr, client_data); - pr_n("", pr, client_data, 0); - if (m->u.mod.value) - { - pr_n("", pr, client_data, 0); - pr_cdata(m->u.mod.value, pr, client_data); - pr_n("", pr, client_data, 0); - } - pr_n("\n", pr, client_data, 0); - } - pr_n("\n", pr, client_data, level+4); - } + cql_to_xml_mod(cn->u.boolean.modifiers, + pr, client_data, level+4); + pr_n("\n", pr, client_data, level+2); } if (cn->u.boolean.left) diff --git a/test/Makefile.am b/test/Makefile.am index 02f7e07..8dda4f6 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,18 +1,24 @@ -## Copyright (C) 1994-2003, Index Data +## Copyright (C) 1994-2004, Index Data ## All rights reserved. -## $Id: Makefile.am,v 1.1 2003-10-27 12:21:38 adam Exp $ +## $Id: Makefile.am,v 1.2 2004-03-10 16:34:30 adam Exp $ check_PROGRAMS = tsticonv tstnmem tstmatchstr tstwrbuf tstodr tstccl +check_SCRIPTS = tstcql.sh -TESTS = $(check_PROGRAMS) +TESTS = $(check_PROGRAMS) $(check_SCRIPTS) -EXTRA_DIST = tstodr.asn tstodrcodec.c tstodrcodec.h +EXTRA_DIST = tstodr.asn tstodrcodec.c tstodrcodec.h cqlsample $(check_SCRIPTS) YAZCOMP = $(top_srcdir)/util/yaz-asncomp YAZCOMPLINE = $(YAZCOMP) -d z.tcl -i yaz -I../include $(YCFLAGS) AM_CPPFLAGS=-I$(top_srcdir)/include $(XML2_CFLAGS) +dist-hook: + mkdir -p $(distdir)/cql + cp $(srcdir)/cql/*.err $(distdir)/cql + cp $(srcdir)/cql/*.out $(distdir)/cql + # Rule for generating codecs for our small ASN.1 spec tstodrcodec.c tstodrcodec.h: tstodr.asn $(YAZCOMP) cd $(srcdir); $(YAZCOMP) tstodr.asn diff --git a/test/cql/.cvsignore b/test/cql/.cvsignore new file mode 100644 index 0000000..0f46ad0 --- /dev/null +++ b/test/cql/.cvsignore @@ -0,0 +1,2 @@ +*.tmp +*.diff diff --git a/test/cql/1.1.err b/test/cql/1.1.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/1.1.out b/test/cql/1.1.out new file mode 100644 index 0000000..04e6f3f --- /dev/null +++ b/test/cql/1.1.out @@ -0,0 +1,7 @@ + + cql.serverChoice + + scr + + cat + diff --git a/test/cql/1.10.err b/test/cql/1.10.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/1.10.out b/test/cql/1.10.out new file mode 100644 index 0000000..a44a871 --- /dev/null +++ b/test/cql/1.10.out @@ -0,0 +1,7 @@ + + cql.serverChoice + + scr + + all + diff --git a/test/cql/1.11.err b/test/cql/1.11.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/1.11.out b/test/cql/1.11.out new file mode 100644 index 0000000..6aa73cd --- /dev/null +++ b/test/cql/1.11.out @@ -0,0 +1,7 @@ + + cql.serverChoice + + scr + + prox + diff --git a/test/cql/1.2.err b/test/cql/1.2.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/1.2.out b/test/cql/1.2.out new file mode 100644 index 0000000..04e6f3f --- /dev/null +++ b/test/cql/1.2.out @@ -0,0 +1,7 @@ + + cql.serverChoice + + scr + + cat + diff --git a/test/cql/1.3.err b/test/cql/1.3.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/1.3.out b/test/cql/1.3.out new file mode 100644 index 0000000..216c15c --- /dev/null +++ b/test/cql/1.3.out @@ -0,0 +1,7 @@ + + cql.serverChoice + + scr + + comp.os.linux + diff --git a/test/cql/1.4.err b/test/cql/1.4.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/1.4.out b/test/cql/1.4.out new file mode 100644 index 0000000..9b2ab93 --- /dev/null +++ b/test/cql/1.4.out @@ -0,0 +1,7 @@ + + cql.serverChoice + + scr + + ml:element + diff --git a/test/cql/1.5.err b/test/cql/1.5.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/1.5.out b/test/cql/1.5.out new file mode 100644 index 0000000..4ce7bc2 --- /dev/null +++ b/test/cql/1.5.out @@ -0,0 +1,7 @@ + + cql.serverChoice + + scr + + <xml:element> + diff --git a/test/cql/1.6.err b/test/cql/1.6.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/1.6.out b/test/cql/1.6.out new file mode 100644 index 0000000..d7786cb --- /dev/null +++ b/test/cql/1.6.out @@ -0,0 +1,7 @@ + + cql.serverChoice + + scr + + = + diff --git a/test/cql/1.7.err b/test/cql/1.7.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/1.7.out b/test/cql/1.7.out new file mode 100644 index 0000000..29742fc --- /dev/null +++ b/test/cql/1.7.out @@ -0,0 +1,7 @@ + + cql.serverChoice + + scr + + prox/distance<3/unit=word + diff --git a/test/cql/1.8.err b/test/cql/1.8.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/1.8.out b/test/cql/1.8.out new file mode 100644 index 0000000..04e6f3f --- /dev/null +++ b/test/cql/1.8.out @@ -0,0 +1,7 @@ + + cql.serverChoice + + scr + + cat + diff --git a/test/cql/1.9.err b/test/cql/1.9.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/1.9.out b/test/cql/1.9.out new file mode 100644 index 0000000..b8cbb85 --- /dev/null +++ b/test/cql/1.9.out @@ -0,0 +1,7 @@ + + cql.serverChoice + + scr + + dog + diff --git a/test/cql/10.1.err b/test/cql/10.1.err new file mode 100644 index 0000000..f83d884 --- /dev/null +++ b/test/cql/10.1.err @@ -0,0 +1 @@ +Syntax error diff --git a/test/cql/10.1.out b/test/cql/10.1.out new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/10.10.err b/test/cql/10.10.err new file mode 100644 index 0000000..f83d884 --- /dev/null +++ b/test/cql/10.10.err @@ -0,0 +1 @@ +Syntax error diff --git a/test/cql/10.10.out b/test/cql/10.10.out new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/10.2.err b/test/cql/10.2.err new file mode 100644 index 0000000..f83d884 --- /dev/null +++ b/test/cql/10.2.err @@ -0,0 +1 @@ +Syntax error diff --git a/test/cql/10.2.out b/test/cql/10.2.out new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/10.3.err b/test/cql/10.3.err new file mode 100644 index 0000000..f83d884 --- /dev/null +++ b/test/cql/10.3.err @@ -0,0 +1 @@ +Syntax error diff --git a/test/cql/10.3.out b/test/cql/10.3.out new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/10.4.err b/test/cql/10.4.err new file mode 100644 index 0000000..f83d884 --- /dev/null +++ b/test/cql/10.4.err @@ -0,0 +1 @@ +Syntax error diff --git a/test/cql/10.4.out b/test/cql/10.4.out new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/10.5.err b/test/cql/10.5.err new file mode 100644 index 0000000..f83d884 --- /dev/null +++ b/test/cql/10.5.err @@ -0,0 +1 @@ +Syntax error diff --git a/test/cql/10.5.out b/test/cql/10.5.out new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/10.6.err b/test/cql/10.6.err new file mode 100644 index 0000000..f83d884 --- /dev/null +++ b/test/cql/10.6.err @@ -0,0 +1 @@ +Syntax error diff --git a/test/cql/10.6.out b/test/cql/10.6.out new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/10.7.err b/test/cql/10.7.err new file mode 100644 index 0000000..f83d884 --- /dev/null +++ b/test/cql/10.7.err @@ -0,0 +1 @@ +Syntax error diff --git a/test/cql/10.7.out b/test/cql/10.7.out new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/10.8.err b/test/cql/10.8.err new file mode 100644 index 0000000..f83d884 --- /dev/null +++ b/test/cql/10.8.err @@ -0,0 +1 @@ +Syntax error diff --git a/test/cql/10.8.out b/test/cql/10.8.out new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/10.9.err b/test/cql/10.9.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/10.9.out b/test/cql/10.9.out new file mode 100644 index 0000000..e910b08 --- /dev/null +++ b/test/cql/10.9.out @@ -0,0 +1,7 @@ + + title + + = + + illegal parentheses + diff --git a/test/cql/2.1.err b/test/cql/2.1.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/2.1.out b/test/cql/2.1.out new file mode 100644 index 0000000..be3c9c1 --- /dev/null +++ b/test/cql/2.1.out @@ -0,0 +1,7 @@ + + title + + = + + fish + diff --git a/test/cql/2.10.err b/test/cql/2.10.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/2.10.out b/test/cql/2.10.out new file mode 100644 index 0000000..d7dfe7a --- /dev/null +++ b/test/cql/2.10.out @@ -0,0 +1,7 @@ + + title + + any + + frog + diff --git a/test/cql/2.11.err b/test/cql/2.11.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/2.11.out b/test/cql/2.11.out new file mode 100644 index 0000000..bc04886 --- /dev/null +++ b/test/cql/2.11.out @@ -0,0 +1,13 @@ + + dc.title + + any + + + stem + = + + + + frog pond + diff --git a/test/cql/2.12.err b/test/cql/2.12.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/2.12.out b/test/cql/2.12.out new file mode 100644 index 0000000..a648cc5 --- /dev/null +++ b/test/cql/2.12.out @@ -0,0 +1,7 @@ + + dc.title + + scr + + fish frog chicken + diff --git a/test/cql/2.13.err b/test/cql/2.13.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/2.13.out b/test/cql/2.13.out new file mode 100644 index 0000000..4e66231 --- /dev/null +++ b/test/cql/2.13.out @@ -0,0 +1,14 @@ + + dc.title + + = + + + rel.algorithm + = + CORI + + + + squid + diff --git a/test/cql/2.14.err b/test/cql/2.14.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/2.14.out b/test/cql/2.14.out new file mode 100644 index 0000000..e1e02a8 --- /dev/null +++ b/test/cql/2.14.out @@ -0,0 +1,18 @@ + + creator + + any + + + b.bar + > + 1 + + + f.foo + = + + + + sanderson taylor + diff --git a/test/cql/2.2.err b/test/cql/2.2.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/2.2.out b/test/cql/2.2.out new file mode 100644 index 0000000..2b78ddf --- /dev/null +++ b/test/cql/2.2.out @@ -0,0 +1,7 @@ + + title + + exact + + fish + diff --git a/test/cql/2.3.err b/test/cql/2.3.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/2.3.out b/test/cql/2.3.out new file mode 100644 index 0000000..62521be --- /dev/null +++ b/test/cql/2.3.out @@ -0,0 +1,7 @@ + + title + + any + + fish + diff --git a/test/cql/2.4.err b/test/cql/2.4.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/2.4.out b/test/cql/2.4.out new file mode 100644 index 0000000..646c973 --- /dev/null +++ b/test/cql/2.4.out @@ -0,0 +1,7 @@ + + title + + all + + fish + diff --git a/test/cql/2.5.err b/test/cql/2.5.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/2.5.out b/test/cql/2.5.out new file mode 100644 index 0000000..92411c4 --- /dev/null +++ b/test/cql/2.5.out @@ -0,0 +1,7 @@ + + title + + > + + 9 + diff --git a/test/cql/2.6.err b/test/cql/2.6.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/2.6.out b/test/cql/2.6.out new file mode 100644 index 0000000..6702471 --- /dev/null +++ b/test/cql/2.6.out @@ -0,0 +1,7 @@ + + title + + >= + + 23 + diff --git a/test/cql/2.7.err b/test/cql/2.7.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/2.7.out b/test/cql/2.7.out new file mode 100644 index 0000000..ba4ac78 --- /dev/null +++ b/test/cql/2.7.out @@ -0,0 +1,7 @@ + + dc.title + + any + + fish chips + diff --git a/test/cql/2.8.err b/test/cql/2.8.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/2.8.out b/test/cql/2.8.out new file mode 100644 index 0000000..3f45441 --- /dev/null +++ b/test/cql/2.8.out @@ -0,0 +1,13 @@ + + dc.title + + any + + + stem + = + + + + fish + diff --git a/test/cql/2.9.err b/test/cql/2.9.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/2.9.out b/test/cql/2.9.out new file mode 100644 index 0000000..1222fac --- /dev/null +++ b/test/cql/2.9.out @@ -0,0 +1,17 @@ + + dc.fish + + all + + + fuzzy + = + + + stem + = + + + + fish chips + diff --git a/test/cql/3.1.err b/test/cql/3.1.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/3.1.out b/test/cql/3.1.out new file mode 100644 index 0000000..de0acae --- /dev/null +++ b/test/cql/3.1.out @@ -0,0 +1,23 @@ + + + or + + + + cql.serverChoice + + scr + + cat + + + + + cql.serverChoice + + scr + + dog + + + diff --git a/test/cql/3.2.err b/test/cql/3.2.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/3.2.out b/test/cql/3.2.out new file mode 100644 index 0000000..f5dba0b --- /dev/null +++ b/test/cql/3.2.out @@ -0,0 +1,23 @@ + + + and + + + + cql.serverChoice + + scr + + cat + + + + + cql.serverChoice + + scr + + fish + + + diff --git a/test/cql/3.3.err b/test/cql/3.3.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/3.3.out b/test/cql/3.3.out new file mode 100644 index 0000000..895ee06 --- /dev/null +++ b/test/cql/3.3.out @@ -0,0 +1,23 @@ + + + not + + + + cql.serverChoice + + scr + + cat + + + + + cql.serverChoice + + scr + + frog + + + diff --git a/test/cql/3.4.err b/test/cql/3.4.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/3.4.out b/test/cql/3.4.out new file mode 100644 index 0000000..895ee06 --- /dev/null +++ b/test/cql/3.4.out @@ -0,0 +1,23 @@ + + + not + + + + cql.serverChoice + + scr + + cat + + + + + cql.serverChoice + + scr + + frog + + + diff --git a/test/cql/3.5.err b/test/cql/3.5.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/3.5.out b/test/cql/3.5.out new file mode 100644 index 0000000..4627440 --- /dev/null +++ b/test/cql/3.5.out @@ -0,0 +1,23 @@ + + + not + + + + cql.serverChoice + + scr + + cat + + + + + cql.serverChoice + + scr + + fish food + + + diff --git a/test/cql/3.6.err b/test/cql/3.6.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/3.6.out b/test/cql/3.6.out new file mode 100644 index 0000000..049b9d8 --- /dev/null +++ b/test/cql/3.6.out @@ -0,0 +1,23 @@ + + + and + + + + cql.serverChoice + + scr + + xml + + + + + cql.serverChoice + + scr + + prox/// + + + diff --git a/test/cql/3.7.err b/test/cql/3.7.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/3.7.out b/test/cql/3.7.out new file mode 100644 index 0000000..0a62182 --- /dev/null +++ b/test/cql/3.7.out @@ -0,0 +1,23 @@ + + + and + + + + cql.serverChoice + + scr + + fred + + + + + cql.serverChoice + + scr + + any + + + diff --git a/test/cql/3.8.err b/test/cql/3.8.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/3.8.out b/test/cql/3.8.out new file mode 100644 index 0000000..d971224 --- /dev/null +++ b/test/cql/3.8.out @@ -0,0 +1,23 @@ + + + or + + + + cql.serverChoice + + scr + + fred + + + + + cql.serverChoice + + scr + + all + + + diff --git a/test/cql/3.9.err b/test/cql/3.9.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/3.9.out b/test/cql/3.9.out new file mode 100644 index 0000000..9b7f604 --- /dev/null +++ b/test/cql/3.9.out @@ -0,0 +1,55 @@ + + + not + + + + + and + + + + + or + + + + cql.serverChoice + + scr + + a + + + + + cql.serverChoice + + scr + + b + + + + + + + cql.serverChoice + + scr + + c + + + + + + + cql.serverChoice + + scr + + d + + + diff --git a/test/cql/4.1.err b/test/cql/4.1.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/4.1.out b/test/cql/4.1.out new file mode 100644 index 0000000..6565168 --- /dev/null +++ b/test/cql/4.1.out @@ -0,0 +1,23 @@ + + + and + + + + bath.uniformTitle + + any + + fish + + + + + dc.title + + any + + cat dog + + + diff --git a/test/cql/4.2.err b/test/cql/4.2.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/4.2.out b/test/cql/4.2.out new file mode 100644 index 0000000..9280263 --- /dev/null +++ b/test/cql/4.2.out @@ -0,0 +1,29 @@ + + + or + + + + title + + any + + + stem + = + + + + fish dog + + + + + cql.serverChoice + + scr + + and + + + diff --git a/test/cql/5.1.err b/test/cql/5.1.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/5.1.out b/test/cql/5.1.out new file mode 100644 index 0000000..b42c733 --- /dev/null +++ b/test/cql/5.1.out @@ -0,0 +1,23 @@ + + + prox + + + + cql.serverChoice + + scr + + cat + + + + + cql.serverChoice + + scr + + hat + + + diff --git a/test/cql/5.2.err b/test/cql/5.2.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/5.2.out b/test/cql/5.2.out new file mode 100644 index 0000000..1ad4e8a --- /dev/null +++ b/test/cql/5.2.out @@ -0,0 +1,39 @@ + + + prox + + + ordered + = + + + unit + = + word + + + distance + = + 3 + + + + + + cql.serverChoice + + scr + + cat + + + + + cql.serverChoice + + scr + + hat + + + diff --git a/test/cql/5.3.err b/test/cql/5.3.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/5.3.out b/test/cql/5.3.out new file mode 100644 index 0000000..7700548 --- /dev/null +++ b/test/cql/5.3.out @@ -0,0 +1,30 @@ + + + prox + + + distance + < + 3 + + + + + + cql.serverChoice + + scr + + cat + + + + + cql.serverChoice + + scr + + hat + + + diff --git a/test/cql/5.4.err b/test/cql/5.4.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/5.4.out b/test/cql/5.4.out new file mode 100644 index 0000000..5e93079 --- /dev/null +++ b/test/cql/5.4.out @@ -0,0 +1,30 @@ + + + prox + + + unit + = + sentence + + + + + + cql.serverChoice + + scr + + fish food + + + + + cql.serverChoice + + scr + + and + + + diff --git a/test/cql/5.5.err b/test/cql/5.5.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/5.5.out b/test/cql/5.5.out new file mode 100644 index 0000000..1d03784 --- /dev/null +++ b/test/cql/5.5.out @@ -0,0 +1,30 @@ + + + prox + + + distance + <= + 5 + + + + + + title + + all + + chips frog + + + + + cql.serverChoice + + scr + + exact + + + diff --git a/test/cql/5.6.err b/test/cql/5.6.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/5.6.out b/test/cql/5.6.out new file mode 100644 index 0000000..20a88e9 --- /dev/null +++ b/test/cql/5.6.out @@ -0,0 +1,35 @@ + + + prox + + + unit + = + element + + + distance + > + 5 + + + + + + dc.author + + exact + + jones + + + + + title + + >= + + smith + + + diff --git a/test/cql/5.7.err b/test/cql/5.7.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/5.7.out b/test/cql/5.7.out new file mode 100644 index 0000000..5274289 --- /dev/null +++ b/test/cql/5.7.out @@ -0,0 +1,29 @@ + + + and + + + rel.SumOfScores + = + + + + + + cql.serverChoice + + scr + + a + + + + + cql.serverChoice + + scr + + b + + + diff --git a/test/cql/5.8.err b/test/cql/5.8.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/5.8.out b/test/cql/5.8.out new file mode 100644 index 0000000..8759654 --- /dev/null +++ b/test/cql/5.8.out @@ -0,0 +1,30 @@ + + + and + + + rel.algorithm + = + CORI + + + + + + cql.serverChoice + + scr + + a + + + + + cql.serverChoice + + scr + + b + + + diff --git a/test/cql/6.1.err b/test/cql/6.1.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/6.1.out b/test/cql/6.1.out new file mode 100644 index 0000000..6e59421 --- /dev/null +++ b/test/cql/6.1.out @@ -0,0 +1,7 @@ + + cql.serverChoice + + scr + + cat^ + diff --git a/test/cql/6.2.err b/test/cql/6.2.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/6.2.out b/test/cql/6.2.out new file mode 100644 index 0000000..04e6f3f --- /dev/null +++ b/test/cql/6.2.out @@ -0,0 +1,7 @@ + + cql.serverChoice + + scr + + cat + diff --git a/test/cql/6.3.err b/test/cql/6.3.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/6.3.out b/test/cql/6.3.out new file mode 100644 index 0000000..7411f1a --- /dev/null +++ b/test/cql/6.3.out @@ -0,0 +1,7 @@ + + cql.serverChoice + + scr + + ^cat says "fish" + diff --git a/test/cql/6.4.err b/test/cql/6.4.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/6.4.out b/test/cql/6.4.out new file mode 100644 index 0000000..4c5cf95 --- /dev/null +++ b/test/cql/6.4.out @@ -0,0 +1,7 @@ + + cql.serverChoice + + scr + + cat*fish + diff --git a/test/cql/6.5.err b/test/cql/6.5.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/6.5.out b/test/cql/6.5.out new file mode 100644 index 0000000..d82b932 --- /dev/null +++ b/test/cql/6.5.out @@ -0,0 +1,7 @@ + + cql.serverChoice + + scr + + cat?dog + diff --git a/test/cql/6.6.err b/test/cql/6.6.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/6.6.out b/test/cql/6.6.out new file mode 100644 index 0000000..f9851fb --- /dev/null +++ b/test/cql/6.6.out @@ -0,0 +1,7 @@ + + cql.serverChoice + + scr + + ^cat*fishdog"horse? + diff --git a/test/cql/7.1.err b/test/cql/7.1.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/7.1.out b/test/cql/7.1.out new file mode 100644 index 0000000..e9baec9 --- /dev/null +++ b/test/cql/7.1.out @@ -0,0 +1,55 @@ + + + and + + + + + or + + + + + or + + + + cql.serverChoice + + scr + + cat + + + + + cql.serverChoice + + scr + + dog + + + + + + + cql.serverChoice + + scr + + horse + + + + + + + cql.serverChoice + + scr + + frog + + + diff --git a/test/cql/7.2.err b/test/cql/7.2.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/7.2.out b/test/cql/7.2.out new file mode 100644 index 0000000..8df4539 --- /dev/null +++ b/test/cql/7.2.out @@ -0,0 +1,55 @@ + + + or + + + + + and + + + + cql.serverChoice + + scr + + cat + + + + + cql.serverChoice + + scr + + dog + + + + + + + + and + + + + cql.serverChoice + + scr + + horse + + + + + cql.serverChoice + + scr + + frog + + + + + diff --git a/test/cql/7.3.err b/test/cql/7.3.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/7.3.out b/test/cql/7.3.out new file mode 100644 index 0000000..3a057fd --- /dev/null +++ b/test/cql/7.3.out @@ -0,0 +1,55 @@ + + + and + + + + + and + + + + cql.serverChoice + + scr + + cat + + + + + + or + + + + cql.serverChoice + + scr + + horse + + + + + cql.serverChoice + + scr + + frog + + + + + + + + + cql.serverChoice + + scr + + chips + + + diff --git a/test/cql/8.1.err b/test/cql/8.1.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/8.1.out b/test/cql/8.1.out new file mode 100644 index 0000000..2b489af --- /dev/null +++ b/test/cql/8.1.out @@ -0,0 +1,13 @@ + + + + foo + info:srw/cql-context-set/1/dc-v1.1 + + + dc.title + + = + + fish + diff --git a/test/cql/8.2.err b/test/cql/8.2.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/8.2.out b/test/cql/8.2.out new file mode 100644 index 0000000..b86dbf2 --- /dev/null +++ b/test/cql/8.2.out @@ -0,0 +1,12 @@ + + + + info:srw/cql-context-set/1/dc-v1.1 + + + title + + = + + fish + diff --git a/test/cql/8.3.err b/test/cql/8.3.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/8.3.out b/test/cql/8.3.out new file mode 100644 index 0000000..4eebbd3 --- /dev/null +++ b/test/cql/8.3.out @@ -0,0 +1,33 @@ + + + + foo + info:srw/cql-context-set/1/dc-v1.1 + + + ccg + http://srw.cheshire3.org/contextSets/ccg/1.1/ + + + + and + + + + foo.title + + = + + fish + + + + + ccg.force + + = + + 3 + + + diff --git a/test/cql/9.1.err b/test/cql/9.1.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/9.1.out b/test/cql/9.1.out new file mode 100644 index 0000000..eac3a28 --- /dev/null +++ b/test/cql/9.1.out @@ -0,0 +1,55 @@ + + + prox + + + + + and + + + + + or + + + + cql.serverChoice + + scr + + any + + + + + cql.serverChoice + + scr + + all:stem + + + + + + + all + + exact + + any + + + + + + + prox + + = + + fuzzy + + + diff --git a/test/cql/9.2.err b/test/cql/9.2.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/9.2.out b/test/cql/9.2.out new file mode 100644 index 0000000..eb0d4a9 --- /dev/null +++ b/test/cql/9.2.out @@ -0,0 +1,7 @@ + + cql.serverChoice + + scr + + any + diff --git a/test/cql/9.3.err b/test/cql/9.3.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/9.3.out b/test/cql/9.3.out new file mode 100644 index 0000000..ee798ea --- /dev/null +++ b/test/cql/9.3.out @@ -0,0 +1,7 @@ + + cql.serverChoice + + scr + + + diff --git a/test/cql/9.4.err b/test/cql/9.4.err new file mode 100644 index 0000000..e69de29 diff --git a/test/cql/9.4.out b/test/cql/9.4.out new file mode 100644 index 0000000..aed8eca --- /dev/null +++ b/test/cql/9.4.out @@ -0,0 +1,16 @@ + + + + any + + + any + exact + + + any + + > + + any + diff --git a/test/cqlsample b/test/cqlsample new file mode 100644 index 0000000..c9f88b5 --- /dev/null +++ b/test/cqlsample @@ -0,0 +1,103 @@ +# $Id: cqlsample,v 1.1 2004-03-10 16:34:30 adam Exp $ +# CQL queries for testing. +# Simple Term + +cat +"cat" +comp.os.linux +ml:element +"" +"=" +"prox/distance<3/unit=word" +("cat") +((dog)) +all +prox + +# Index Relation Term + +title = "fish" +title exact fish +title any fish +title all fish +title > 9 +title >= 23 +dc.title any "fish chips" +dc.title any/stem fish +dc.fish all/stem/fuzzy "fish chips" +(title any frog) +((dc.title any/stem "frog pond")) +dc.title scr "fish frog chicken" +dc.title =/rel.algorithm=CORI squid +creator any/f.foo/b.bar>1 "sanderson taylor" + +# Simple Boolean + +cat or dog +cat and fish +cat not frog +(cat not frog) +"cat" not "fish food" +xml and "prox///" +fred and any +((fred or all)) +a or b and c not d + +# Index Relation Term plus Boolean + +bath.uniformTitle any fish and dc.title any "cat dog" +(title any/stem "fish dog" or and) + +# Proximity and Boolean Modifiers + +cat prox hat +cat prox/distance=3/unit=word/ordered hat +cat prox/distance<3 hat +"fish food" prox/unit=sentence and +title all "chips frog" prox/distance<=5 exact +(dc.author exact "jones" prox/distance>5/unit=element title >= "smith") +a and/rel.SumOfScores b +a and/rel.algorithm=CORI b + +# Special Characters + +(cat^) +"cat" +"^cat says \"fish\"" +"cat*fish" +cat?dog +(("^cat*fishdog\"horse?")) + +# Nesting Parentheses + +(((cat or dog) or horse) and frog) +(cat and dog) or (horse and frog) +(cat and (horse or frog)) and chips + +# Prefix Maps + +> foo="info:srw/cql-context-set/1/dc-v1.1" dc.title="fish" +> "info:srw/cql-context-set/1/dc-v1.1" title="fish" +> foo="info:srw/cql-context-set/1/dc-v1.1" > ccg = "http://srw.cheshire3.org/contextSets/ccg/1.1/" foo.title="fish" and ccg.force=3 + +# Lame Searches + +any or all:stem and all exact any prox prox=fuzzy +(((((((((any))))))))) +"" +> any > any = exact any > any + +# Invalid searches [should error] + +< +=== +missingClause or +missingTerm any +() +(missingParen +missingParen any fish) +(emptyParens or ()) +title = ("illegal parentheses") +> illegal="urn:missingQuery" + + diff --git a/test/tstcql.sh b/test/tstcql.sh new file mode 100755 index 0000000..2f41aba --- /dev/null +++ b/test/tstcql.sh @@ -0,0 +1,49 @@ +#!/bin/sh +oIFS="$IFS" +IFS=' +' +secno=0 +testno=0 +comment=0 +ecode=0 +for f in `cat cqlsample`; do + if echo $f | grep '^#' >/dev/null; then + comment=1 + else + if test "$comment" = "1"; then + secno=`expr $secno + 1` + testno=0 + fi + comment=0 + testno=`expr $testno + 1` + OUT1=cql/$secno.$testno.out + ERR1=cql/$secno.$testno.err + OUT2=cql/$secno.$testno.out.tmp + ERR2=cql/$secno.$testno.err.tmp + DIFF=cql/$secno.$testno.diff + ../util/cql2xcql "$f" >$OUT2 2>$ERR2 + if test -f $OUT1 -a -f $ERR1; then + if diff $OUT1 $OUT2 >$DIFF; then + rm $DIFF + else + echo "diff out $secno $testno $f" + cat $DIFF + ecode=1 + fi + if diff $ERR1 $ERR2 >$DIFF; then + rm $DIFF + else + echo "diff err $secno $testno $f" + cat $DIFF + ecode=1 + fi + else + echo "making test $secno $testno $f" + mv $OUT2 $OUT1 + mv $ERR2 $ERR1 + ecode=1 + fi + fi +done +IFS="$oIFS" +exit $ecode diff --git a/util/cql2xcql.c b/util/cql2xcql.c index e389069..2dadb4c 100644 --- a/util/cql2xcql.c +++ b/util/cql2xcql.c @@ -1,4 +1,4 @@ -/* $Id: cql2xcql.c,v 1.1 2003-10-27 12:21:39 adam Exp $ +/* $Id: cql2xcql.c,v 1.2 2004-03-10 16:34:31 adam Exp $ Copyright (C) 2002-2003 Index Data Aps @@ -13,10 +13,33 @@ See the file LICENSE. int main(int argc, char **argv) { + CQL_parser cp; int r; - CQL_parser cp = cql_parser_create(); - if (argc == 2) - r = cql_parser_string(cp, argv[1]); + const char *fname = 0; + int iterations = 1; + int ret; + char *arg; + + while ((ret = options("n:", argv, argc, &arg)) != -2) + { + switch (ret) + { + case 0: + fname = arg; + break; + case 'n': + iterations = atoi(arg); + break; + } + } + + cp = cql_parser_create(); + if (fname) + { + int i; + for (i = 0; i