X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fcql.y;h=4021373e46c1b79a1eebf8807b1d3885945ce307;hb=7dfff1f7b79d8a3cf5f5ed62c71f6e4c2a616072;hp=7bb83f848af886f93cfa995d634cca7580a9d735;hpb=43a9d38d20c1b1bcd1a03b2445a501d27526bd35;p=yaz-moved-to-github.git diff --git a/src/cql.y b/src/cql.y index 7bb83f8..4021373 100644 --- a/src/cql.y +++ b/src/cql.y @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -66,17 +66,35 @@ top: { ((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 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 { @@ -266,7 +284,7 @@ int yylex(YYSTYPE *lval, void *vp) return 0; if (c == '\n') return 0; - } while (isspace(c)); + } while (yaz_isspace(c)); if (strchr("()=>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; @@ -428,3 +445,12 @@ struct cql_node *cql_parser_result(CQL_parser cp) { return cp->top; } + +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */