Update CQL parser to use CQL 1.1 modifiers for booleans and
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 10 Mar 2004 16:34:29 +0000 (16:34 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 10 Mar 2004 16:34:29 +0000 (16:34 +0000)
relations. Add CQL regression cases.

155 files changed:
CHANGELOG
Makefile.am
include/yaz/cql.h
src/Makefile.am
src/cql.y
src/cqltransform.c
src/cqlutil.c
src/lexer.h [deleted file]
src/xcqlutil.c
test/Makefile.am
test/cql/.cvsignore [new file with mode: 0644]
test/cql/1.1.err [new file with mode: 0644]
test/cql/1.1.out [new file with mode: 0644]
test/cql/1.10.err [new file with mode: 0644]
test/cql/1.10.out [new file with mode: 0644]
test/cql/1.11.err [new file with mode: 0644]
test/cql/1.11.out [new file with mode: 0644]
test/cql/1.2.err [new file with mode: 0644]
test/cql/1.2.out [new file with mode: 0644]
test/cql/1.3.err [new file with mode: 0644]
test/cql/1.3.out [new file with mode: 0644]
test/cql/1.4.err [new file with mode: 0644]
test/cql/1.4.out [new file with mode: 0644]
test/cql/1.5.err [new file with mode: 0644]
test/cql/1.5.out [new file with mode: 0644]
test/cql/1.6.err [new file with mode: 0644]
test/cql/1.6.out [new file with mode: 0644]
test/cql/1.7.err [new file with mode: 0644]
test/cql/1.7.out [new file with mode: 0644]
test/cql/1.8.err [new file with mode: 0644]
test/cql/1.8.out [new file with mode: 0644]
test/cql/1.9.err [new file with mode: 0644]
test/cql/1.9.out [new file with mode: 0644]
test/cql/10.1.err [new file with mode: 0644]
test/cql/10.1.out [new file with mode: 0644]
test/cql/10.10.err [new file with mode: 0644]
test/cql/10.10.out [new file with mode: 0644]
test/cql/10.2.err [new file with mode: 0644]
test/cql/10.2.out [new file with mode: 0644]
test/cql/10.3.err [new file with mode: 0644]
test/cql/10.3.out [new file with mode: 0644]
test/cql/10.4.err [new file with mode: 0644]
test/cql/10.4.out [new file with mode: 0644]
test/cql/10.5.err [new file with mode: 0644]
test/cql/10.5.out [new file with mode: 0644]
test/cql/10.6.err [new file with mode: 0644]
test/cql/10.6.out [new file with mode: 0644]
test/cql/10.7.err [new file with mode: 0644]
test/cql/10.7.out [new file with mode: 0644]
test/cql/10.8.err [new file with mode: 0644]
test/cql/10.8.out [new file with mode: 0644]
test/cql/10.9.err [new file with mode: 0644]
test/cql/10.9.out [new file with mode: 0644]
test/cql/2.1.err [new file with mode: 0644]
test/cql/2.1.out [new file with mode: 0644]
test/cql/2.10.err [new file with mode: 0644]
test/cql/2.10.out [new file with mode: 0644]
test/cql/2.11.err [new file with mode: 0644]
test/cql/2.11.out [new file with mode: 0644]
test/cql/2.12.err [new file with mode: 0644]
test/cql/2.12.out [new file with mode: 0644]
test/cql/2.13.err [new file with mode: 0644]
test/cql/2.13.out [new file with mode: 0644]
test/cql/2.14.err [new file with mode: 0644]
test/cql/2.14.out [new file with mode: 0644]
test/cql/2.2.err [new file with mode: 0644]
test/cql/2.2.out [new file with mode: 0644]
test/cql/2.3.err [new file with mode: 0644]
test/cql/2.3.out [new file with mode: 0644]
test/cql/2.4.err [new file with mode: 0644]
test/cql/2.4.out [new file with mode: 0644]
test/cql/2.5.err [new file with mode: 0644]
test/cql/2.5.out [new file with mode: 0644]
test/cql/2.6.err [new file with mode: 0644]
test/cql/2.6.out [new file with mode: 0644]
test/cql/2.7.err [new file with mode: 0644]
test/cql/2.7.out [new file with mode: 0644]
test/cql/2.8.err [new file with mode: 0644]
test/cql/2.8.out [new file with mode: 0644]
test/cql/2.9.err [new file with mode: 0644]
test/cql/2.9.out [new file with mode: 0644]
test/cql/3.1.err [new file with mode: 0644]
test/cql/3.1.out [new file with mode: 0644]
test/cql/3.2.err [new file with mode: 0644]
test/cql/3.2.out [new file with mode: 0644]
test/cql/3.3.err [new file with mode: 0644]
test/cql/3.3.out [new file with mode: 0644]
test/cql/3.4.err [new file with mode: 0644]
test/cql/3.4.out [new file with mode: 0644]
test/cql/3.5.err [new file with mode: 0644]
test/cql/3.5.out [new file with mode: 0644]
test/cql/3.6.err [new file with mode: 0644]
test/cql/3.6.out [new file with mode: 0644]
test/cql/3.7.err [new file with mode: 0644]
test/cql/3.7.out [new file with mode: 0644]
test/cql/3.8.err [new file with mode: 0644]
test/cql/3.8.out [new file with mode: 0644]
test/cql/3.9.err [new file with mode: 0644]
test/cql/3.9.out [new file with mode: 0644]
test/cql/4.1.err [new file with mode: 0644]
test/cql/4.1.out [new file with mode: 0644]
test/cql/4.2.err [new file with mode: 0644]
test/cql/4.2.out [new file with mode: 0644]
test/cql/5.1.err [new file with mode: 0644]
test/cql/5.1.out [new file with mode: 0644]
test/cql/5.2.err [new file with mode: 0644]
test/cql/5.2.out [new file with mode: 0644]
test/cql/5.3.err [new file with mode: 0644]
test/cql/5.3.out [new file with mode: 0644]
test/cql/5.4.err [new file with mode: 0644]
test/cql/5.4.out [new file with mode: 0644]
test/cql/5.5.err [new file with mode: 0644]
test/cql/5.5.out [new file with mode: 0644]
test/cql/5.6.err [new file with mode: 0644]
test/cql/5.6.out [new file with mode: 0644]
test/cql/5.7.err [new file with mode: 0644]
test/cql/5.7.out [new file with mode: 0644]
test/cql/5.8.err [new file with mode: 0644]
test/cql/5.8.out [new file with mode: 0644]
test/cql/6.1.err [new file with mode: 0644]
test/cql/6.1.out [new file with mode: 0644]
test/cql/6.2.err [new file with mode: 0644]
test/cql/6.2.out [new file with mode: 0644]
test/cql/6.3.err [new file with mode: 0644]
test/cql/6.3.out [new file with mode: 0644]
test/cql/6.4.err [new file with mode: 0644]
test/cql/6.4.out [new file with mode: 0644]
test/cql/6.5.err [new file with mode: 0644]
test/cql/6.5.out [new file with mode: 0644]
test/cql/6.6.err [new file with mode: 0644]
test/cql/6.6.out [new file with mode: 0644]
test/cql/7.1.err [new file with mode: 0644]
test/cql/7.1.out [new file with mode: 0644]
test/cql/7.2.err [new file with mode: 0644]
test/cql/7.2.out [new file with mode: 0644]
test/cql/7.3.err [new file with mode: 0644]
test/cql/7.3.out [new file with mode: 0644]
test/cql/8.1.err [new file with mode: 0644]
test/cql/8.1.out [new file with mode: 0644]
test/cql/8.2.err [new file with mode: 0644]
test/cql/8.2.out [new file with mode: 0644]
test/cql/8.3.err [new file with mode: 0644]
test/cql/8.3.out [new file with mode: 0644]
test/cql/9.1.err [new file with mode: 0644]
test/cql/9.1.out [new file with mode: 0644]
test/cql/9.2.err [new file with mode: 0644]
test/cql/9.2.out [new file with mode: 0644]
test/cql/9.3.err [new file with mode: 0644]
test/cql/9.3.out [new file with mode: 0644]
test/cql/9.4.err [new file with mode: 0644]
test/cql/9.4.out [new file with mode: 0644]
test/cqlsample [new file with mode: 0644]
test/tstcql.sh [new file with mode: 0755]
util/cql2xcql.c
win/makefile

index 0c22fbe..1d882b4 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,10 @@
 Possible compatibility problems with earlier versions marked with '*'.
 
 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.
 --- 2.0.15 2004/03/01
 
 Another fix for decoding of XML packed records.
index f54ec43..8b7416f 100644 (file)
@@ -1,10 +1,10 @@
 ## Copyright (C) 1994-2003, Index Data
 ## All rights reserved.
 ## 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 
 
 
 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
 
 
 aclocaldir=$(datadir)/aclocal
 
index b9b5f4d..6d6782c 100644 (file)
@@ -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.
    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 cql_node *modifiers;
             struct cql_node *prefixes;
         } boolean;
-        struct {
-            char *name;
-            char *value;
-            struct cql_node *next;
-        } mod;
     } u;
 };
 
     } u;
 };
 
@@ -134,10 +129,6 @@ struct cql_node *cql_node_prefix(struct cql_node *n,
                                  const char *prefix,
                                  const char *uri);
 YAZ_EXPORT
                                  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);
 struct cql_node *cql_node_dup (struct cql_node *cp);
 YAZ_EXPORT
 struct cql_node *cql_parser_result(CQL_parser cp);
index 8964796..9f3052d 100644 (file)
@@ -1,6 +1,6 @@
 ## Copyright (C) 1994-2003, Index Data
 ## All rights reserved.
 ## 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
 
 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 \
   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)
   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)
index c98696d..0a81738 100644 (file)
--- 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.
    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
 
 %pure_parser
 %token TERM AND OR NOT PROX GE LE NE
-%expect 8
+%expect 9
 
 %%
 
 top: { 
 
 %%
 
 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);
     ((CQL_parser) parm)->top = 0;
 } cqlQuery1 {
     cql_node_destroy($$.rel);
@@ -68,14 +68,14 @@ cqlQuery1: cqlQuery
 cqlQuery: 
   searchClause
 |
 cqlQuery: 
   searchClause
 |
-  cqlQuery boolean { 
-      $$.rel = $0.rel; 
+  cqlQuery boolean modifiers { 
+      $$.rel = $0.rel;
   } searchClause {
       struct cql_node *cn = cql_node_mk_boolean($2.buf);
       
   } 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.left = $1.cql;
-      cn->u.boolean.right = $4.cql;
+      cn->u.boolean.right = $5.cql;
 
       $$.cql = cn;
   }
 
       $$.cql = cn;
   }
