X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fcql.y;h=7bb83f848af886f93cfa995d634cca7580a9d735;hb=7b1bbfddfb6e9d68c645388e3279a4990a6592ef;hp=c6151a23a05c0ccd8f3b9f76fd98128bc21d55d5;hpb=d940392c53c32ccf76fb287cc5b997b9e921a431;p=yaz-moved-to-github.git diff --git a/src/cql.y b/src/cql.y index c6151a2..7bb83f8 100644 --- a/src/cql.y +++ b/src/cql.y @@ -1,5 +1,5 @@ /* 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. */ @@ -11,6 +11,9 @@ * 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 +#endif #include #include #include @@ -53,7 +56,7 @@ %} %pure_parser -%token DOTTERM TERM AND OR NOT PROX GE LE NE EXACT +%token DOTTERM TERM AND OR NOT PROX GE LE NE EXACT SORTBY %% @@ -61,12 +64,20 @@ top: { $$.rel = cql_node_mk_sc(((CQL_parser) parm)->nmem, "cql.serverChoice", "=", 0); ((CQL_parser) parm)->top = 0; -} cqlQuery1 { +} cqlQuery1 sortby { cql_node_destroy($$.rel); ((CQL_parser) parm)->top = $2.cql; } ; +sortby: /* empty */ +| SORTBY sortSpec; + +sortSpec: sortSpec singleSpec +| singleSpec; + +singleSpec: index modifiers ; + cqlQuery1: cqlQuery | cqlQuery error { cql_node_destroy($1.cql); @@ -203,6 +214,7 @@ searchTerm: | OR | NOT | PROX +| SORTBY ; %% @@ -358,6 +370,11 @@ int yylex(YYSTYPE *lval, void *vp) lval->buf = "prox"; return PROX; } + if (!cql_strcmp(lval->buf, "sortby")) + { + lval->buf = "sortby"; + return SORTBY; + } if (!cql_strcmp(lval->buf, "all")) relation_like = 1; if (!cql_strcmp(lval->buf, "any"))