Modify CQL parser and transform code to become more CQL 1.2 compliant.
Default relation is '=' instead 'scr'. Relation for exact is ==
instead of 'exact'. Work on bug #609: HDCQL.
-# $Id: pqf.properties,v 1.13 2006-09-20 10:12:29 mike Exp $
+# $Id: pqf.properties,v 1.14 2008-01-06 13:08:09 adam Exp $
#
# Propeties file to drive org.z3950.zing.cql.CQLNode's toPQF()
# back-end and the YAZ CQL-to-PQF converter. This specifies the
# attributes.
# Identifiers for prefixes used in this file. (index.*)
-set.cql = info:srw/cql-context-set/1/cql-v1.1
+set.cql = info:srw/cql-context-set/1/cql-v1.2
set.rec = info:srw/cql-context-set/2/rec-1.1
set.dc = info:srw/cql-context-set/1/dc-v1.1
set.bath = http://zing.z3950.org/cql/bath/2.0/
-/* $Id: cql.y,v 1.15 2007-10-31 21:58:07 adam Exp $
+/* $Id: cql.y,v 1.16 2008-01-06 13:08:09 adam Exp $
Copyright (C) 2002-2006
Index Data ApS
%}
%pure_parser
-%token TERM AND OR NOT PROX GE LE NE
-%expect 9
+%token DOTTERM TERM AND OR NOT PROX GE LE NE EXACT
%%
top: {
$$.rel = cql_node_mk_sc(((CQL_parser) parm)->nmem,
- "cql.serverChoice", "scr", 0);
+ "cql.serverChoice", "=", 0);
((CQL_parser) parm)->top = 0;
} cqlQuery1 {
cql_node_destroy($$.rel);
}
;
-cqlQuery:
+cqlQuery:
+ scopedClause
+ |
+ '>' searchTerm '=' searchTerm {
+ $$.rel = $0.rel;
+ } cqlQuery {
+ $$.cql = cql_apply_prefix(((CQL_parser) parm)->nmem,
+ $6.cql, $2.buf, $4.buf);
+ }
+| '>' searchTerm {
+ $$.rel = $0.rel;
+ } cqlQuery {
+ $$.cql = cql_apply_prefix(((CQL_parser) parm)->nmem,
+ $4.cql, 0, $2.buf);
+ }
+;
+
+scopedClause:
searchClause
|
- cqlQuery boolean modifiers {
+ scopedClause boolean modifiers {
$$.rel = $0.rel;
} searchClause {
struct cql_node *cn = cql_node_mk_boolean(((CQL_parser) parm)->nmem,
$$.cql = $5.cql;
cql_node_destroy($4.rel);
}
-| '>' searchTerm '=' searchTerm {
- $$.rel = $0.rel;
- } cqlQuery {
- $$.cql = cql_apply_prefix(((CQL_parser) parm)->nmem,
- $6.cql, $2.buf, $4.buf);
- }
-| '>' searchTerm {
- $$.rel = $0.rel;
- } cqlQuery {
- $$.cql = cql_apply_prefix(((CQL_parser) parm)->nmem,
- $4.cql, 0, $2.buf);
- }
;
/* unary NOT search TERM here .. */
}
;
+/*
+extraTerms:
+ extraTerms TERM | ;
+*/
+
mrelation:
'='
| '>'
| GE
| LE
| NE
+| EXACT
;
relation:
| GE
| LE
| NE
-| TERM
+| EXACT
+| DOTTERM
;
index:
searchTerm:
TERM
+| DOTTERM
| AND
| OR
| NOT
{
int c1;
putb(lval, cp, c);
- if (c == '>')
+ if (c == '=')
+ {
+ c1 = cp->getbyte(cp->client_data);
+ if (c1 == '=')
+ {
+ putb(lval, cp, c1);
+ return EXACT;
+ }
+ else
+ cp->ungetbyte(c1, cp->client_data);
+ }
+ else if (c == '>')
{
c1 = cp->getbyte(cp->client_data);
if (c1 == '=')
putb(lval, cp, c);
}
putb(lval, cp, 0);
+ return TERM;
}
else
{
- while (c != 0 && !strchr(" \n()=<>/", c))
- {
- if (c == '\\')
+ int relation_like = 0;
+ while (c != 0 && !strchr(" \n()=<>/", c))
+ {
+ if (c == '.')
+ relation_like = 1;
+ if (c == '\\')
{
putb(lval, cp, c);
- c = cp->getbyte(cp->client_data);
+ c = cp->getbyte(cp->client_data);
if (!c)
break;
}
- putb(lval, cp, c);
+ putb(lval, cp, c);
c = cp->getbyte(cp->client_data);
- }
+ }
putb(lval, cp, 0);
#if YYDEBUG
- printf ("got %s\n", lval->buf);
+ printf ("got %s\n", lval->buf);
#endif
- if (c != 0)
- cp->ungetbyte(c, cp->client_data);
- if (!cql_strcmp(lval->buf, "and"))
+ if (c != 0)
+ cp->ungetbyte(c, cp->client_data);
+ if (!cql_strcmp(lval->buf, "and"))
{
lval->buf = "and";
- return AND;
+ return AND;
}
- if (!cql_strcmp(lval->buf, "or"))
+ if (!cql_strcmp(lval->buf, "or"))
{
lval->buf = "or";
- return OR;
+ return OR;
}
- if (!cql_strcmp(lval->buf, "not"))
+ if (!cql_strcmp(lval->buf, "not"))
{
lval->buf = "not";
- return NOT;
+ return NOT;
}
- if (!cql_strcmp(lval->buf, "prox"))
+ if (!cql_strcmp(lval->buf, "prox"))
{
lval->buf = "prox";
- return PROX;
+ return PROX;
}
+ if (!cql_strcmp(lval->buf, "all"))
+ relation_like = 1;
+ if (!cql_strcmp(lval->buf, "any"))
+ relation_like = 1;
+ if (relation_like)
+ return DOTTERM;
}
return TERM;
}
-/* $Id: cqltransform.c,v 1.30 2007-12-20 22:45:37 adam Exp $
+/* $Id: cqltransform.c,v 1.31 2008-01-06 13:08:09 adam Exp $
Copyright (C) 1995-2007, Index Data ApS
Index Data Aps
{
if (!res)
res = cql_lookup_property(ct, category, prefix, eval);
+ /* we have some aliases for some relations unfortunately.. */
+ if (!res && !prefix && !strcmp(category, "relation"))
+ {
+ if (!strcmp(val, "=="))
+ res = cql_lookup_property(ct, category, prefix, "exact");
+ if (!strcmp(val, "="))
+ res = cql_lookup_property(ct, category, prefix, "eq");
+ if (!strcmp(val, "<="))
+ res = cql_lookup_property(ct, category, prefix, "le");
+ if (!strcmp(val, ">="))
+ res = cql_lookup_property(ct, category, prefix, "ge");
+ }
if (!res)
res = cql_lookup_property(ct, category, prefix, "*");
}
}
}
cql_pr_attr(ct, "always", 0, 0, pr, client_data, 0);
- if (cn->u.st.relation && !cql_strcmp(cn->u.st.relation, "="))
- cql_pr_attr(ct, "relation", "eq", "scr",
- pr, client_data, 19);
- else if (cn->u.st.relation && !cql_strcmp(cn->u.st.relation, "<="))
- cql_pr_attr(ct, "relation", "le", "scr",
- pr, client_data, 19);
- else if (cn->u.st.relation && !cql_strcmp(cn->u.st.relation, ">="))
- cql_pr_attr(ct, "relation", "ge", "scr",
- pr, client_data, 19);
- else
- cql_pr_attr(ct, "relation", cn->u.st.relation, "eq",
- pr, client_data, 19);
+ cql_pr_attr(ct, "relation", cn->u.st.relation, 0, pr, client_data, 19);
cql_pr_attr(ct, "structure", cn->u.st.relation, 0,
pr, client_data, 24);
if (cn->u.st.relation && !cql_strcmp(cn->u.st.relation, "all"))
-/* $Id: cqlutil.c,v 1.11 2007-01-03 08:42:15 adam Exp $
+/* $Id: cqlutil.c,v 1.12 2008-01-06 13:08:09 adam Exp $
Copyright (C) 1995-2007, Index Data ApS
Index Data Aps
const char *cql_uri(void)
{
- return "info:srw/cql-context-set/1/cql-v1.1";
+ return "info:srw/cql-context-set/1/cql-v1.2";
}
struct cql_node *cql_apply_prefix(NMEM nmem,
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>cat</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>all</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>prox</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>cat</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>comp.os.linux</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>ml:element</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term><xml:element></term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>=</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>prox/distance<3/unit=word</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>cat</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>dog</term>
</searchClause>
<searchClause>
<index>dc.title</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>fish frog chicken</term>
</searchClause>
<searchClause>
<index>title</index>
<relation>
- <value>exact</value>
+ <value>==</value>
</relation>
<term>fish</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>cat</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>dog</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>cat</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>fish</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>cat</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>frog</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>cat</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>frog</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>cat</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>fish food</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>xml</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>prox///</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>fred</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>any</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>fred</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>all</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>a</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>b</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>c</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>d</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>and</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>cat</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>hat</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>cat</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>hat</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>cat</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>hat</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>fish food</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>and</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>exact</term>
</searchClause>
<searchClause>
<index>dc.author</index>
<relation>
- <value>exact</value>
+ <value>==</value>
</relation>
<term>jones</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>a</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>b</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>a</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>b</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>cat^</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>cat</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>^cat says \"fish\"</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>cat*fish</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>cat?dog</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>^cat*fishdog\"horse?</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>cat</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>dog</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>horse</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>frog</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>cat</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>dog</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>horse</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>frog</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>cat</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>horse</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>frog</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>chips</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>any</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>all:stem</term>
</searchClause>
<searchClause>
<index>all</index>
<relation>
- <value>exact</value>
+ <value>==</value>
</relation>
<term>any</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term>any</term>
</searchClause>
<searchClause>
<index>cql.serverChoice</index>
<relation>
- <value>scr</value>
+ <value>=</value>
</relation>
<term></term>
</searchClause>
-# $Id: cqlsample,v 1.2 2004-03-10 18:50:56 adam Exp $
+# $Id: cqlsample,v 1.3 2008-01-06 13:08:09 adam Exp $
# CQL queries for testing.
# from http://www.loc.gov/z3950/agency/zing/cql/sample-queries.html
# Simple Term
# Index Relation Term
title = "fish"
-title exact fish
+title == fish
title any fish
title all fish
title > 9
dc.fish all/stem/fuzzy "fish chips"
(title any frog)
((dc.title any/stem "frog pond"))
-dc.title scr "fish frog chicken"
+dc.title = "fish frog chicken"
dc.title =/rel.algorithm=CORI squid
creator any/f.foo/b.bar>1 "sanderson taylor"
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")
+(dc.author == "jones" prox/distance>5/unit=element title >= "smith")
a and/rel.SumOfScores b
a and/rel.algorithm=CORI b
# Lame Searches
-any or all:stem and all exact any prox prox=fuzzy
+any or all:stem and all == any prox prox=fuzzy
(((((((((any)))))))))
""
> any > any = exact any > any