@@ -95,12 +95,12 @@ searchClause:
       $$.cql = st;
   }
 | 
       $$.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 {
   } searchClause {
-      $$.cql = $4.cql;
-      cql_node_destroy($2.rel);
+      $$.cql = $5.cql;
+      cql_node_destroy($4.rel);
   }
 | '>' searchTerm '=' searchTerm {
       $$.rel = $0.rel;
   }
 | '>' searchTerm '=' searchTerm {
       $$.rel = $0.rel;
@@ -117,91 +117,40 @@ searchClause:
 /* unary NOT search TERM here .. */
 
 boolean: 
 /* 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 = mod;
 }
-|  
+|
 { 
     $$.cql = 0;
 }
 ;
 
 { 
     $$.cql = 0;
 }
 ;
 
-baseRelation: 
+mrelation:
+  '=' 
+| '>' 
+| '<'
+| GE
+| LE
+| NE
+;
+
+relation: 
   '=' 
 | '>' 
 | '<'
   '=' 
 | '>' 
 | '<'
@@ -229,7 +178,111 @@ int yyerror(char *s)
     return 0;
 }
 
     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("()=></", c))
+    {
+        int c1;
+        putb(lval, cp, c);
+        if (c == '>')
+        {
+            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,
 
 
 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)
 {
                       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;
     cp->getbyte = getbyte;
     cp->ungetbyte = ungetbyte;
     cp->client_data = client_data;
index 22f3fe5..52cb21f 100644 (file)
@@ -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
 
    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;
     if (errcode && !ct->error)
     {
         ct->error = errcode;
-        ct->addinfo = strdup(val);
+       if (val)
+           ct->addinfo = strdup(val);
+       else
+           ct->addinfo = 0;
     }
     return 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 (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;
             }
                 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;
             }
         }
                 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;
         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);
             }
         }
                             pr, client_data, 20);
             }
         }
@@ -524,13 +527,13 @@ int cql_transform(cql_transform_t ct,
     {
         if (!memcmp(e->pattern, "set.", 4))
         {
     {
         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"))
         {
         }
         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);
         }
     }
     cql_transform_r (ct, cn, pr, client_data, prefix_ar, 1);
index baa54ad..1b842b1 100644 (file)
@@ -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.
    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;
         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);
     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;
 }
 
     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));
 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)
     {
     }
     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;
 }
 
         *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)
 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;
         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);
     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);
 }
     }
     free (cn);
 }
diff --git a/src/lexer.h b/src/lexer.h
deleted file mode 100644 (file)
index 6c8a3b4..0000000
+++ /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("()=></", c))
-    {
-        int c1;
-        putb(lval, cp, c);
-        if (c == '>')
-        {
-            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;
-}
index 9c38de1..b884b6e 100644 (file)
@@ -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.
    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("<prefixes>\n", pr, client_data, level);
     if (cn)
     {
         pr_n("<prefixes>\n", pr, client_data, level);
-        for (; cn; cn = cn->u.mod.next)
+        for (; cn; cn = cn->u.st.modifiers)
         {
             pr_n("<prefix>\n", pr, client_data, level+2);
         {
             pr_n("<prefix>\n", pr, client_data, level+2);
-            if (cn->u.mod.name)
+            if (cn->u.st.index)
             {
                 pr_n("<name>", pr, client_data, level+4);
             {
                 pr_n("<name>", 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("</name>\n", pr, client_data, 0);
             }
                 pr_n("</name>\n", pr, client_data, 0);
             }
-            if (cn->u.mod.value)
+            if (cn->u.st.term)
             {
                 pr_n("<identifier>", pr, client_data, level+4);
             {
                 pr_n("<identifier>", 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("</identifier>\n", pr, client_data, 0);
             }
             pr_n("</prefix>\n", pr, client_data, level+2);
                 pr_n("</identifier>\n", pr, client_data, 0);
             }
             pr_n("</prefix>\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("<modifiers>\n", pr, client_data, level);
+       for (; m; m = m->u.st.modifiers)
+       {
+           pr_n("<modifier>\n", pr, client_data, level+2);
+           pr_n("<type>", pr, client_data, level+4);
+           pr_cdata(m->u.st.index, pr, client_data);
+           pr_n("</type>\n", pr, client_data, 0);
+           if (m->u.st.relation)
+           {
+               pr_n("<relation>", pr, client_data, level+4);
+               pr_cdata(m->u.st.relation, pr, client_data);
+               pr_n("</relation>\n", pr, client_data, 0);
+           }
+           if (m->u.st.term)
+           {
+               pr_n("<value>", pr, client_data, level+4);
+               pr_cdata(m->u.st.term, pr, client_data);
+               pr_n("</value>\n", pr, client_data, 0);
+           }
+           pr_n("</modifier>\n", pr, client_data, level+2);
+       }
+       pr_n("</modifiers>\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)
 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)
         {
         }
         if (cn->u.st.relation)
         {
-            struct cql_node *m = cn->u.st.modifiers;
             pr_n("<relation>\n", pr, client_data, level+2);
             pr_n("<value>", pr, client_data, level+4);
             pr_cdata(cn->u.st.relation, pr, client_data);
             pr_n("</value>\n", pr, client_data, 0);
             pr_n("<relation>\n", pr, client_data, level+2);
             pr_n("<value>", pr, client_data, level+4);
             pr_cdata(cn->u.st.relation, pr, client_data);
             pr_n("</value>\n", pr, client_data, 0);
-            if (m)
-            {
-                pr_n("<modifiers>\n", pr, client_data, level+4);
-                for (; m; m = m->u.mod.next)
-                {
-                    pr_n("<modifier><value>", pr, client_data, level+6);
-                    pr_cdata(m->u.mod.value, pr, client_data);
-                    pr_n("</value></modifier>\n", pr, client_data, 0);
-                }
-                pr_n("</modifiers>\n", pr, client_data, level+4);
-            }
+
+           cql_to_xml_mod(cn->u.st.modifiers,
+                          pr, client_data, level+4);
+
             pr_n("</relation>\n", pr, client_data, level+2);
         }
         if (cn->u.st.term)
             pr_n("</relation>\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)
         {
         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("<boolean>\n", pr, client_data, level+2);
 
             pr_n("<value>", pr, client_data, level+4);
             pr_cdata(cn->u.boolean.value, pr, client_data);
             pr_n("</value>\n", pr, client_data, 0);
 
             pr_n("<boolean>\n", pr, client_data, level+2);
 
             pr_n("<value>", pr, client_data, level+4);
             pr_cdata(cn->u.boolean.value, pr, client_data);
             pr_n("</value>\n", pr, client_data, 0);
 
-            if (m)
-            {
-                pr_n("<modifiers>\n", pr, client_data, level+4);
-                for (; m; m = m->u.mod.next)
-                {
-                    pr_n("<modifier><type>", pr, client_data, level+6);
-                    pr_cdata(m->u.mod.name, pr, client_data);
-                    pr_n("</type>", pr, client_data, 0);
-                    if (m->u.mod.value)
-                    {
-                        pr_n("<value>", pr, client_data, 0);
-                        pr_cdata(m->u.mod.value, pr, client_data);
-                        pr_n("</value>", pr, client_data, 0);
-                    }
-                    pr_n("</modifier>\n", pr, client_data, 0);
-                }
-                pr_n("</modifiers>\n", pr, client_data, level+4);
-            }
+           cql_to_xml_mod(cn->u.boolean.modifiers,
+                          pr, client_data, level+4);
+
             pr_n("</boolean>\n", pr, client_data, level+2);
         }
         if (cn->u.boolean.left)
             pr_n("</boolean>\n", pr, client_data, level+2);
         }
         if (cn->u.boolean.left)
index 02f7e07..8dda4f6 100644 (file)
@@ -1,18 +1,24 @@
-## Copyright (C) 1994-2003, Index Data
+## Copyright (C) 1994-2004, Index Data
 ## All rights reserved.
 ## 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_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)
 
 
 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
 # 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 (file)
index 0000000..0f46ad0
--- /dev/null
@@ -0,0 +1,2 @@
+*.tmp
+*.diff
diff --git a/test/cql/1.1.err b/test/cql/1.1.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/1.1.out b/test/cql/1.1.out
new file mode 100644 (file)
index 0000000..04e6f3f
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>cql.serverChoice</index>
+  <relation>
+    <value>scr</value>
+  </relation>
+  <term>cat</term>
+</searchClause>
diff --git a/test/cql/1.10.err b/test/cql/1.10.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/1.10.out b/test/cql/1.10.out
new file mode 100644 (file)
index 0000000..a44a871
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>cql.serverChoice</index>
+  <relation>
+    <value>scr</value>
+  </relation>
+  <term>all</term>
+</searchClause>
diff --git a/test/cql/1.11.err b/test/cql/1.11.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/1.11.out b/test/cql/1.11.out
new file mode 100644 (file)
index 0000000..6aa73cd
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>cql.serverChoice</index>
+  <relation>
+    <value>scr</value>
+  </relation>
+  <term>prox</term>
+</searchClause>
diff --git a/test/cql/1.2.err b/test/cql/1.2.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/1.2.out b/test/cql/1.2.out
new file mode 100644 (file)
index 0000000..04e6f3f
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>cql.serverChoice</index>
+  <relation>
+    <value>scr</value>
+  </relation>
+  <term>cat</term>
+</searchClause>
diff --git a/test/cql/1.3.err b/test/cql/1.3.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/1.3.out b/test/cql/1.3.out
new file mode 100644 (file)
index 0000000..216c15c
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>cql.serverChoice</index>
+  <relation>
+    <value>scr</value>
+  </relation>
+  <term>comp.os.linux</term>
+</searchClause>
diff --git a/test/cql/1.4.err b/test/cql/1.4.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/1.4.out b/test/cql/1.4.out
new file mode 100644 (file)
index 0000000..9b2ab93
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>cql.serverChoice</index>
+  <relation>
+    <value>scr</value>
+  </relation>
+  <term>ml:element</term>
+</searchClause>
diff --git a/test/cql/1.5.err b/test/cql/1.5.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/1.5.out b/test/cql/1.5.out
new file mode 100644 (file)
index 0000000..4ce7bc2
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>cql.serverChoice</index>
+  <relation>
+    <value>scr</value>
+  </relation>
+  <term>&lt;xml:element&gt;</term>
+</searchClause>
diff --git a/test/cql/1.6.err b/test/cql/1.6.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/1.6.out b/test/cql/1.6.out
new file mode 100644 (file)
index 0000000..d7786cb
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>cql.serverChoice</index>
+  <relation>
+    <value>scr</value>
+  </relation>
+  <term>=</term>
+</searchClause>
diff --git a/test/cql/1.7.err b/test/cql/1.7.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/1.7.out b/test/cql/1.7.out
new file mode 100644 (file)
index 0000000..29742fc
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>cql.serverChoice</index>
+  <relation>
+    <value>scr</value>
+  </relation>
+  <term>prox/distance&lt;3/unit=word</term>
+</searchClause>
diff --git a/test/cql/1.8.err b/test/cql/1.8.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/1.8.out b/test/cql/1.8.out
new file mode 100644 (file)
index 0000000..04e6f3f
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>cql.serverChoice</index>
+  <relation>
+    <value>scr</value>
+  </relation>
+  <term>cat</term>
+</searchClause>
diff --git a/test/cql/1.9.err b/test/cql/1.9.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/1.9.out b/test/cql/1.9.out
new file mode 100644 (file)
index 0000000..b8cbb85
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>cql.serverChoice</index>
+  <relation>
+    <value>scr</value>
+  </relation>
+  <term>dog</term>
+</searchClause>
diff --git a/test/cql/10.1.err b/test/cql/10.1.err
new file mode 100644 (file)
index 0000000..f83d884
--- /dev/null
@@ -0,0 +1 @@
+Syntax error
diff --git a/test/cql/10.1.out b/test/cql/10.1.out
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/10.10.err b/test/cql/10.10.err
new file mode 100644 (file)
index 0000000..f83d884
--- /dev/null
@@ -0,0 +1 @@
+Syntax error
diff --git a/test/cql/10.10.out b/test/cql/10.10.out
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/10.2.err b/test/cql/10.2.err
new file mode 100644 (file)
index 0000000..f83d884
--- /dev/null
@@ -0,0 +1 @@
+Syntax error
diff --git a/test/cql/10.2.out b/test/cql/10.2.out
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/10.3.err b/test/cql/10.3.err
new file mode 100644 (file)
index 0000000..f83d884
--- /dev/null
@@ -0,0 +1 @@
+Syntax error
diff --git a/test/cql/10.3.out b/test/cql/10.3.out
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/10.4.err b/test/cql/10.4.err
new file mode 100644 (file)
index 0000000..f83d884
--- /dev/null
@@ -0,0 +1 @@
+Syntax error
diff --git a/test/cql/10.4.out b/test/cql/10.4.out
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/10.5.err b/test/cql/10.5.err
new file mode 100644 (file)
index 0000000..f83d884
--- /dev/null
@@ -0,0 +1 @@
+Syntax error
diff --git a/test/cql/10.5.out b/test/cql/10.5.out
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/10.6.err b/test/cql/10.6.err
new file mode 100644 (file)
index 0000000..f83d884
--- /dev/null
@@ -0,0 +1 @@
+Syntax error
diff --git a/test/cql/10.6.out b/test/cql/10.6.out
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/10.7.err b/test/cql/10.7.err
new file mode 100644 (file)
index 0000000..f83d884
--- /dev/null
@@ -0,0 +1 @@
+Syntax error
diff --git a/test/cql/10.7.out b/test/cql/10.7.out
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/10.8.err b/test/cql/10.8.err
new file mode 100644 (file)
index 0000000..f83d884
--- /dev/null
@@ -0,0 +1 @@
+Syntax error
diff --git a/test/cql/10.8.out b/test/cql/10.8.out
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/10.9.err b/test/cql/10.9.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/10.9.out b/test/cql/10.9.out
new file mode 100644 (file)
index 0000000..e910b08
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>title</index>
+  <relation>
+    <value>=</value>
+  </relation>
+  <term>illegal parentheses</term>
+</searchClause>
diff --git a/test/cql/2.1.err b/test/cql/2.1.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/2.1.out b/test/cql/2.1.out
new file mode 100644 (file)
index 0000000..be3c9c1
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>title</index>
+  <relation>
+    <value>=</value>
+  </relation>
+  <term>fish</term>
+</searchClause>
diff --git a/test/cql/2.10.err b/test/cql/2.10.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/2.10.out b/test/cql/2.10.out
new file mode 100644 (file)
index 0000000..d7dfe7a
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>title</index>
+  <relation>
+    <value>any</value>
+  </relation>
+  <term>frog</term>
+</searchClause>
diff --git a/test/cql/2.11.err b/test/cql/2.11.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/2.11.out b/test/cql/2.11.out
new file mode 100644 (file)
index 0000000..bc04886
--- /dev/null
@@ -0,0 +1,13 @@
+<searchClause>
+  <index>dc.title</index>
+  <relation>
+    <value>any</value>
+    <modifiers>
+      <modifier>
+        <type>stem</type>
+        <relation>=</relation>
+      </modifier>
+    </modifiers>
+  </relation>
+  <term>frog pond</term>
+</searchClause>
diff --git a/test/cql/2.12.err b/test/cql/2.12.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/2.12.out b/test/cql/2.12.out
new file mode 100644 (file)
index 0000000..a648cc5
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>dc.title</index>
+  <relation>
+    <value>scr</value>
+  </relation>
+  <term>fish frog chicken</term>
+</searchClause>
diff --git a/test/cql/2.13.err b/test/cql/2.13.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/2.13.out b/test/cql/2.13.out
new file mode 100644 (file)
index 0000000..4e66231
--- /dev/null
@@ -0,0 +1,14 @@
+<searchClause>
+  <index>dc.title</index>
+  <relation>
+    <value>=</value>
+    <modifiers>
+      <modifier>
+        <type>rel.algorithm</type>
+        <relation>=</relation>
+        <value>CORI</value>
+      </modifier>
+    </modifiers>
+  </relation>
+  <term>squid</term>
+</searchClause>
diff --git a/test/cql/2.14.err b/test/cql/2.14.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/2.14.out b/test/cql/2.14.out
new file mode 100644 (file)
index 0000000..e1e02a8
--- /dev/null
@@ -0,0 +1,18 @@
+<searchClause>
+  <index>creator</index>
+  <relation>
+    <value>any</value>
+    <modifiers>
+      <modifier>
+        <type>b.bar</type>
+        <relation>&gt;</relation>
+        <value>1</value>
+      </modifier>
+      <modifier>
+        <type>f.foo</type>
+        <relation>=</relation>
+      </modifier>
+    </modifiers>
+  </relation>
+  <term>sanderson taylor</term>
+</searchClause>
diff --git a/test/cql/2.2.err b/test/cql/2.2.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/2.2.out b/test/cql/2.2.out
new file mode 100644 (file)
index 0000000..2b78ddf
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>title</index>
+  <relation>
+    <value>exact</value>
+  </relation>
+  <term>fish</term>
+</searchClause>
diff --git a/test/cql/2.3.err b/test/cql/2.3.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/2.3.out b/test/cql/2.3.out
new file mode 100644 (file)
index 0000000..62521be
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>title</index>
+  <relation>
+    <value>any</value>
+  </relation>
+  <term>fish</term>
+</searchClause>
diff --git a/test/cql/2.4.err b/test/cql/2.4.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/2.4.out b/test/cql/2.4.out
new file mode 100644 (file)
index 0000000..646c973
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>title</index>
+  <relation>
+    <value>all</value>
+  </relation>
+  <term>fish</term>
+</searchClause>
diff --git a/test/cql/2.5.err b/test/cql/2.5.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/2.5.out b/test/cql/2.5.out
new file mode 100644 (file)
index 0000000..92411c4
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>title</index>
+  <relation>
+    <value>&gt;</value>
+  </relation>
+  <term>9</term>
+</searchClause>
diff --git a/test/cql/2.6.err b/test/cql/2.6.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/2.6.out b/test/cql/2.6.out
new file mode 100644 (file)
index 0000000..6702471
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>title</index>
+  <relation>
+    <value>&gt;=</value>
+  </relation>
+  <term>23</term>
+</searchClause>
diff --git a/test/cql/2.7.err b/test/cql/2.7.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/2.7.out b/test/cql/2.7.out
new file mode 100644 (file)
index 0000000..ba4ac78
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>dc.title</index>
+  <relation>
+    <value>any</value>
+  </relation>
+  <term>fish chips</term>
+</searchClause>
diff --git a/test/cql/2.8.err b/test/cql/2.8.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/2.8.out b/test/cql/2.8.out
new file mode 100644 (file)
index 0000000..3f45441
--- /dev/null
@@ -0,0 +1,13 @@
+<searchClause>
+  <index>dc.title</index>
+  <relation>
+    <value>any</value>
+    <modifiers>
+      <modifier>
+        <type>stem</type>
+        <relation>=</relation>
+      </modifier>
+    </modifiers>
+  </relation>
+  <term>fish</term>
+</searchClause>
diff --git a/test/cql/2.9.err b/test/cql/2.9.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/2.9.out b/test/cql/2.9.out
new file mode 100644 (file)
index 0000000..1222fac
--- /dev/null
@@ -0,0 +1,17 @@
+<searchClause>
+  <index>dc.fish</index>
+  <relation>
+    <value>all</value>
+    <modifiers>
+      <modifier>
+        <type>fuzzy</type>
+        <relation>=</relation>
+      </modifier>
+      <modifier>
+        <type>stem</type>
+        <relation>=</relation>
+      </modifier>
+    </modifiers>
+  </relation>
+  <term>fish chips</term>
+</searchClause>
diff --git a/test/cql/3.1.err b/test/cql/3.1.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/3.1.out b/test/cql/3.1.out
new file mode 100644 (file)
index 0000000..de0acae
--- /dev/null
@@ -0,0 +1,23 @@
+<triple>
+  <boolean>
+    <value>or</value>
+  </boolean>
+  <leftOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>cat</term>
+    </searchClause>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>dog</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/3.2.err b/test/cql/3.2.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/3.2.out b/test/cql/3.2.out
new file mode 100644 (file)
index 0000000..f5dba0b
--- /dev/null
@@ -0,0 +1,23 @@
+<triple>
+  <boolean>
+    <value>and</value>
+  </boolean>
+  <leftOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>cat</term>
+    </searchClause>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>fish</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/3.3.err b/test/cql/3.3.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/3.3.out b/test/cql/3.3.out
new file mode 100644 (file)
index 0000000..895ee06
--- /dev/null
@@ -0,0 +1,23 @@
+<triple>
+  <boolean>
+    <value>not</value>
+  </boolean>
+  <leftOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>cat</term>
+    </searchClause>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>frog</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/3.4.err b/test/cql/3.4.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/3.4.out b/test/cql/3.4.out
new file mode 100644 (file)
index 0000000..895ee06
--- /dev/null
@@ -0,0 +1,23 @@
+<triple>
+  <boolean>
+    <value>not</value>
+  </boolean>
+  <leftOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>cat</term>
+    </searchClause>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>frog</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/3.5.err b/test/cql/3.5.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/3.5.out b/test/cql/3.5.out
new file mode 100644 (file)
index 0000000..4627440
--- /dev/null
@@ -0,0 +1,23 @@
+<triple>
+  <boolean>
+    <value>not</value>
+  </boolean>
+  <leftOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>cat</term>
+    </searchClause>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>fish food</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/3.6.err b/test/cql/3.6.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/3.6.out b/test/cql/3.6.out
new file mode 100644 (file)
index 0000000..049b9d8
--- /dev/null
@@ -0,0 +1,23 @@
+<triple>
+  <boolean>
+    <value>and</value>
+  </boolean>
+  <leftOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>xml</term>
+    </searchClause>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>prox///</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/3.7.err b/test/cql/3.7.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/3.7.out b/test/cql/3.7.out
new file mode 100644 (file)
index 0000000..0a62182
--- /dev/null
@@ -0,0 +1,23 @@
+<triple>
+  <boolean>
+    <value>and</value>
+  </boolean>
+  <leftOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>fred</term>
+    </searchClause>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>any</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/3.8.err b/test/cql/3.8.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/3.8.out b/test/cql/3.8.out
new file mode 100644 (file)
index 0000000..d971224
--- /dev/null
@@ -0,0 +1,23 @@
+<triple>
+  <boolean>
+    <value>or</value>
+  </boolean>
+  <leftOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>fred</term>
+    </searchClause>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>all</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/3.9.err b/test/cql/3.9.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/3.9.out b/test/cql/3.9.out
new file mode 100644 (file)
index 0000000..9b7f604
--- /dev/null
@@ -0,0 +1,55 @@
+<triple>
+  <boolean>
+    <value>not</value>
+  </boolean>
+  <leftOperand>
+    <triple>
+      <boolean>
+        <value>and</value>
+      </boolean>
+      <leftOperand>
+        <triple>
+          <boolean>
+            <value>or</value>
+          </boolean>
+          <leftOperand>
+            <searchClause>
+              <index>cql.serverChoice</index>
+              <relation>
+                <value>scr</value>
+              </relation>
+              <term>a</term>
+            </searchClause>
+          </leftOperand>
+          <rightOperand>
+            <searchClause>
+              <index>cql.serverChoice</index>
+              <relation>
+                <value>scr</value>
+              </relation>
+              <term>b</term>
+            </searchClause>
+          </rightOperand>
+        </triple>
+      </leftOperand>
+      <rightOperand>
+        <searchClause>
+          <index>cql.serverChoice</index>
+          <relation>
+            <value>scr</value>
+          </relation>
+          <term>c</term>
+        </searchClause>
+      </rightOperand>
+    </triple>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>d</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/4.1.err b/test/cql/4.1.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/4.1.out b/test/cql/4.1.out
new file mode 100644 (file)
index 0000000..6565168
--- /dev/null
@@ -0,0 +1,23 @@
+<triple>
+  <boolean>
+    <value>and</value>
+  </boolean>
+  <leftOperand>
+    <searchClause>
+      <index>bath.uniformTitle</index>
+      <relation>
+        <value>any</value>
+      </relation>
+      <term>fish</term>
+    </searchClause>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>dc.title</index>
+      <relation>
+        <value>any</value>
+      </relation>
+      <term>cat dog</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/4.2.err b/test/cql/4.2.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/4.2.out b/test/cql/4.2.out
new file mode 100644 (file)
index 0000000..9280263
--- /dev/null
@@ -0,0 +1,29 @@
+<triple>
+  <boolean>
+    <value>or</value>
+  </boolean>
+  <leftOperand>
+    <searchClause>
+      <index>title</index>
+      <relation>
+        <value>any</value>
+        <modifiers>
+          <modifier>
+            <type>stem</type>
+            <relation>=</relation>
+          </modifier>
+        </modifiers>
+      </relation>
+      <term>fish dog</term>
+    </searchClause>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>and</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/5.1.err b/test/cql/5.1.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/5.1.out b/test/cql/5.1.out
new file mode 100644 (file)
index 0000000..b42c733
--- /dev/null
@@ -0,0 +1,23 @@
+<triple>
+  <boolean>
+    <value>prox</value>
+  </boolean>
+  <leftOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>cat</term>
+    </searchClause>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>hat</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/5.2.err b/test/cql/5.2.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/5.2.out b/test/cql/5.2.out
new file mode 100644 (file)
index 0000000..1ad4e8a
--- /dev/null
@@ -0,0 +1,39 @@
+<triple>
+  <boolean>
+    <value>prox</value>
+    <modifiers>
+      <modifier>
+        <type>ordered</type>
+        <relation>=</relation>
+      </modifier>
+      <modifier>
+        <type>unit</type>
+        <relation>=</relation>
+        <value>word</value>
+      </modifier>
+      <modifier>
+        <type>distance</type>
+        <relation>=</relation>
+        <value>3</value>
+      </modifier>
+    </modifiers>
+  </boolean>
+  <leftOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>cat</term>
+    </searchClause>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>hat</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/5.3.err b/test/cql/5.3.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/5.3.out b/test/cql/5.3.out
new file mode 100644 (file)
index 0000000..7700548
--- /dev/null
@@ -0,0 +1,30 @@
+<triple>
+  <boolean>
+    <value>prox</value>
+    <modifiers>
+      <modifier>
+        <type>distance</type>
+        <relation>&lt;</relation>
+        <value>3</value>
+      </modifier>
+    </modifiers>
+  </boolean>
+  <leftOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>cat</term>
+    </searchClause>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>hat</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/5.4.err b/test/cql/5.4.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/5.4.out b/test/cql/5.4.out
new file mode 100644 (file)
index 0000000..5e93079
--- /dev/null
@@ -0,0 +1,30 @@
+<triple>
+  <boolean>
+    <value>prox</value>
+    <modifiers>
+      <modifier>
+        <type>unit</type>
+        <relation>=</relation>
+        <value>sentence</value>
+      </modifier>
+    </modifiers>
+  </boolean>
+  <leftOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>fish food</term>
+    </searchClause>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>and</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/5.5.err b/test/cql/5.5.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/5.5.out b/test/cql/5.5.out
new file mode 100644 (file)
index 0000000..1d03784
--- /dev/null
@@ -0,0 +1,30 @@
+<triple>
+  <boolean>
+    <value>prox</value>
+    <modifiers>
+      <modifier>
+        <type>distance</type>
+        <relation>&lt;=</relation>
+        <value>5</value>
+      </modifier>
+    </modifiers>
+  </boolean>
+  <leftOperand>
+    <searchClause>
+      <index>title</index>
+      <relation>
+        <value>all</value>
+      </relation>
+      <term>chips frog</term>
+    </searchClause>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>exact</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/5.6.err b/test/cql/5.6.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/5.6.out b/test/cql/5.6.out
new file mode 100644 (file)
index 0000000..20a88e9
--- /dev/null
@@ -0,0 +1,35 @@
+<triple>
+  <boolean>
+    <value>prox</value>
+    <modifiers>
+      <modifier>
+        <type>unit</type>
+        <relation>=</relation>
+        <value>element</value>
+      </modifier>
+      <modifier>
+        <type>distance</type>
+        <relation>&gt;</relation>
+        <value>5</value>
+      </modifier>
+    </modifiers>
+  </boolean>
+  <leftOperand>
+    <searchClause>
+      <index>dc.author</index>
+      <relation>
+        <value>exact</value>
+      </relation>
+      <term>jones</term>
+    </searchClause>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>title</index>
+      <relation>
+        <value>&gt;=</value>
+      </relation>
+      <term>smith</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/5.7.err b/test/cql/5.7.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/5.7.out b/test/cql/5.7.out
new file mode 100644 (file)
index 0000000..5274289
--- /dev/null
@@ -0,0 +1,29 @@
+<triple>
+  <boolean>
+    <value>and</value>
+    <modifiers>
+      <modifier>
+        <type>rel.SumOfScores</type>
+        <relation>=</relation>
+      </modifier>
+    </modifiers>
+  </boolean>
+  <leftOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>a</term>
+    </searchClause>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>b</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/5.8.err b/test/cql/5.8.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/5.8.out b/test/cql/5.8.out
new file mode 100644 (file)
index 0000000..8759654
--- /dev/null
@@ -0,0 +1,30 @@
+<triple>
+  <boolean>
+    <value>and</value>
+    <modifiers>
+      <modifier>
+        <type>rel.algorithm</type>
+        <relation>=</relation>
+        <value>CORI</value>
+      </modifier>
+    </modifiers>
+  </boolean>
+  <leftOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>a</term>
+    </searchClause>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>b</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/6.1.err b/test/cql/6.1.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/6.1.out b/test/cql/6.1.out
new file mode 100644 (file)
index 0000000..6e59421
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>cql.serverChoice</index>
+  <relation>
+    <value>scr</value>
+  </relation>
+  <term>cat^</term>
+</searchClause>
diff --git a/test/cql/6.2.err b/test/cql/6.2.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/6.2.out b/test/cql/6.2.out
new file mode 100644 (file)
index 0000000..04e6f3f
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>cql.serverChoice</index>
+  <relation>
+    <value>scr</value>
+  </relation>
+  <term>cat</term>
+</searchClause>
diff --git a/test/cql/6.3.err b/test/cql/6.3.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/6.3.out b/test/cql/6.3.out
new file mode 100644 (file)
index 0000000..7411f1a
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>cql.serverChoice</index>
+  <relation>
+    <value>scr</value>
+  </relation>
+  <term>^cat says "fish"</term>
+</searchClause>
diff --git a/test/cql/6.4.err b/test/cql/6.4.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/6.4.out b/test/cql/6.4.out
new file mode 100644 (file)
index 0000000..4c5cf95
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>cql.serverChoice</index>
+  <relation>
+    <value>scr</value>
+  </relation>
+  <term>cat*fish</term>
+</searchClause>
diff --git a/test/cql/6.5.err b/test/cql/6.5.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/6.5.out b/test/cql/6.5.out
new file mode 100644 (file)
index 0000000..d82b932
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>cql.serverChoice</index>
+  <relation>
+    <value>scr</value>
+  </relation>
+  <term>cat?dog</term>
+</searchClause>
diff --git a/test/cql/6.6.err b/test/cql/6.6.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/6.6.out b/test/cql/6.6.out
new file mode 100644 (file)
index 0000000..f9851fb
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>cql.serverChoice</index>
+  <relation>
+    <value>scr</value>
+  </relation>
+  <term>^cat*fishdog"horse?</term>
+</searchClause>
diff --git a/test/cql/7.1.err b/test/cql/7.1.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/7.1.out b/test/cql/7.1.out
new file mode 100644 (file)
index 0000000..e9baec9
--- /dev/null
@@ -0,0 +1,55 @@
+<triple>
+  <boolean>
+    <value>and</value>
+  </boolean>
+  <leftOperand>
+    <triple>
+      <boolean>
+        <value>or</value>
+      </boolean>
+      <leftOperand>
+        <triple>
+          <boolean>
+            <value>or</value>
+          </boolean>
+          <leftOperand>
+            <searchClause>
+              <index>cql.serverChoice</index>
+              <relation>
+                <value>scr</value>
+              </relation>
+              <term>cat</term>
+            </searchClause>
+          </leftOperand>
+          <rightOperand>
+            <searchClause>
+              <index>cql.serverChoice</index>
+              <relation>
+                <value>scr</value>
+              </relation>
+              <term>dog</term>
+            </searchClause>
+          </rightOperand>
+        </triple>
+      </leftOperand>
+      <rightOperand>
+        <searchClause>
+          <index>cql.serverChoice</index>
+          <relation>
+            <value>scr</value>
+          </relation>
+          <term>horse</term>
+        </searchClause>
+      </rightOperand>
+    </triple>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>frog</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/7.2.err b/test/cql/7.2.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/7.2.out b/test/cql/7.2.out
new file mode 100644 (file)
index 0000000..8df4539
--- /dev/null
@@ -0,0 +1,55 @@
+<triple>
+  <boolean>
+    <value>or</value>
+  </boolean>
+  <leftOperand>
+    <triple>
+      <boolean>
+        <value>and</value>
+      </boolean>
+      <leftOperand>
+        <searchClause>
+          <index>cql.serverChoice</index>
+          <relation>
+            <value>scr</value>
+          </relation>
+          <term>cat</term>
+        </searchClause>
+      </leftOperand>
+      <rightOperand>
+        <searchClause>
+          <index>cql.serverChoice</index>
+          <relation>
+            <value>scr</value>
+          </relation>
+          <term>dog</term>
+        </searchClause>
+      </rightOperand>
+    </triple>
+  </leftOperand>
+  <rightOperand>
+    <triple>
+      <boolean>
+        <value>and</value>
+      </boolean>
+      <leftOperand>
+        <searchClause>
+          <index>cql.serverChoice</index>
+          <relation>
+            <value>scr</value>
+          </relation>
+          <term>horse</term>
+        </searchClause>
+      </leftOperand>
+      <rightOperand>
+        <searchClause>
+          <index>cql.serverChoice</index>
+          <relation>
+            <value>scr</value>
+          </relation>
+          <term>frog</term>
+        </searchClause>
+      </rightOperand>
+    </triple>
+  </rightOperand>
+</triple>
diff --git a/test/cql/7.3.err b/test/cql/7.3.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/7.3.out b/test/cql/7.3.out
new file mode 100644 (file)
index 0000000..3a057fd
--- /dev/null
@@ -0,0 +1,55 @@
+<triple>
+  <boolean>
+    <value>and</value>
+  </boolean>
+  <leftOperand>
+    <triple>
+      <boolean>
+        <value>and</value>
+      </boolean>
+      <leftOperand>
+        <searchClause>
+          <index>cql.serverChoice</index>
+          <relation>
+            <value>scr</value>
+          </relation>
+          <term>cat</term>
+        </searchClause>
+      </leftOperand>
+      <rightOperand>
+        <triple>
+          <boolean>
+            <value>or</value>
+          </boolean>
+          <leftOperand>
+            <searchClause>
+              <index>cql.serverChoice</index>
+              <relation>
+                <value>scr</value>
+              </relation>
+              <term>horse</term>
+            </searchClause>
+          </leftOperand>
+          <rightOperand>
+            <searchClause>
+              <index>cql.serverChoice</index>
+              <relation>
+                <value>scr</value>
+              </relation>
+              <term>frog</term>
+            </searchClause>
+          </rightOperand>
+        </triple>
+      </rightOperand>
+    </triple>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>cql.serverChoice</index>
+      <relation>
+        <value>scr</value>
+      </relation>
+      <term>chips</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/8.1.err b/test/cql/8.1.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/8.1.out b/test/cql/8.1.out
new file mode 100644 (file)
index 0000000..2b489af
--- /dev/null
@@ -0,0 +1,13 @@
+<searchClause>
+  <prefixes>
+    <prefix>
+      <name>foo</name>
+      <identifier>info:srw/cql-context-set/1/dc-v1.1</identifier>
+    </prefix>
+  </prefixes>
+  <index>dc.title</index>
+  <relation>
+    <value>=</value>
+  </relation>
+  <term>fish</term>
+</searchClause>
diff --git a/test/cql/8.2.err b/test/cql/8.2.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/8.2.out b/test/cql/8.2.out
new file mode 100644 (file)
index 0000000..b86dbf2
--- /dev/null
@@ -0,0 +1,12 @@
+<searchClause>
+  <prefixes>
+    <prefix>
+      <identifier>info:srw/cql-context-set/1/dc-v1.1</identifier>
+    </prefix>
+  </prefixes>
+  <index>title</index>
+  <relation>
+    <value>=</value>
+  </relation>
+  <term>fish</term>
+</searchClause>
diff --git a/test/cql/8.3.err b/test/cql/8.3.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/8.3.out b/test/cql/8.3.out
new file mode 100644 (file)
index 0000000..4eebbd3
--- /dev/null
@@ -0,0 +1,33 @@
+<triple>
+  <prefixes>
+    <prefix>
+      <name>foo</name>
+      <identifier>info:srw/cql-context-set/1/dc-v1.1</identifier>
+    </prefix>
+    <prefix>
+      <name>ccg</name>
+      <identifier>http://srw.cheshire3.org/contextSets/ccg/1.1/</identifier>
+    </prefix>
+  </prefixes>
+  <boolean>
+    <value>and</value>
+  </boolean>
+  <leftOperand>
+    <searchClause>
+      <index>foo.title</index>
+      <relation>
+        <value>=</value>
+      </relation>
+      <term>fish</term>
+    </searchClause>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>ccg.force</index>
+      <relation>
+        <value>=</value>
+      </relation>
+      <term>3</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/9.1.err b/test/cql/9.1.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/9.1.out b/test/cql/9.1.out
new file mode 100644 (file)
index 0000000..eac3a28
--- /dev/null
@@ -0,0 +1,55 @@
+<triple>
+  <boolean>
+    <value>prox</value>
+  </boolean>
+  <leftOperand>
+    <triple>
+      <boolean>
+        <value>and</value>
+      </boolean>
+      <leftOperand>
+        <triple>
+          <boolean>
+            <value>or</value>
+          </boolean>
+          <leftOperand>
+            <searchClause>
+              <index>cql.serverChoice</index>
+              <relation>
+                <value>scr</value>
+              </relation>
+              <term>any</term>
+            </searchClause>
+          </leftOperand>
+          <rightOperand>
+            <searchClause>
+              <index>cql.serverChoice</index>
+              <relation>
+                <value>scr</value>
+              </relation>
+              <term>all:stem</term>
+            </searchClause>
+          </rightOperand>
+        </triple>
+      </leftOperand>
+      <rightOperand>
+        <searchClause>
+          <index>all</index>
+          <relation>
+            <value>exact</value>
+          </relation>
+          <term>any</term>
+        </searchClause>
+      </rightOperand>
+    </triple>
+  </leftOperand>
+  <rightOperand>
+    <searchClause>
+      <index>prox</index>
+      <relation>
+        <value>=</value>
+      </relation>
+      <term>fuzzy</term>
+    </searchClause>
+  </rightOperand>
+</triple>
diff --git a/test/cql/9.2.err b/test/cql/9.2.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/9.2.out b/test/cql/9.2.out
new file mode 100644 (file)
index 0000000..eb0d4a9
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>cql.serverChoice</index>
+  <relation>
+    <value>scr</value>
+  </relation>
+  <term>any</term>
+</searchClause>
diff --git a/test/cql/9.3.err b/test/cql/9.3.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/9.3.out b/test/cql/9.3.out
new file mode 100644 (file)
index 0000000..ee798ea
--- /dev/null
@@ -0,0 +1,7 @@
+<searchClause>
+  <index>cql.serverChoice</index>
+  <relation>
+    <value>scr</value>
+  </relation>
+  <term></term>
+</searchClause>
diff --git a/test/cql/9.4.err b/test/cql/9.4.err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/cql/9.4.out b/test/cql/9.4.out
new file mode 100644 (file)
index 0000000..aed8eca
--- /dev/null
@@ -0,0 +1,16 @@
+<searchClause>
+  <prefixes>
+    <prefix>
+      <identifier>any</identifier>
+    </prefix>
+    <prefix>
+      <name>any</name>
+      <identifier>exact</identifier>
+    </prefix>
+  </prefixes>
+  <index>any</index>
+  <relation>
+    <value>&gt;</value>
+  </relation>
+  <term>any</term>
+</searchClause>
diff --git a/test/cqlsample b/test/cqlsample
new file mode 100644 (file)
index 0000000..c9f88b5
--- /dev/null
@@ -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
+"<xml: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 (executable)
index 0000000..2f41aba
--- /dev/null
@@ -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
index e389069..2dadb4c 100644 (file)
@@ -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
 
    Copyright (C) 2002-2003
    Index Data Aps
 
@@ -13,10 +13,33 @@ See the file LICENSE.
 
 int main(int argc, char **argv)
 {
 
 int main(int argc, char **argv)
 {
+    CQL_parser cp;
     int r;
     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<iterations; i++)
+           r = cql_parser_string(cp, fname);
+    }
     else
         r = cql_parser_stdio(cp, stdin);
     if (r)
     else
         r = cql_parser_stdio(cp, stdin);
     if (r)
index be4e2c8..d6b43d2 100644 (file)
@@ -1,6 +1,6 @@
-# Copyright (C) 1994-2003, Index Data
+# Copyright (C) 1994-2004, Index Data
 # All rights reserved.
 # All rights reserved.
-# $Id: makefile,v 1.69 2004-01-12 12:11:58 adam Exp $
+# $Id: makefile,v 1.70 2004-03-10 16:34:31 adam Exp $
 #
 # Programmed by
 #  HL: Heikki Levanto, Index Data
 #
 # Programmed by
 #  HL: Heikki Levanto, Index Data