libidav/davqlparser.h

Tue, 12 Dec 2017 17:41:01 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 12 Dec 2017 17:41:01 +0100
branch
v1.1
changeset 341
7954fdacdb5c
parent 185
cd42cccee550
child 357
5dfbf7b45873
permissions
-rw-r--r--

enable va_list fix only on mingw (this is the real release, as usual)

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 *
185
cd42cccee550 updated copyright notice
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 131
diff changeset
4 * Copyright 2016 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>
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 */
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
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
77 typedef struct {
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
78 davqltokenclass_t tokenclass;
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
79 sstr_t value;
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
80 } DavQLToken;
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
81
76
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 * An expression within a DAVQL query.
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 typedef struct _davqlexpr DavQLExpression;
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 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
88 * The structure for type 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 struct _davqlexpr {
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
91 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
92 * The original expression text.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
93 * Contains the literal value, if type is LITERAL.
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 sstr_t srctext;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
96 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
97 * The expression type.
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 davqlexprtype_t type;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
100 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
101 * Operator.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
102 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
103 davqloperator_t op;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
104 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
105 * Left or single operand.
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
106 * <code>NULL</code> for literals or identifiers.
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
107 */
80
a2832c054c98 added path examination to debugger + changed field names of expression subtrees
Mike Becker <universe@uap-core.de>
parents: 79
diff changeset
108 DavQLExpression *left;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
109 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
110 * Right operand.
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
111 * <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
112 */
80
a2832c054c98 added path examination to debugger + changed field names of expression subtrees
Mike Becker <universe@uap-core.de>
parents: 79
diff changeset
113 DavQLExpression *right;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
114 };
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
115
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
116 /**
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
117 * 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
118 */
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 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
120 /**
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 * 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
122 */
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 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
124 /**
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
125 * 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
126 * 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
127 */
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
128 _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
129 } 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
130
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
131 /**
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 * 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
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 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
135 /**
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 * 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
137 * <ul>
127
7072a2b4ae35 renamed GET to SELECT in davql syntax
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
138 * <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
139 * <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
140 * </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
141 */
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 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
143 /**
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 * 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
145 * <ul>
127
7072a2b4ae35 renamed GET to SELECT in davql syntax
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
146 * <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
147 * <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
148 * </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
149 */
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 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
151 } DavQLField;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
152
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
153 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
154 * Query statement object.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
155 * 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
156 *
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
157 * The grammar for a DavQLStatement is:
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
158 *
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
159 * <pre>
131
32e7b3e6b482 added missing keywords + fixed missing source text for boolean primaries
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
160 * 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
161 * | "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
162 * | "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
163 * | "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
164 *
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
165 * 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
166 * 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
167 * 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
168 * BitwiseExpression = UnaryExpression, [BitwiseOperator, BitwiseExpression];
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
169 * 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
170 * 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
171 * 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
172 *
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 * 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
174 * 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
175 * 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
176 * 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
177 *
114
943548492a47 added function call parser + fixed some memory management mistakes
Mike Becker <universe@uap-core.de>
parents: 113
diff changeset
178 * 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
179 * 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
180 * 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
181 * | "`", ?Character? - "`", {?Character? - "`"}, "`";
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
182 * IdentifierChar = ?Character? - (" "|",");
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
183 * 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
184 * 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
185 * String = "'", {?Character? - "'" | "'''"} , "'" | "%s";
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
186 * 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
187 *
116
44ffe073b5e3 fixed logical expression parser
Mike Becker <universe@uap-core.de>
parents: 115
diff changeset
188 * LogicalExpression = BooleanExpression, [LogicalOperator, LogicalExpression];
44ffe073b5e3 fixed logical expression parser
Mike Becker <universe@uap-core.de>
parents: 115
diff changeset
189 * 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
190 * | "(", LogicalExpression, ")"
115
5744a3dee766 completed logical expression parser - NEED TO TEST A LOT!
Mike Becker <universe@uap-core.de>
parents: 114
diff changeset
191 * | BooleanPrimary;
5744a3dee766 completed logical expression parser - NEED TO TEST A LOT!
Mike Becker <universe@uap-core.de>
parents: 114
diff changeset
192 * 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
193 * | 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
194 * | 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
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 * 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
197 * Comparison = | "=" | "<" | ">" | "<=" | ">=" | "!=";
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
198 *
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
199 * 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
200 * | "*", {",", NamedField}
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
201 * | 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
202 * FieldExpression = NamedField | Identifier;
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 = Expression, " as ", Identifier;
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
204 *
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
205 * 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
206 * 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
207 *
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
208 * 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
209 * | "/", [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
210 * 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
211 *
85
0ab1cf261a44 improved grammar + changed depth default, type and added infinity
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
212 * 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
213 *
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
214 * 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
215 * 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
216 *
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
217 * </pre>
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
218 *
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
219 * 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
220 * 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
221 * 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
222 *
127
7072a2b4ae35 renamed GET to SELECT in davql syntax
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
223 * <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
224 * <pre>
127
7072a2b4ae35 renamed GET to SELECT in davql syntax
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
225 * 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
226 * " 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
227 * [" 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
228 * [" 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
229 * [" 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
230 * </pre>
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
231 *
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
232 * <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
233 * <pre>
131
32e7b3e6b482 added missing keywords + fixed missing source text for boolean primaries
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
234 * SetStatement = "set ",SetExpressions,
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
235 * " 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
236 * [" 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
237 * (" 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
238 * </pre>
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
239 *
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
240 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
241 typedef struct {
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
242 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
243 * The original query text.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
244 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
245 sstr_t srctext;
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 * The statement type.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
248 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
249 davqltype_t type;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
250 /**
86
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
251 * 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
252 */
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
253 int errorcode;
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
254 /**
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
255 * Error message, if any error occurred.
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
256 */
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
257 char* errormessage;
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
258 /**
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
259 * The list of DavQLFields.
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
260 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
261 UcxList* fields;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
262 /**
87
ed21d95984bb removed DavQLExpression type for path (since it always is an identifier)
Mike Becker <universe@uap-core.de>
parents: 86
diff changeset
263 * 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
264 */
87
ed21d95984bb removed DavQLExpression type for path (since it always is an identifier)
Mike Becker <universe@uap-core.de>
parents: 86
diff changeset
265 sstr_t path;
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
266 /**
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
267 * Logical expression for selection.
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
268 * <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
269 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
270 DavQLExpression* where;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
271 /**
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
272 * 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
273 * 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
274 * 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
275 */
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 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
277 /**
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
278 * 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
279 * 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
280 * 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
281 * DAV_DEPTH_PLACEHOLDER for a placeholder.
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
282 */
85
0ab1cf261a44 improved grammar + changed depth default, type and added infinity
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
283 int depth;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
284 } DavQLStatement;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
285
86
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
286 /** 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
287 #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
288
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
289 /** 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
290 #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
291
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
292 /** Unexpected token. */
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
293 #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
294
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
295 /** 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
296 #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
297
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
298 /** A token that has been expected was not found. */
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
299 #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
300
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
301 /** An expression has been expected, but was not found. */
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
302 #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
303
111
39f4c5fcaa60 parser for ParExpression
Mike Becker <universe@uap-core.de>
parents: 108
diff changeset
304 /** A closed parenthesis ')' is missing. */
39f4c5fcaa60 parser for ParExpression
Mike Becker <universe@uap-core.de>
parents: 108
diff changeset
305 #define DAVQL_ERROR_MISSING_PAR 13
39f4c5fcaa60 parser for ParExpression
Mike Becker <universe@uap-core.de>
parents: 108
diff changeset
306
108
0199f13c7fe2 fixed parsing of binary expressions did not yield the correct type
Mike Becker <universe@uap-core.de>
parents: 107
diff changeset
307 /** 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
308 #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
309
115
5744a3dee766 completed logical expression parser - NEED TO TEST A LOT!
Mike Becker <universe@uap-core.de>
parents: 114
diff changeset
310 /** 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
311 #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
312
115
5744a3dee766 completed logical expression parser - NEED TO TEST A LOT!
Mike Becker <universe@uap-core.de>
parents: 114
diff changeset
313 /** 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
314 #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
315
107
a0903d2d8e3e added format specifier parser
Mike Becker <universe@uap-core.de>
parents: 106
diff changeset
316 /** Invalid format specifier. */
115
5744a3dee766 completed logical expression parser - NEED TO TEST A LOT!
Mike Becker <universe@uap-core.de>
parents: 114
diff changeset
317 #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
318
5744a3dee766 completed logical expression parser - NEED TO TEST A LOT!
Mike Becker <universe@uap-core.de>
parents: 114
diff changeset
319 /** 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
320 #define DAVQL_ERROR_INVALID_STRING 25
107
a0903d2d8e3e added format specifier parser
Mike Becker <universe@uap-core.de>
parents: 106
diff changeset
321
120
246c50447ebf implemented order by parser
Mike Becker <universe@uap-core.de>
parents: 117
diff changeset
322 /** 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
323 #define DAVQL_ERROR_INVALID_ORDER_CRITERION 26
246c50447ebf implemented order by parser
Mike Becker <universe@uap-core.de>
parents: 117
diff changeset
324
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
325 /** The depth is invalid. */
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
326 #define DAVQL_ERROR_INVALID_DEPTH 101
86
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
327
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
328 /** Nothing about the statement seems legit. */
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
329 #define DAVQL_ERROR_INVALID -1
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
330
121
eea36bf5ffe2 fixed statement type for logical expressions without operator + prepared OOM handling
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
331 /** 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
332 #define DAVQL_ERROR_OUT_OF_MEMORY -2
106
9cec78f23cbf started refactoring davqlparser
Mike Becker <universe@uap-core.de>
parents: 102
diff changeset
333
79
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
334 /**
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
335 * 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
336 *
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
337 * @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
338 */
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
339 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
340
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
341 /**
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
342 * Parses a statement.
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
343 * @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
344 * @return a DavQLStatement object
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
345 */
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
346 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
347
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
348 /**
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
349 * 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
350 */
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
351 #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
352
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
353 /**
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
354 * 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
355 * @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
356 */
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
357 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
358
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
359 #ifdef __cplusplus
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
360 }
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
361 #endif
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
362
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
363 #endif /* DAVQLPARSER_H */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
364

mercurial