libidav/davqlparser.h

Sat, 02 May 2015 18:32:50 +0200

author
Mike Becker <universe@uap-core.de>
date
Sat, 02 May 2015 18:32:50 +0200
changeset 102
e9ae1318a559
parent 98
237844f263b4
child 106
9cec78f23cbf
permissions
-rw-r--r--

reworked expression grammar (removed left recursion) + added field names to debugger + fixed bug when WITH-clause was the last clause in a statement

76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 /*
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
3 *
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
4 * Copyright 2015 Olaf Wintermann. All rights reserved.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
5 *
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8 *
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
11 *
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15 *
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
28
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
29 #ifndef DAVQLPARSER_H
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
30 #define DAVQLPARSER_H
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
31
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
32 #ifdef __cplusplus
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
33 extern "C" {
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
34 #endif
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
35
79
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
36 #include <stdint.h>
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
37 #include "ucx/string.h"
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
38 #include "ucx/list.h"
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
39
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
40 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
41 * Enumeration of possible statement types.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
42 */
82
0567444f2d76 renamed some enums to avoid collisions with macros + minor grammar change (backsticks for identifiers) + tokenizer + parser skeleton
Mike Becker <universe@uap-core.de>
parents: 80
diff changeset
43 typedef enum {DAVQL_ERROR, DAVQL_GET, DAVQL_SET} davqltype_t;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
44
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
45 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
46 * Enumeration of possible expression types.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
47 */
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
48 typedef enum {
98
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
49 DAVQL_UNDEFINED_TYP,
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
50 DAVQL_NUMBER, DAVQL_STRING, DAVQL_TIMESTAMP, DAVQL_IDENTIFIER,
82
0567444f2d76 renamed some enums to avoid collisions with macros + minor grammar change (backsticks for identifiers) + tokenizer + parser skeleton
Mike Becker <universe@uap-core.de>
parents: 80
diff changeset
51 DAVQL_UNARY, DAVQL_BINARY, DAVQL_LOGICAL, DAVQL_FUNCCALL
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
52 } davqlexprtype_t;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
53
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
54 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
55 * Enumeration of possible expression operators.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
56 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
57 typedef enum {
92
e073cf4afc6a added order by clause to grammar + moved with clause right after the from clause
Mike Becker <universe@uap-core.de>
parents: 91
diff changeset
58 DAVQL_NOOP, DAVQL_CALL, DAVQL_ARGLIST, // internal representations
83
7d20ce5d235b improved expression parser (can now detect literals and identifiers) - TODO: tokenizer must not split strings and "backstick-identifiers"
Mike Becker <universe@uap-core.de>
parents: 82
diff changeset
59 DAVQL_ADD, DAVQL_SUB, DAVQL_MUL, DAVQL_DIV,
92
e073cf4afc6a added order by clause to grammar + moved with clause right after the from clause
Mike Becker <universe@uap-core.de>
parents: 91
diff changeset
60 DAVQL_AND, DAVQL_OR, DAVQL_XOR, DAVQL_NEG, // airthmetic
e073cf4afc6a added order by clause to grammar + moved with clause right after the from clause
Mike Becker <universe@uap-core.de>
parents: 91
diff changeset
61 DAVQL_NOT, DAVQL_LAND, DAVQL_LOR, DAVQL_LXOR, // logical
83
7d20ce5d235b improved expression parser (can now detect literals and identifiers) - TODO: tokenizer must not split strings and "backstick-identifiers"
Mike Becker <universe@uap-core.de>
parents: 82
diff changeset
62 DAVQL_EQ, DAVQL_NEQ, DAVQL_LT, DAVQL_GT, DAVQL_LE, DAVQL_GE,
92
e073cf4afc6a added order by clause to grammar + moved with clause right after the from clause
Mike Becker <universe@uap-core.de>
parents: 91
diff changeset
63 DAVQL_LIKE, DAVQL_UNLIKE // comparisons
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
64 } davqloperator_t;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
65
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
66 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
67 * An expression within a DAVQL query.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
68 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
69 typedef struct _davqlexpr DavQLExpression;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
70
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
71 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
72 * The structure for type DavQLExpression.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
73 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
74 struct _davqlexpr {
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
75 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
76 * The original expression text.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
77 * Contains the literal value, if type is LITERAL.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
78 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
79 sstr_t srctext;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
80 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
81 * The expression type.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
82 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
83 davqlexprtype_t type;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
84 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
85 * Operator.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
86 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
87 davqloperator_t op;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
88 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
89 * Left or single operand.
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
90 * <code>NULL</code> for literals or identifiers.
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
91 */
80
a2832c054c98 added path examination to debugger + changed field names of expression subtrees
Mike Becker <universe@uap-core.de>
parents: 79
diff changeset
92 DavQLExpression *left;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
93 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
94 * Right operand.
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
95 * <code>NULL</code> for literals, identifiers or unary expressions.
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
96 */
80
a2832c054c98 added path examination to debugger + changed field names of expression subtrees
Mike Becker <universe@uap-core.de>
parents: 79
diff changeset
97 DavQLExpression *right;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
98 };
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
99
95
8ed7d8df6427 simplified with clause parsing + added order by to data structure and debugger (TODO: implement)
Mike Becker <universe@uap-core.de>
parents: 92
diff changeset
100 /**
8ed7d8df6427 simplified with clause parsing + added order by to data structure and debugger (TODO: implement)
Mike Becker <universe@uap-core.de>
parents: 92
diff changeset
101 * A tuple representing an order criterion.
8ed7d8df6427 simplified with clause parsing + added order by to data structure and debugger (TODO: implement)
Mike Becker <universe@uap-core.de>
parents: 92
diff changeset
102 */
8ed7d8df6427 simplified with clause parsing + added order by to data structure and debugger (TODO: implement)
Mike Becker <universe@uap-core.de>
parents: 92
diff changeset
103 typedef struct {
8ed7d8df6427 simplified with clause parsing + added order by to data structure and debugger (TODO: implement)
Mike Becker <universe@uap-core.de>
parents: 92
diff changeset
104 /**
8ed7d8df6427 simplified with clause parsing + added order by to data structure and debugger (TODO: implement)
Mike Becker <universe@uap-core.de>
parents: 92
diff changeset
105 * The column.
8ed7d8df6427 simplified with clause parsing + added order by to data structure and debugger (TODO: implement)
Mike Becker <universe@uap-core.de>
parents: 92
diff changeset
106 */
8ed7d8df6427 simplified with clause parsing + added order by to data structure and debugger (TODO: implement)
Mike Becker <universe@uap-core.de>
parents: 92
diff changeset
107 DavQLExpression *column;
8ed7d8df6427 simplified with clause parsing + added order by to data structure and debugger (TODO: implement)
Mike Becker <universe@uap-core.de>
parents: 92
diff changeset
108 /**
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
109 * True, if the result shall be sorted descending, false otherwise.
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
110 * Default is false (ascending).
95
8ed7d8df6427 simplified with clause parsing + added order by to data structure and debugger (TODO: implement)
Mike Becker <universe@uap-core.de>
parents: 92
diff changeset
111 */
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
112 _Bool descending;
95
8ed7d8df6427 simplified with clause parsing + added order by to data structure and debugger (TODO: implement)
Mike Becker <universe@uap-core.de>
parents: 92
diff changeset
113 } DavQLOrderCriterion;
8ed7d8df6427 simplified with clause parsing + added order by to data structure and debugger (TODO: implement)
Mike Becker <universe@uap-core.de>
parents: 92
diff changeset
114
98
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
115 /**
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
116 * A tuple representing a field.
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
117 */
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
118 typedef struct {
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
119 /**
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
120 * The field name.
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
121 * <ul>
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
122 * <li>GET: the identifier or an alias name</li>
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
123 * <li>SET: the identifier</li>
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
124 * </ul>
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
125 */
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
126 sstr_t name;
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
127 /**
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
128 * The field expression.
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
129 * <ul>
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
130 * <li>GET: the queried property (identifier) or an expression</li>
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
131 * <li>SET: the expression for the value to be set</li>
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
132 * </ul>
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
133 */
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
134 DavQLExpression *expr;
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
135 } DavQLField;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
136
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
137 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
138 * Query statement object.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
139 * Contains the binary information about the parsed query.
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
140 *
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
141 * The grammar for a DavQLStatement is:
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
142 *
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
143 * <pre>
102
e9ae1318a559 reworked expression grammar (removed left recursion) + added field names to debugger + fixed bug when WITH-clause was the last clause in a statement
Mike Becker <universe@uap-core.de>
parents: 98
diff changeset
144 * Expression = AddExpression;
e9ae1318a559 reworked expression grammar (removed left recursion) + added field names to debugger + fixed bug when WITH-clause was the last clause in a statement
Mike Becker <universe@uap-core.de>
parents: 98
diff changeset
145 * AddExpression = MultExpression, [AddOperator, AddExpression];
e9ae1318a559 reworked expression grammar (removed left recursion) + added field names to debugger + fixed bug when WITH-clause was the last clause in a statement
Mike Becker <universe@uap-core.de>
parents: 98
diff changeset
146 * MultExpression = BitwiseExpression, [MultOperator, MultExpression];
e9ae1318a559 reworked expression grammar (removed left recursion) + added field names to debugger + fixed bug when WITH-clause was the last clause in a statement
Mike Becker <universe@uap-core.de>
parents: 98
diff changeset
147 * BitwiseExpression = UnaryExpression, [BitwiseOperator, BitwiseExpression];
e9ae1318a559 reworked expression grammar (removed left recursion) + added field names to debugger + fixed bug when WITH-clause was the last clause in a statement
Mike Becker <universe@uap-core.de>
parents: 98
diff changeset
148 * UnaryExpression = [UnaryOperator], (AtomicExpression | ParExpression);
e9ae1318a559 reworked expression grammar (removed left recursion) + added field names to debugger + fixed bug when WITH-clause was the last clause in a statement
Mike Becker <universe@uap-core.de>
parents: 98
diff changeset
149 * AtomicExpression = FunctionCall | Identifier | Literal;
e9ae1318a559 reworked expression grammar (removed left recursion) + added field names to debugger + fixed bug when WITH-clause was the last clause in a statement
Mike Becker <universe@uap-core.de>
parents: 98
diff changeset
150 * ParExpression = "(", Expression, ")";
e9ae1318a559 reworked expression grammar (removed left recursion) + added field names to debugger + fixed bug when WITH-clause was the last clause in a statement
Mike Becker <universe@uap-core.de>
parents: 98
diff changeset
151 *
e9ae1318a559 reworked expression grammar (removed left recursion) + added field names to debugger + fixed bug when WITH-clause was the last clause in a statement
Mike Becker <universe@uap-core.de>
parents: 98
diff changeset
152 * BitwiseOperator = "&" | "|" | "^";
e9ae1318a559 reworked expression grammar (removed left recursion) + added field names to debugger + fixed bug when WITH-clause was the last clause in a statement
Mike Becker <universe@uap-core.de>
parents: 98
diff changeset
153 * MultOperator = "*" | "/";
e9ae1318a559 reworked expression grammar (removed left recursion) + added field names to debugger + fixed bug when WITH-clause was the last clause in a statement
Mike Becker <universe@uap-core.de>
parents: 98
diff changeset
154 * AddOperator = "+" | "-";
e9ae1318a559 reworked expression grammar (removed left recursion) + added field names to debugger + fixed bug when WITH-clause was the last clause in a statement
Mike Becker <universe@uap-core.de>
parents: 98
diff changeset
155 * UnaryOperator = "+" | "-" | "~";
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
156 *
92
e073cf4afc6a added order by clause to grammar + moved with clause right after the from clause
Mike Becker <universe@uap-core.de>
parents: 91
diff changeset
157 * FunctionCall = Identifier, "(", ArgumentList, ")";
e073cf4afc6a added order by clause to grammar + moved with clause right after the from clause
Mike Becker <universe@uap-core.de>
parents: 91
diff changeset
158 * ArgumentList = Expression, {",", Expression};
83
7d20ce5d235b improved expression parser (can now detect literals and identifiers) - TODO: tokenizer must not split strings and "backstick-identifiers"
Mike Becker <universe@uap-core.de>
parents: 82
diff changeset
159 * Identifier = IdentifierChar - ?Digit?, {IdentifierChar}
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
160 * | "`", ?Character? - "`", {?Character? - "`"}, "`";
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
161 * IdentifierChar = ?Character? - (" "|",");
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
162 * Literal = Number | String | Timestamp;
85
0ab1cf261a44 improved grammar + changed depth default, type and added infinity
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
163 * Number = ?Digit?, {?Digit?} | "%d";
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
164 * String = "'", {?Character? - "'" | "'''"} , "'" | "%s";
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
165 * Timestamp = "%t"; // TODO: maybe introduce a real literal
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
166 *
102
e9ae1318a559 reworked expression grammar (removed left recursion) + added field names to debugger + fixed bug when WITH-clause was the last clause in a statement
Mike Becker <universe@uap-core.de>
parents: 98
diff changeset
167 * LogicalExpression = "not ", LogicalExpression
e9ae1318a559 reworked expression grammar (removed left recursion) + added field names to debugger + fixed bug when WITH-clause was the last clause in a statement
Mike Becker <universe@uap-core.de>
parents: 98
diff changeset
168 * | "(", LogicalExpression, ")"
e9ae1318a559 reworked expression grammar (removed left recursion) + added field names to debugger + fixed bug when WITH-clause was the last clause in a statement
Mike Becker <universe@uap-core.de>
parents: 98
diff changeset
169 * | BooleanExpression, [LogicalOperator, LogicalExpression];
e9ae1318a559 reworked expression grammar (removed left recursion) + added field names to debugger + fixed bug when WITH-clause was the last clause in a statement
Mike Becker <universe@uap-core.de>
parents: 98
diff changeset
170 * BooleanExpression = Expression, Comparison, Expression
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
171 * | Expression, (" like " | " unlike "), String
102
e9ae1318a559 reworked expression grammar (removed left recursion) + added field names to debugger + fixed bug when WITH-clause was the last clause in a statement
Mike Becker <universe@uap-core.de>
parents: 98
diff changeset
172 * | FunctionCall | Identifier;
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
173 *
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
174 * LogicalOperator = " and " | " or " | " xor ";
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
175 * Comparison = | "=" | "<" | ">" | "<=" | ">=" | "!=";
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
176 *
98
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
177 * FieldExpressions = "*", {",", Expression, " as ", Identifier}
86
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
178 * | FieldExpression, {",", FieldExpression}
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
179 * | "-";
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
180 * FieldExpression = Identifier
98
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
181 * | Expression, " as ", Identifier;
102
e9ae1318a559 reworked expression grammar (removed left recursion) + added field names to debugger + fixed bug when WITH-clause was the last clause in a statement
Mike Becker <universe@uap-core.de>
parents: 98
diff changeset
182 * SetExpressions = SetExpression, {",", SetExpression};
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
183 * SetExpression = Identifier, "=", Expression;
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
184 *
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
185 * Path = "%s"
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
186 * | "/", {?Character? - " "}
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
187 * | "'/", {?Character?}, "'";
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
188 *
85
0ab1cf261a44 improved grammar + changed depth default, type and added infinity
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
189 * WithClause = "depth", "=", (Number | "infinity");
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
190 *
92
e073cf4afc6a added order by clause to grammar + moved with clause right after the from clause
Mike Becker <universe@uap-core.de>
parents: 91
diff changeset
191 * OrderByClause = OrderByCriterion, {",", OrderByCriterion};
e073cf4afc6a added order by clause to grammar + moved with clause right after the from clause
Mike Becker <universe@uap-core.de>
parents: 91
diff changeset
192 * OrderByCriterion = (Identifier | Number), [" asc"|" desc"];
e073cf4afc6a added order by clause to grammar + moved with clause right after the from clause
Mike Becker <universe@uap-core.de>
parents: 91
diff changeset
193 *
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
194 * </pre>
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
195 *
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
196 * Note: mandatory spaces are part of the grammar. But you may also insert an
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
197 * arbitrary amount of optional spaces between two symbols if they are not part
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
198 * of an literal or identifier.
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
199 *
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
200 * <b>GET:</b>
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
201 * <pre>
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
202 * GetStatement = "get ", FieldExpressions,
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
203 * " from ", Path,
92
e073cf4afc6a added order by clause to grammar + moved with clause right after the from clause
Mike Becker <universe@uap-core.de>
parents: 91
diff changeset
204 * [" with ", WithClause],
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
205 * [" where ", LogicalExpression],
92
e073cf4afc6a added order by clause to grammar + moved with clause right after the from clause
Mike Becker <universe@uap-core.de>
parents: 91
diff changeset
206 * [" order by ", OrderByClause];
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
207 * </pre>
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
208 *
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
209 * <b>SET:</b>
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
210 * <pre>
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
211 * "set ",SetExpressions,
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
212 * " at ", Path,
92
e073cf4afc6a added order by clause to grammar + moved with clause right after the from clause
Mike Becker <universe@uap-core.de>
parents: 91
diff changeset
213 * [" with ", WithClause],
e073cf4afc6a added order by clause to grammar + moved with clause right after the from clause
Mike Becker <universe@uap-core.de>
parents: 91
diff changeset
214 * (" where ", LogicalExpression) | " anywhere";
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
215 * </pre>
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
216 *
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
217 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
218 typedef struct {
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
219 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
220 * The original query text.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
221 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
222 sstr_t srctext;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
223 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
224 * The statement type.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
225 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
226 davqltype_t type;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
227 /**
86
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
228 * Error code, if any error occurred. Zero otherwise.
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
229 */
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
230 int errorcode;
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
231 /**
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
232 * Error message, if any error occurred.
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
233 */
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
234 char* errormessage;
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
235 /**
98
237844f263b4 minor grammar fix (alias name is now identifier and not string) + completed debugger (so far) + separated field list parser (currently unable to parse alias names) + new structure for fields
Mike Becker <universe@uap-core.de>
parents: 96
diff changeset
236 * The list of DavQLFields.
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
237 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
238 UcxList* fields;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
239 /**
87
ed21d95984bb removed DavQLExpression type for path (since it always is an identifier)
Mike Becker <universe@uap-core.de>
parents: 86
diff changeset
240 * A string that denotes the queried path.
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
241 */
87
ed21d95984bb removed DavQLExpression type for path (since it always is an identifier)
Mike Becker <universe@uap-core.de>
parents: 86
diff changeset
242 sstr_t path;
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
243 /**
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
244 * Logical expression for selection.
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
245 * <code>NULL</code>, if there is no where clause.
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
246 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
247 DavQLExpression* where;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
248 /**
95
8ed7d8df6427 simplified with clause parsing + added order by to data structure and debugger (TODO: implement)
Mike Becker <universe@uap-core.de>
parents: 92
diff changeset
249 * The list of DavQLOrderCriterions.
8ed7d8df6427 simplified with clause parsing + added order by to data structure and debugger (TODO: implement)
Mike Becker <universe@uap-core.de>
parents: 92
diff changeset
250 * This is <code>NULL</code> for SET queries and may be <code>NULL</code>
8ed7d8df6427 simplified with clause parsing + added order by to data structure and debugger (TODO: implement)
Mike Becker <universe@uap-core.de>
parents: 92
diff changeset
251 * if the result doesn't need to be sorted.
8ed7d8df6427 simplified with clause parsing + added order by to data structure and debugger (TODO: implement)
Mike Becker <universe@uap-core.de>
parents: 92
diff changeset
252 */
8ed7d8df6427 simplified with clause parsing + added order by to data structure and debugger (TODO: implement)
Mike Becker <universe@uap-core.de>
parents: 92
diff changeset
253 UcxList* orderby;
8ed7d8df6427 simplified with clause parsing + added order by to data structure and debugger (TODO: implement)
Mike Becker <universe@uap-core.de>
parents: 92
diff changeset
254 /**
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
255 * The recursion depth for the statement.
85
0ab1cf261a44 improved grammar + changed depth default, type and added infinity
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
256 * Defaults to 1.
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
257 * Magic numbers are DAV_DEPTH_INFINITY for infinity and
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
258 * DAV_DEPTH_PLACEHOLDER for a placeholder.
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
259 */
85
0ab1cf261a44 improved grammar + changed depth default, type and added infinity
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
260 int depth;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
261 } DavQLStatement;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
262
86
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
263 /** Infinity recursion depth for a DavQLStatement. */
85
0ab1cf261a44 improved grammar + changed depth default, type and added infinity
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
264 #define DAV_DEPTH_INFINITY -1
0ab1cf261a44 improved grammar + changed depth default, type and added infinity
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
265
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
266 /** Depth needs to be specified at runtime. */
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
267 #define DAV_DEPTH_PLACEHOLDER -2
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
268
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
269 /** Invalid path. */
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
270 #define DAVQL_ERROR_INVALID_PATH 1
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
271
91
838b427267bb parser verifies that path is an identifier
Mike Becker <universe@uap-core.de>
parents: 90
diff changeset
272 /** Expected an identifier, but found something else. */
838b427267bb parser verifies that path is an identifier
Mike Becker <universe@uap-core.de>
parents: 90
diff changeset
273 #define DAVQL_ERROR_IDENTIFIER_EXPECTED 10
838b427267bb parser verifies that path is an identifier
Mike Becker <universe@uap-core.de>
parents: 90
diff changeset
274
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
275 /** Expected an identifier or literal, but found something else. */
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
276 #define DAVQL_ERROR_IDORLIT_EXPECTED 11
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
277
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
278 /** Expected an identifier or number, but found something else. */
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
279 #define DAVQL_ERROR_IDORNUM_EXPECTED 12
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
280
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
281 /** Expected an identifier or string, but found something else. */
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
282 #define DAVQL_ERROR_IDORSTR_EXPECTED 13
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
283
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
284 /** Expected an identifier or timestamp, but found something else. */
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
285 #define DAVQL_ERROR_IDORTS_EXPECTED 14
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
286
89
785f6007a0c1 parser for with clause + unexpected token message, if something is beyond the with clause
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
287 /** The with-clause contains an unknown attribute. */
785f6007a0c1 parser for with clause + unexpected token message, if something is beyond the with clause
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
288 #define DAVQL_ERROR_UNKNOWN_ATTRIBUTE 20
785f6007a0c1 parser for with clause + unexpected token message, if something is beyond the with clause
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
289
785f6007a0c1 parser for with clause + unexpected token message, if something is beyond the with clause
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
290 /** Depth must be greater than zero or infinity. */
785f6007a0c1 parser for with clause + unexpected token message, if something is beyond the with clause
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
291 #define DAVQL_ERROR_INVALID_DEPTH 21
785f6007a0c1 parser for with clause + unexpected token message, if something is beyond the with clause
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
292
90
46971430650b parser for with-clause ready to parse more attributes, but marks duplicated attributes as error
Mike Becker <universe@uap-core.de>
parents: 89
diff changeset
293 /** The with-clause contains an attribute more than once. */
46971430650b parser for with-clause ready to parse more attributes, but marks duplicated attributes as error
Mike Becker <universe@uap-core.de>
parents: 89
diff changeset
294 #define DAVQL_ERROR_DUPLICATED_ATTRIBUTE 29
46971430650b parser for with-clause ready to parse more attributes, but marks duplicated attributes as error
Mike Becker <universe@uap-core.de>
parents: 89
diff changeset
295
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
296 /** The format specifier is missing. */
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
297 #define DAVQL_ERROR_MISSING_FMTSPEC 30
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
298
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
299 /** The format specifier is unknown. */
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
300 #define DAVQL_ERROR_UNKNOWN_FMTSPEC 31
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
301
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
302 /** The format specifier is invalid. */
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
303 #define DAVQL_ERROR_INVALID_FMTSPEC 39
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
304
88
4d6b03bd7034 tokenizer now correctly handles quoted tokens
Mike Becker <universe@uap-core.de>
parents: 87
diff changeset
305 /** A quote symbol (' or `) is missing. */
4d6b03bd7034 tokenizer now correctly handles quoted tokens
Mike Becker <universe@uap-core.de>
parents: 87
diff changeset
306 #define DAVQL_ERROR_MISSING_QUOTE 50
4d6b03bd7034 tokenizer now correctly handles quoted tokens
Mike Becker <universe@uap-core.de>
parents: 87
diff changeset
307
86
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
308 /** No more tokens to parse, but the parser expected more. */
88
4d6b03bd7034 tokenizer now correctly handles quoted tokens
Mike Becker <universe@uap-core.de>
parents: 87
diff changeset
309 #define DAVQL_ERROR_UNEXPECTED_END 100
86
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
310
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
311 /** A token was found, which has not been expected. */
88
4d6b03bd7034 tokenizer now correctly handles quoted tokens
Mike Becker <universe@uap-core.de>
parents: 87
diff changeset
312 #define DAVQL_ERROR_UNEXPECTED_TOKEN 101
86
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
313
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
314 /** Nothing about the statement seems legit. */
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
315 #define DAVQL_ERROR_INVALID -1
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
316
79
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
317 /**
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
318 * Starts an interactive debugger for a DavQLStatement.
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
319 *
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
320 * @param stmt the statement to debug
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
321 */
82
0567444f2d76 renamed some enums to avoid collisions with macros + minor grammar change (backsticks for identifiers) + tokenizer + parser skeleton
Mike Becker <universe@uap-core.de>
parents: 80
diff changeset
322 void dav_debug_statement(DavQLStatement *stmt);
79
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
323
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
324 /**
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
325 * Parses a statement.
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
326 * @param stmt the sstr_t containing the statement
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
327 * @return a DavQLStatement object
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
328 */
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
329 DavQLStatement* dav_parse_statement(sstr_t stmt);
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
330
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
331 /**
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
332 * Implicitly converts a cstr to a sstr_t and calls dav_parse_statement.
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
333 */
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
334 #define dav_parse_cstr_statement(stmt) dav_parse_statement(S(stmt))
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
335
82
0567444f2d76 renamed some enums to avoid collisions with macros + minor grammar change (backsticks for identifiers) + tokenizer + parser skeleton
Mike Becker <universe@uap-core.de>
parents: 80
diff changeset
336 /**
0567444f2d76 renamed some enums to avoid collisions with macros + minor grammar change (backsticks for identifiers) + tokenizer + parser skeleton
Mike Becker <universe@uap-core.de>
parents: 80
diff changeset
337 * Frees a DavQLStatement.
0567444f2d76 renamed some enums to avoid collisions with macros + minor grammar change (backsticks for identifiers) + tokenizer + parser skeleton
Mike Becker <universe@uap-core.de>
parents: 80
diff changeset
338 * @param stmt the statement object to free
0567444f2d76 renamed some enums to avoid collisions with macros + minor grammar change (backsticks for identifiers) + tokenizer + parser skeleton
Mike Becker <universe@uap-core.de>
parents: 80
diff changeset
339 */
0567444f2d76 renamed some enums to avoid collisions with macros + minor grammar change (backsticks for identifiers) + tokenizer + parser skeleton
Mike Becker <universe@uap-core.de>
parents: 80
diff changeset
340 void dav_free_statement(DavQLStatement *stmt);
0567444f2d76 renamed some enums to avoid collisions with macros + minor grammar change (backsticks for identifiers) + tokenizer + parser skeleton
Mike Becker <universe@uap-core.de>
parents: 80
diff changeset
341
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
342 #ifdef __cplusplus
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
343 }
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
344 #endif
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
345
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
346 #endif /* DAVQLPARSER_H */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
347

mercurial