From: Adam Dickmeiss Date: Tue, 16 Apr 2013 14:21:03 +0000 (+0200) Subject: cql_parser_strict X-Git-Tag: v4.2.54~4 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=5ae2f74ba9b27bb7e926d5908471ac79371f7823;p=yaz-moved-to-github.git cql_parser_strict cql_parser_strict with mode=1 puts CQL parser in a mode where CQL parser is conforming to standard. --- diff --git a/include/yaz/cql.h b/include/yaz/cql.h index a389ac4..cd36fe9 100644 --- a/include/yaz/cql.h +++ b/include/yaz/cql.h @@ -96,6 +96,16 @@ int cql_parser_stream(CQL_parser cp, YAZ_EXPORT int cql_parser_stdio(CQL_parser cp, FILE *f); +/** \brief configures strict mode + \param cp CQL parser + \param mode 1=enable strict mode, 0=disable strict mode + + This function is similar to cql_parser_string but reads from + stdio FILE handle instead. +*/ +YAZ_EXPORT +void cql_parser_strict(CQL_parser cp, int mode); + /** \brief Node type: search term */ #define CQL_NODE_ST 1 /** \brief Node type: boolean */ diff --git a/src/cql.y b/src/cql.y index d1d5d1b..5af8777 100644 --- a/src/cql.y +++ b/src/cql.y @@ -44,6 +44,7 @@ int last_pos; struct cql_node *top; NMEM nmem; + int strict; }; #define YYSTYPE token @@ -384,6 +385,8 @@ int yylex(YYSTYPE *lval, void *vp) lval->buf = "sortby"; return SORTBY; } + if (cp->strict) + return PREFIX_NAME; if (!cql_strcmp(lval->buf, "all")) relation_like = 1; if (!cql_strcmp(lval->buf, "any")) @@ -424,6 +427,7 @@ CQL_parser cql_parser_create(void) cp->last_error = 0; cp->last_pos = 0; cp->nmem = nmem_create(); + cp->strict = 0; return cp; } @@ -439,6 +443,11 @@ struct cql_node *cql_parser_result(CQL_parser cp) return cp->top; } +void cql_parser_strict(CQL_parser cp, int mode) +{ + cp->strict = mode; +} + /* * Local variables: * c-basic-offset: 4 diff --git a/util/cql2xcql.c b/util/cql2xcql.c index e2aa5c8..bad3f3e 100644 --- a/util/cql2xcql.c +++ b/util/cql2xcql.c @@ -15,7 +15,7 @@ static void usage(const char *prog) { - fprintf(stderr, "%s: [-c] [-n iterations] [-s] [infile]\n", prog); + fprintf(stderr, "%s: [-c] [-n iterations] [-s] [-S] [infile]\n", prog); exit(1); } @@ -30,8 +30,9 @@ int main(int argc, char **argv) char *arg; char *prog = argv[0]; int do_sortkeys = 0; + int do_strict = 0; - while ((ret = options("cn:s", argv, argc, &arg)) != YAZ_OPTIONS_EOF) + while ((ret = options("cn:sS", argv, argc, &arg)) != YAZ_OPTIONS_EOF) { switch (ret) { @@ -47,12 +48,16 @@ int main(int argc, char **argv) case 's': do_sortkeys = 1; break; + case 'S': + do_strict = 1; + break; default: usage(prog); } } cp = cql_parser_create(); + cql_parser_strict(cp, do_strict); if (fname) { int i;