libidav/davqlparser.h

Sun, 17 Nov 2024 13:11:14 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 17 Nov 2024 13:11:14 +0100
changeset 847
61a3892a8dfb
parent 747
efbd59642577
permissions
-rw-r--r--

fix PUT request with chunked transfer encoding

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 *
365
f04ab0420512 fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 359
diff changeset
4 * Copyright 2018 Olaf Wintermann. All rights reserved.
76
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>
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 365
diff changeset
37 #include <cx/string.h>
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 365
diff changeset
38 #include <cx/list.h>
76
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 */
127
7072a2b4ae35 renamed GET to SELECT in davql syntax
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
43 typedef enum {DAVQL_ERROR, DAVQL_SELECT, 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 /**
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
46 * Enumeration of possible token classes.
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
47 */
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
48 typedef enum {
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
49 DAVQL_TOKEN_INVALID, DAVQL_TOKEN_KEYWORD,
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
50 DAVQL_TOKEN_IDENTIFIER, DAVQL_TOKEN_FMTSPEC,
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
51 DAVQL_TOKEN_STRING, DAVQL_TOKEN_NUMBER, DAVQL_TOKEN_TIMESTAMP,
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
52 DAVQL_TOKEN_COMMA, DAVQL_TOKEN_OPENP, DAVQL_TOKEN_CLOSEP,
117
5ffc2f23803f fixed null pointer access on end of token stream by adding a special END token to the stream
Mike Becker <universe@uap-core.de>
parents: 116
diff changeset
53 DAVQL_TOKEN_OPERATOR, DAVQL_TOKEN_END
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
54 } davqltokenclass_t;
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
55
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
56 /**
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
57 * Enumeration of possible expression types.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
58 */
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
59 typedef enum {
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
60 DAVQL_UNDEFINED_TYPE,
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
61 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
62 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
63 } davqlexprtype_t;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
64
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 * Enumeration of possible expression operators.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
67 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
68 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
69 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
70 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
71 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
72 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
73 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
74 DAVQL_LIKE, DAVQL_UNLIKE // comparisons
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
75 } davqloperator_t;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
76
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 365
diff changeset
77 typedef struct DavQLToken DavQLToken;
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 365
diff changeset
78 struct DavQLToken {
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
79 davqltokenclass_t tokenclass;
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 365
diff changeset
80 cxstring value;
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 365
diff changeset
81 DavQLToken *prev;
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 365
diff changeset
82 DavQLToken *next;
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 365
diff changeset
83 };
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
84
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
85 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
86 * An expression within a DAVQL query.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
87 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
88 typedef struct _davqlexpr DavQLExpression;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
89
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
90 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
91 * The structure for type DavQLExpression.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
92 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
93 struct _davqlexpr {
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
94 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
95 * The original expression text.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
96 * Contains the literal value, if type is LITERAL.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
97 */
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 365
diff changeset
98 cxstring srctext;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
99 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
100 * The expression type.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
101 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
102 davqlexprtype_t type;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
103 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
104 * Operator.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
105 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
106 davqloperator_t op;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
107 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
108 * Left or single operand.
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
109 * <code>NULL</code> for literals or identifiers.
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
110 */
80
a2832c054c98 added path examination to debugger + changed field names of expression subtrees
Mike Becker <universe@uap-core.de>
parents: 79
diff changeset
111 DavQLExpression *left;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
112 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
113 * Right operand.
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
114 * <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
115 */
80
a2832c054c98 added path examination to debugger + changed field names of expression subtrees
Mike Becker <universe@uap-core.de>
parents: 79
diff changeset
116 DavQLExpression *right;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
117 };
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
118
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
119 /**
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
120 * 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
121 */
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
122 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
123 /**
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
124 * 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
125 */
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
126 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
127 /**
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
128 * 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
129 * 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
130 */
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
131 _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
132 } 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
133
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
134 /**
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 * 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
136 */
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
137 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
138 /**
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
139 * 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
140 * <ul>
127
7072a2b4ae35 renamed GET to SELECT in davql syntax
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
141 * <li>SELECT: the identifier or an alias name</li>
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
142 * <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
143 * </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
144 */
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 365
diff changeset
145 cxstring name;
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
146 /**
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
147 * 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
148 * <ul>
127
7072a2b4ae35 renamed GET to SELECT in davql syntax
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
149 * <li>SELECT: the queried property (identifier) or an expression</li>
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
150 * <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
151 * </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
152 */
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
153 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
154 } DavQLField;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
155
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
156 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
157 * Query statement object.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
158 * 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
159 *
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
160 * The grammar for a DavQLStatement is:
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
161 *
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
162 * <pre>
131
32e7b3e6b482 added missing keywords + fixed missing source text for boolean primaries
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
163 * Keyword = "select" | "set" | "from" | "at" | "as"
32e7b3e6b482 added missing keywords + fixed missing source text for boolean primaries
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
164 * | "where" | "anywhere" | "like" | "unlike"
32e7b3e6b482 added missing keywords + fixed missing source text for boolean primaries
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
165 * | "and" | "or" | "not" | "xor" | "with" | "infinity"
130
80d273229f24 fixed grammar for path + added missing string quote escaping (still not perfect: escape sequence is in syntax tree)
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
166 * | "order" | "by" | "asc" | "desc";
80d273229f24 fixed grammar for path + added missing string quote escaping (still not perfect: escape sequence is in syntax tree)
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
167 *
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
168 * 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
169 * 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
170 * 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
171 * BitwiseExpression = UnaryExpression, [BitwiseOperator, BitwiseExpression];
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
172 * UnaryExpression = [UnaryOperator], (ParExpression | AtomicExpression);
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
173 * 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
174 * 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
175 *
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
176 * 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
177 * 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
178 * 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
179 * 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
180 *
114
943548492a47 added function call parser + fixed some memory management mistakes
Mike Becker <universe@uap-core.de>
parents: 113
diff changeset
181 * FunctionCall = Identifier, "(", [ArgumentList], ")";
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
182 * 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
183 * 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
184 * | "`", ?Character? - "`", {?Character? - "`"}, "`";
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
185 * IdentifierChar = ?Character? - (" "|",");
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
186 * 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
187 * 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
188 * String = "'", {?Character? - "'" | "'''"} , "'" | "%s";
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
189 * 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
190 *
116
44ffe073b5e3 fixed logical expression parser
Mike Becker <universe@uap-core.de>
parents: 115
diff changeset
191 * LogicalExpression = BooleanExpression, [LogicalOperator, LogicalExpression];
44ffe073b5e3 fixed logical expression parser
Mike Becker <universe@uap-core.de>
parents: 115
diff changeset
192 * BooleanExpression = "not ", BooleanExpression
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
193 * | "(", LogicalExpression, ")"
115
5744a3dee766 completed logical expression parser - NEED TO TEST A LOT!
Mike Becker <universe@uap-core.de>
parents: 114
diff changeset
194 * | BooleanPrimary;
5744a3dee766 completed logical expression parser - NEED TO TEST A LOT!
Mike Becker <universe@uap-core.de>
parents: 114
diff changeset
195 * BooleanPrimary = Expression, (" like " | " unlike "), String
5744a3dee766 completed logical expression parser - NEED TO TEST A LOT!
Mike Becker <universe@uap-core.de>
parents: 114
diff changeset
196 * | Expression, Comparison, Expression
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
197 * | 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
198 *
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
199 * 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
200 * Comparison = | "=" | "<" | ">" | "<=" | ">=" | "!=";
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
201 *
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
202 * FieldExpressions = "-"
113
412b06dc0162 completed field list parser + error messages do now provide more context information based on the source string
Mike Becker <universe@uap-core.de>
parents: 111
diff changeset
203 * | "*", {",", NamedField}
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
204 * | FieldExpression, {",", FieldExpression};
113
412b06dc0162 completed field list parser + error messages do now provide more context information based on the source string
Mike Becker <universe@uap-core.de>
parents: 111
diff changeset
205 * FieldExpression = NamedField | Identifier;
357
5dfbf7b45873 implements parser for Assignments (previously called SetExpressions) + improves davql debugger regarding DavQLField
Mike Becker <universe@uap-core.de>
parents: 185
diff changeset
206 * NamedField = Expression, " as ", Identifier;
113
412b06dc0162 completed field list parser + error messages do now provide more context information based on the source string
Mike Becker <universe@uap-core.de>
parents: 111
diff changeset
207 *
357
5dfbf7b45873 implements parser for Assignments (previously called SetExpressions) + improves davql debugger regarding DavQLField
Mike Becker <universe@uap-core.de>
parents: 185
diff changeset
208 * Assignments = Assignment, {",", Assignment};
5dfbf7b45873 implements parser for Assignments (previously called SetExpressions) + improves davql debugger regarding DavQLField
Mike Becker <universe@uap-core.de>
parents: 185
diff changeset
209 * Assignment = Identifier, "=", 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
210 *
130
80d273229f24 fixed grammar for path + added missing string quote escaping (still not perfect: escape sequence is in syntax tree)
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
211 * Path = String
80d273229f24 fixed grammar for path + added missing string quote escaping (still not perfect: escape sequence is in syntax tree)
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
212 * | "/", [PathNode, {"/", PathNode}], ["/"];
80d273229f24 fixed grammar for path + added missing string quote escaping (still not perfect: escape sequence is in syntax tree)
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
213 * PathNode = {{?Character? - "/"} - Keyword};
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
214 *
85
0ab1cf261a44 improved grammar + changed depth default, type and added infinity
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
215 * 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
216 *
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
217 * 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
218 * 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
219 *
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
220 * </pre>
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
221 *
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
222 * 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
223 * arbitrary amount of optional spaces between two symbols if they are not part
130
80d273229f24 fixed grammar for path + added missing string quote escaping (still not perfect: escape sequence is in syntax tree)
Mike Becker <universe@uap-core.de>
parents: 127
diff changeset
224 * of an literal, identifier or the path.
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
225 *
127
7072a2b4ae35 renamed GET to SELECT in davql syntax
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
226 * <b>SELECT:</b>
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
227 * <pre>
127
7072a2b4ae35 renamed GET to SELECT in davql syntax
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
228 * SelectStatement = "select ", FieldExpressions,
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
229 * " 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
230 * [" with ", WithClause],
359
bacb54502b24 davql: allow ANYWHERE keyword in SELECT statements
Mike Becker <universe@uap-core.de>
parents: 357
diff changeset
231 * [(" where ", LogicalExpression) | " anywhere"],
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
232 * [" 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
233 * </pre>
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
234 *
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
235 * <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
236 * <pre>
357
5dfbf7b45873 implements parser for Assignments (previously called SetExpressions) + improves davql debugger regarding DavQLField
Mike Becker <universe@uap-core.de>
parents: 185
diff changeset
237 * SetStatement = "set ",Assignments,
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
238 * " 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
239 * [" 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
240 * (" 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
241 * </pre>
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
242 *
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
243 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
244 typedef struct {
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
245 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
246 * The original query text.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
247 */
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 365
diff changeset
248 cxstring srctext;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
249 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
250 * The statement type.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
251 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
252 davqltype_t type;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
253 /**
86
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
254 * 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
255 */
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
256 int errorcode;
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
257 /**
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
258 * Error message, if any error occurred.
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
259 */
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
260 char* errormessage;
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
261 /**
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
262 * The list of DavQLFields.
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
263 */
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 365
diff changeset
264 CxList* fields;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
265 /**
87
ed21d95984bb removed DavQLExpression type for path (since it always is an identifier)
Mike Becker <universe@uap-core.de>
parents: 86
diff changeset
266 * 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
267 */
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 365
diff changeset
268 cxstring path;
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
269 /**
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
270 * Logical expression for selection.
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
271 * <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
272 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
273 DavQLExpression* where;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
274 /**
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
275 * 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
276 * 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
277 * 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
278 */
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 365
diff changeset
279 CxList* orderby;
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
280 /**
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
281 * 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
282 * 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
283 * 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
284 * DAV_DEPTH_PLACEHOLDER for a placeholder.
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
285 */
85
0ab1cf261a44 improved grammar + changed depth default, type and added infinity
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
286 int depth;
365
f04ab0420512 fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 359
diff changeset
287 /**
f04ab0420512 fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 359
diff changeset
288 * A list of all required arguments
f04ab0420512 fixes misuse of vaarg on all platforms
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 359
diff changeset
289 */
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 365
diff changeset
290 CxList* args;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
291 } DavQLStatement;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
292
86
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
293 /** 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
294 #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
295
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
296 /** 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
297 #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
298
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
299 /** Unexpected token. */
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
300 #define DAVQL_ERROR_UNEXPECTED_TOKEN 1
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
301
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
302 /** A token has been found, for which no token class is applicable. */
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
303 #define DAVQL_ERROR_INVALID_TOKEN 2
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
304
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
305 /** A token that has been expected was not found. */
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
306 #define DAVQL_ERROR_MISSING_TOKEN 11
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
307
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
308 /** An expression has been expected, but was not found. */
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
309 #define DAVQL_ERROR_MISSING_EXPR 12
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
310
111
39f4c5fcaa60 parser for ParExpression
Mike Becker <universe@uap-core.de>
parents: 108
diff changeset
311 /** A closed parenthesis ')' is missing. */
39f4c5fcaa60 parser for ParExpression
Mike Becker <universe@uap-core.de>
parents: 108
diff changeset
312 #define DAVQL_ERROR_MISSING_PAR 13
39f4c5fcaa60 parser for ParExpression
Mike Becker <universe@uap-core.de>
parents: 108
diff changeset
313
357
5dfbf7b45873 implements parser for Assignments (previously called SetExpressions) + improves davql debugger regarding DavQLField
Mike Becker <universe@uap-core.de>
parents: 185
diff changeset
314 /** An assignment operator '=' is missing. */
5dfbf7b45873 implements parser for Assignments (previously called SetExpressions) + improves davql debugger regarding DavQLField
Mike Becker <universe@uap-core.de>
parents: 185
diff changeset
315 #define DAVQL_ERROR_MISSING_ASSIGN 14
5dfbf7b45873 implements parser for Assignments (previously called SetExpressions) + improves davql debugger regarding DavQLField
Mike Becker <universe@uap-core.de>
parents: 185
diff changeset
316
108
0199f13c7fe2 fixed parsing of binary expressions did not yield the correct type
Mike Becker <universe@uap-core.de>
parents: 107
diff changeset
317 /** The type of the expression could not be determined. */
0199f13c7fe2 fixed parsing of binary expressions did not yield the correct type
Mike Becker <universe@uap-core.de>
parents: 107
diff changeset
318 #define DAVQL_ERROR_INVALID_EXPR 21
0199f13c7fe2 fixed parsing of binary expressions did not yield the correct type
Mike Becker <universe@uap-core.de>
parents: 107
diff changeset
319
115
5744a3dee766 completed logical expression parser - NEED TO TEST A LOT!
Mike Becker <universe@uap-core.de>
parents: 114
diff changeset
320 /** An operator has been found for an unary expression, but it is invalid. */
108
0199f13c7fe2 fixed parsing of binary expressions did not yield the correct type
Mike Becker <universe@uap-core.de>
parents: 107
diff changeset
321 #define DAVQL_ERROR_INVALID_UNARY_OP 22
88
4d6b03bd7034 tokenizer now correctly handles quoted tokens
Mike Becker <universe@uap-core.de>
parents: 87
diff changeset
322
115
5744a3dee766 completed logical expression parser - NEED TO TEST A LOT!
Mike Becker <universe@uap-core.de>
parents: 114
diff changeset
323 /** An operator has been found for a logical expression, but it is invalid. */
5744a3dee766 completed logical expression parser - NEED TO TEST A LOT!
Mike Becker <universe@uap-core.de>
parents: 114
diff changeset
324 #define DAVQL_ERROR_INVALID_LOGICAL_OP 23
5744a3dee766 completed logical expression parser - NEED TO TEST A LOT!
Mike Becker <universe@uap-core.de>
parents: 114
diff changeset
325
107
a0903d2d8e3e added format specifier parser
Mike Becker <universe@uap-core.de>
parents: 106
diff changeset
326 /** Invalid format specifier. */
115
5744a3dee766 completed logical expression parser - NEED TO TEST A LOT!
Mike Becker <universe@uap-core.de>
parents: 114
diff changeset
327 #define DAVQL_ERROR_INVALID_FMTSPEC 24
5744a3dee766 completed logical expression parser - NEED TO TEST A LOT!
Mike Becker <universe@uap-core.de>
parents: 114
diff changeset
328
5744a3dee766 completed logical expression parser - NEED TO TEST A LOT!
Mike Becker <universe@uap-core.de>
parents: 114
diff changeset
329 /** A string has been expected. */
5744a3dee766 completed logical expression parser - NEED TO TEST A LOT!
Mike Becker <universe@uap-core.de>
parents: 114
diff changeset
330 #define DAVQL_ERROR_INVALID_STRING 25
107
a0903d2d8e3e added format specifier parser
Mike Becker <universe@uap-core.de>
parents: 106
diff changeset
331
120
246c50447ebf implemented order by parser
Mike Becker <universe@uap-core.de>
parents: 117
diff changeset
332 /** The order criterion is invalid (must be an identifier or field index). */
246c50447ebf implemented order by parser
Mike Becker <universe@uap-core.de>
parents: 117
diff changeset
333 #define DAVQL_ERROR_INVALID_ORDER_CRITERION 26
246c50447ebf implemented order by parser
Mike Becker <universe@uap-core.de>
parents: 117
diff changeset
334
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
335 /** The depth is invalid. */
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
336 #define DAVQL_ERROR_INVALID_DEPTH 101
86
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
337
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
338 /** Nothing about the statement seems legit. */
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
339 #define DAVQL_ERROR_INVALID -1
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
340
121
eea36bf5ffe2 fixed statement type for logical expressions without operator + prepared OOM handling
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
341 /** A call to malloc or calloc failed. */
eea36bf5ffe2 fixed statement type for logical expressions without operator + prepared OOM handling
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
342 #define DAVQL_ERROR_OUT_OF_MEMORY -2
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
343
79
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
344 /**
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
345 * 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
346 *
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
347 * @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
348 */
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
349 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
350
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
351 /**
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
352 * Parses a statement.
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
353 * @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
354 * @return a DavQLStatement object
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
355 */
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 365
diff changeset
356 DavQLStatement* dav_parse_statement(cxstring stmt);
79
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
357
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
358 /**
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
359 * 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
360 */
747
efbd59642577 ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 365
diff changeset
361 #define dav_parse_cstr_statement(stmt) dav_parse_statement(cx_str(stmt))
79
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
362
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
363 /**
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
364 * 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
365 * @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
366 */
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
367 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
368
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
369 #ifdef __cplusplus
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
370 }
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
371 #endif
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
372
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
373 #endif /* DAVQLPARSER_H */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
374

mercurial