From: Adam Dickmeiss Date: Sun, 6 Jan 2008 16:22:02 +0000 (+0000) Subject: Added support for free-form-terms. Bug #609: HDCQL. X-Git-Tag: YAZ.3.0.20~18 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=a29d852d610296e871716c137337fb44510eee1d;p=yaz-moved-to-github.git Added support for free-form-terms. Bug #609: HDCQL. --- diff --git a/include/yaz/cql.h b/include/yaz/cql.h index 458d630..ddd7144 100644 --- a/include/yaz/cql.h +++ b/include/yaz/cql.h @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* $Id: cql.h,v 1.19 2007-11-14 21:03:59 adam Exp $ */ +/* $Id: cql.h,v 1.20 2008-01-06 16:22:02 adam Exp $ */ /** \file cql.h \brief Header with public definitions about CQL. @@ -121,6 +121,8 @@ struct cql_node { char *relation_uri; /** relation modifiers */ struct cql_node *modifiers; + /** term list */ + struct cql_node *extra_terms; } st; /** which == CQL_NODE_BOOL */ struct { diff --git a/src/cql.y b/src/cql.y index 8daf2cb..2670216 100644 --- a/src/cql.y +++ b/src/cql.y @@ -1,4 +1,4 @@ -/* $Id: cql.y,v 1.16 2008-01-06 13:08:09 adam Exp $ +/* $Id: cql.y,v 1.17 2008-01-06 16:22:02 adam Exp $ Copyright (C) 2002-2006 Index Data ApS @@ -121,8 +121,9 @@ searchClause: $$.cql = $3.cql; } | - searchTerm { - struct cql_node *st = cql_node_dup (((CQL_parser) parm)->nmem, $0.rel); +searchTerm extraTerms { + struct cql_node *st = cql_node_dup(((CQL_parser) parm)->nmem, $0.rel); + st->u.st.extra_terms = $2.cql; st->u.st.term = nmem_strdup(((CQL_parser)parm)->nmem, $1.buf); $$.cql = st; } @@ -136,6 +137,18 @@ searchClause: } ; +extraTerms: +extraTerms TERM { + struct cql_node *st = cql_node_mk_sc(((CQL_parser) parm)->nmem, + /* index */ 0, /* rel */ 0, $2.buf); + st->u.st.extra_terms = $1.cql; + $$.cql = st; +} +| +{ $$.cql = 0; } +; + + /* unary NOT search TERM here .. */ boolean: @@ -164,11 +177,6 @@ modifiers '/' searchTerm mrelation searchTerm } ; -/* -extraTerms: - extraTerms TERM | ; -*/ - mrelation: '=' | '>' diff --git a/src/cqlutil.c b/src/cqlutil.c index 836d840..2c25dea 100644 --- a/src/cqlutil.c +++ b/src/cqlutil.c @@ -1,4 +1,4 @@ -/* $Id: cqlutil.c,v 1.12 2008-01-06 13:08:09 adam Exp $ +/* $Id: cqlutil.c,v 1.13 2008-01-06 16:22:02 adam Exp $ Copyright (C) 1995-2007, Index Data ApS Index Data Aps @@ -68,6 +68,7 @@ struct cql_node *cql_node_mk_sc(NMEM nmem, p->u.st.relation = nmem_strdup(nmem, relation); p->u.st.relation_uri = 0; p->u.st.modifiers = 0; + p->u.st.extra_terms = 0; return p; } diff --git a/src/xcqlutil.c b/src/xcqlutil.c index 9eca708..99327c5 100644 --- a/src/xcqlutil.c +++ b/src/xcqlutil.c @@ -1,4 +1,4 @@ -/* $Id: xcqlutil.c,v 1.8 2007-06-28 07:58:07 adam Exp $ +/* $Id: xcqlutil.c,v 1.9 2008-01-06 16:22:02 adam Exp $ Copyright (C) 1995-2007, Index Data ApS Index Data Aps @@ -163,6 +163,16 @@ static void cql_to_xml_r(struct cql_node *cn, pr_cdata(cn->u.st.term, pr, client_data); pr_n("\n", pr, client_data, 0); } + if (cn->u.st.extra_terms) + { + struct cql_node *n = cn->u.st.extra_terms; + for (; n; n = n->u.st.extra_terms) + { + pr_n("", pr, client_data, level+2); + pr_cdata(n->u.st.term, pr, client_data); + pr_n("\n", pr, client_data, 0); + } + } pr_n("\n", pr, client_data, level); break; case CQL_NODE_BOOL: