1 /* $Id: cql.y,v 1.1 2003-01-06 08:20:27 adam Exp $
2 Copyright (C) 2002-2003
5 This file is part of the YAZ toolkit.
9 bison parser for CQL grammar.
27 int (*getbyte)(void *client_data);
28 void (*ungetbyte)(int b, void *client_data);
37 #define YYPARSE_PARAM parm
38 #define YYLEX_PARAM parm
40 int yylex(YYSTYPE *lval, void *vp);
45 %token TERM AND OR NOT PROX EXACT ALL ANY GE LE NE SCR
51 $$.rel = cql_node_mk_sc("srw.serverChoice", "scr", 0);
52 ((CQL_parser) parm)->top = 0;
54 cql_node_destroy($$.rel);
55 ((CQL_parser) parm)->top = $2.cql;
61 cql_node_destroy($1.cql);
72 struct cql_node *cn = cql_node_mk_boolean($2.buf);
74 cn->u.bool.modifiers = $2.rel;
75 cn->u.bool.left = $1.cql;
76 cn->u.bool.right = $4.cql;
91 struct cql_node *st = cql_node_dup ($0.rel);
92 st->u.st.term = strdup($1.buf);
98 $$.rel->u.st.index = strdup($1.buf);
101 cql_node_destroy($$.rel);
103 | '>' searchTerm '=' searchTerm {
106 $$.cql = cql_node_prefix($6.cql, $2.buf, $4.buf);
111 $$.cql = cql_node_prefix($4.cql, 0, $2.buf);
116 AND | OR | NOT | PROX proxqualifiers {
124 $$.rel = cql_node_mk_proxargs ($1.buf, 0, 0, 0);
127 PrelationO Pdistance {
128 $$.rel = cql_node_mk_proxargs ($1.buf, $2.buf, 0, 0);
131 PrelationO PdistanceO Punit {
132 $$.rel = cql_node_mk_proxargs ($1.buf, $2.buf, $3.buf, 0);
135 PrelationO PdistanceO PunitO Pordering {
136 $$.rel = cql_node_mk_proxargs ($1.buf, $2.buf, $3.buf, $4.buf);
142 Punit: '/' searchTerm {
147 PunitO: '/' searchTerm {
151 '/' { $$.buf[0] = 0; }
153 Prelation: '/' baseRelation {
157 PrelationO: '/' baseRelation {
160 | '/' { $$.buf[0] = 0; }
162 Pdistance: '/' searchTerm {
167 PdistanceO: '/' searchTerm {
170 | '/' { $$.buf[0] = 0; }
172 Pordering: '/' searchTerm {
177 relation: baseRelation modifiers {
178 struct cql_node *st = cql_node_mk_sc(/* index */ 0,
179 /* relation */ $1.buf,
182 st->u.st.modifiers = $2.cql;
187 modifiers: '/' searchTerm modifiers
189 struct cql_node *mod = cql_node_mk_mod(0, $2.buf);
191 mod->u.mod.next = $3.cql;
237 int cql_parser_stream(CQL_parser cp,
238 int (*getbyte)(void *client_data),
239 void (*ungetbyte)(int b, void *client_data),
242 cp->getbyte = getbyte;
243 cp->ungetbyte = ungetbyte;
244 cp->client_data = client_data;
251 CQL_parser cql_parser_create(void)
253 CQL_parser cp = malloc (sizeof(*cp));
258 void cql_parser_destroy(CQL_parser cp)
260 cql_node_destroy(cp->top);
264 struct cql_node *cql_parser_result(CQL_parser cp)