X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fcql.y;h=395389bcee36ef119b7be9afff3965e72a7285d0;hb=9549afd48c2dc297f9bcd832d7ef9cea8c336f13;hp=00d806a0e98a206d66078b6b360f266afac6fbc4;hpb=ed51c750eb5540c5a3a34ef3beb0c043a6e65f7c;p=yaz-moved-to-github.git diff --git a/src/cql.y b/src/cql.y index 00d806a..395389b 100644 --- a/src/cql.y +++ b/src/cql.y @@ -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 { @@ -169,7 +187,7 @@ modifiers: modifiers '/' searchTerm $$.cql = mod; } | -modifiers '/' searchTerm mrelation searchTerm +modifiers '/' searchTerm relation_symbol searchTerm { struct cql_node *mod = cql_node_mk_sc(((CQL_parser)parm)->nmem, $3.buf, $4.buf, $5.buf); @@ -183,17 +201,9 @@ modifiers '/' searchTerm mrelation searchTerm } ; -mrelation: - '=' -| '>' -| '<' -| GE -| LE -| NE -| EXACT -; +relation: DOTTERM | relation_symbol; -relation: +relation_symbol: '=' | '>' | '<' @@ -201,7 +211,6 @@ relation: | LE | NE | EXACT -| DOTTERM ; index: @@ -395,8 +404,7 @@ int cql_parser_stream(CQL_parser cp, 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; @@ -428,6 +436,7 @@ struct cql_node *cql_parser_result(CQL_parser cp) { return cp->top; } + /* * Local variables: * c-basic-offset: 4