projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cql_sortby_to_sortkeys: handle modifiers.
[yaz-moved-to-github.git]
/
src
/
cql.y
diff --git
a/src/cql.y
b/src/cql.y
index
25a4287
..
4021373
100644
(file)
--- a/
src/cql.y
+++ b/
src/cql.y
@@
-1,5
+1,5
@@
/* This file is part of the YAZ toolkit.
/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2008 Index Data
+ * Copyright (C) 1995-2011 Index Data
* See the file LICENSE for details.
*/
/* bison parser for CQL grammar. */
* See the file LICENSE for details.
*/
/* bison parser for CQL grammar. */
@@
-11,10
+11,13
@@
* This is a YACC parser, but since it must be reentrant, Bison is required.
* The original source file is cql.y.
*/
* This is a YACC parser, but since it must be reentrant, Bison is required.
* The original source file is cql.y.
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
+#include <yaz/yaz-iconv.h>
#include <yaz/xmalloc.h>
#include <yaz/nmem.h>
#include <yaz/cql.h>
#include <yaz/xmalloc.h>
#include <yaz/nmem.h>
#include <yaz/cql.h>
@@
-63,17
+66,35
@@
top: {
((CQL_parser) parm)->top = 0;
} cqlQuery1 sortby {
cql_node_destroy($$.rel);
((CQL_parser) parm)->top = 0;
} cqlQuery1 sortby {
cql_node_destroy($$.rel);
- ((CQL_parser) parm)->top = $2.cql;
+ if ($3.cql)
+ {
+ $3.cql->u.sort.search = $2.cql;
+ ((CQL_parser) parm)->top = $3.cql;
+ } else {
+ ((CQL_parser) parm)->top = $2.cql;
+ }
}
;
sortby: /* empty */
}
;
sortby: /* empty */
-| SORTBY sortSpec;
-
-sortSpec: sortSpec singleSpec
-| singleSpec;
+ { $$.cql = 0; }
+| SORTBY sortSpec {
+ $$.cql = $2.cql;
+ };
+
+sortSpec: sortSpec singleSpec {
+ $$.cql = $1.cql;
+ $$.cql->u.sort.next = $2.cql;
+ }
+| singleSpec
+{
+ $$.cql = $1.cql;
+};
-singleSpec: index modifiers ;
+singleSpec: index modifiers {
+ $$.cql = cql_node_mk_sort(((CQL_parser) parm)->nmem, $1.buf, $2.cql);
+ }
+;
cqlQuery1: cqlQuery
| cqlQuery error {
cqlQuery1: cqlQuery
| cqlQuery error {
@@
-263,7
+284,7
@@
int yylex(YYSTYPE *lval, void *vp)
return 0;
if (c == '\n')
return 0;
return 0;
if (c == '\n')
return 0;
- } while (isspace(c));
+ } while (yaz_isspace(c));
if (strchr("()=></", c))
{
int c1;
if (strchr("()=></", c))
{
int c1;
@@
-392,8
+413,7
@@
int cql_parser_stream(CQL_parser cp,
cp->getbyte = getbyte;
cp->ungetbyte = ungetbyte;
cp->client_data = client_data;
cp->getbyte = getbyte;
cp->ungetbyte = ungetbyte;
cp->client_data = client_data;
- if (cp->top)
- cql_node_destroy(cp->top);
+ cql_node_destroy(cp->top);
cql_parse(cp);
if (cp->top)
return 0;
cql_parse(cp);
if (cp->top)
return 0;
@@
-425,3
+445,12
@@
struct cql_node *cql_parser_result(CQL_parser cp)
{
return cp->top;
}
{
return cp->top;
}
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */