Update header about CQL grammar
[yaz-moved-to-github.git] / src / yaz-ccl.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2013 Index Data
3  * See the file LICENSE for details.
4  */
5 /**
6  * \file yaz-ccl.c
7  * \brief Implements CCL node tree to RPN converson.
8  */
9 #if HAVE_CONFIG_H
10 #include <config.h>
11 #endif
12
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <string.h>
16
17 #include <yaz/yaz-ccl.h>
18 #include <yaz/pquery.h>
19
20 Z_RPNQuery *ccl_rpn_query (ODR o, struct ccl_rpn_node *p)
21 {
22     YAZ_PQF_Parser parser = yaz_pqf_create();
23     WRBUF wr = wrbuf_alloc();
24     Z_RPNQuery *q;
25
26     ccl_pquery(wr, p);
27
28     q = yaz_pqf_parse(parser, o, wrbuf_cstr(wr));
29
30     wrbuf_destroy(wr);
31     yaz_pqf_destroy(parser);
32     return q;
33 }
34
35 Z_AttributesPlusTerm *ccl_scan_query (ODR o, struct ccl_rpn_node *p)
36 {
37     YAZ_PQF_Parser parser = yaz_pqf_create();
38     WRBUF wr = wrbuf_alloc();
39     Z_AttributesPlusTerm *q;
40     Odr_oid *setp;
41
42     ccl_pquery(wr, p);
43
44     q = yaz_pqf_scan(parser, o, &setp, wrbuf_cstr(wr));
45
46     wrbuf_destroy(wr);
47     yaz_pqf_destroy(parser);
48     return q;
49 }
50
51 /*
52  * Local variables:
53  * c-basic-offset: 4
54  * c-file-style: "Stroustrup"
55  * indent-tabs-mode: nil
56  * End:
57  * vim: shiftwidth=4 tabstop=8 expandtab
58  */
59