libidav/davqlparser.h

Fri, 17 Apr 2015 16:26:53 +0200

author
Mike Becker <universe@uap-core.de>
date
Fri, 17 Apr 2015 16:26:53 +0200
changeset 97
f82cb65a78ec
parent 96
896022673e0e
child 98
237844f263b4
permissions
-rw-r--r--

fixed static variable fail

76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 /*
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
3 *
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
4 * Copyright 2015 Olaf Wintermann. All rights reserved.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
5 *
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8 *
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
11 *
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15 *
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
28
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
29 #ifndef DAVQLPARSER_H
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
30 #define DAVQLPARSER_H
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
31
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
32 #ifdef __cplusplus
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
33 extern "C" {
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
34 #endif
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
35
79
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
36 #include <stdint.h>
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
37 #include "ucx/string.h"
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
38 #include "ucx/list.h"
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
39
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
40 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
41 * Enumeration of possible statement types.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
42 */
82
0567444f2d76 renamed some enums to avoid collisions with macros + minor grammar change (backsticks for identifiers) + tokenizer + parser skeleton
Mike Becker <universe@uap-core.de>
parents: 80
diff changeset
43 typedef enum {DAVQL_ERROR, DAVQL_GET, DAVQL_SET} davqltype_t;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
44
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
45 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
46 * Enumeration of possible expression types.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
47 */
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
48 typedef enum {
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
49 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
50 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
51 } davqlexprtype_t;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
52
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
53 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
54 * Enumeration of possible expression operators.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
55 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
56 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
57 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
58 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
59 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
60 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
61 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
62 DAVQL_LIKE, DAVQL_UNLIKE // comparisons
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
63 } davqloperator_t;
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 * An expression within a DAVQL query.
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 struct _davqlexpr DavQLExpression;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
69
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
70 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
71 * The structure for type DavQLExpression.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
72 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
73 struct _davqlexpr {
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
74 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
75 * The original expression text.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
76 * Contains the literal value, if type is LITERAL.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
77 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
78 sstr_t srctext;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
79 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
80 * The expression type.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
81 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
82 davqlexprtype_t type;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
83 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
84 * Operator.
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 davqloperator_t op;
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 * Left or single operand.
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
89 * <code>NULL</code> for literals or identifiers.
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
90 */
80
a2832c054c98 added path examination to debugger + changed field names of expression subtrees
Mike Becker <universe@uap-core.de>
parents: 79
diff changeset
91 DavQLExpression *left;
76
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 * Right operand.
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
94 * <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
95 */
80
a2832c054c98 added path examination to debugger + changed field names of expression subtrees
Mike Becker <universe@uap-core.de>
parents: 79
diff changeset
96 DavQLExpression *right;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
97 };
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
98
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
99 /**
8ed7d8df6427 simplified with clause parsing + added order by to data structure and debugger (TODO: implement)
Mike Becker <universe@uap-core.de>
parents: 92
diff changeset
100 * 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
101 */
8ed7d8df6427 simplified with clause parsing + added order by to data structure and debugger (TODO: implement)
Mike Becker <universe@uap-core.de>
parents: 92
diff changeset
102 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
103 /**
8ed7d8df6427 simplified with clause parsing + added order by to data structure and debugger (TODO: implement)
Mike Becker <universe@uap-core.de>
parents: 92
diff changeset
104 * 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
105 */
8ed7d8df6427 simplified with clause parsing + added order by to data structure and debugger (TODO: implement)
Mike Becker <universe@uap-core.de>
parents: 92
diff changeset
106 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
107 /**
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
108 * 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
109 * 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
110 */
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
111 _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
112 } 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
113
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 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
116 * Query statement object.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
117 * 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
118 *
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
119 * The grammar for a DavQLStatement is:
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
120 *
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
121 * <pre>
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
122 * Expression = Expression, BinaryOperator, Expression
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
123 * | UnaryOperator, 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
124 * | FunctionCall | Identifier | Literal
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
125 * | "(", Expression, ")";
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
126 *
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
127 * FunctionCall = Identifier, "(", ArgumentList, ")";
e073cf4afc6a added order by clause to grammar + moved with clause right after the from clause
Mike Becker <universe@uap-core.de>
parents: 91
diff changeset
128 * 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
129 * 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
130 * | "`", ?Character? - "`", {?Character? - "`"}, "`";
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
131 * IdentifierChar = ?Character? - (" "|",");
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
132 * 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
133 * 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
134 * String = "'", {?Character? - "'" | "'''"} , "'" | "%s";
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
135 * 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
136 *
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
137 * LogicalExpression = LogicalExpression, LogicalOperator, LogicalExpression
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
138 * | "not ", LogicalExpression
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
139 * | Expression, Comparison, Expression
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
140 * | Expression, (" like " | " unlike "), String
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
141 * | "(", LogicalExpression, ")";
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
142 *
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
143 * UnaryOperator = "-" | "~";
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
144 * BinaryOperator = "+" | "-" | "*" | "/" | "&" | "|" | "^";
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
145 * 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
146 * Comparison = | "=" | "<" | ">" | "<=" | ">=" | "!=";
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
147 *
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
148 * FieldExpressions = "*", {",", Expression, " as ", String}
86
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
149 * | FieldExpression, {",", FieldExpression}
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
150 * | "-";
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
151 * FieldExpression = Identifier
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
152 * | Expression, " as ", String;
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
153 * SetExpressions = SetExpression, {",", SetExpressions};
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
154 * 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
155 *
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
156 * Path = "%s"
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
157 * | "/", {?Character? - " "}
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
158 * | "'/", {?Character?}, "'";
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
159 *
85
0ab1cf261a44 improved grammar + changed depth default, type and added infinity
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
160 * 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
161 *
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
162 * 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
163 * 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
164 *
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
165 * </pre>
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
166 *
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
167 * 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
168 * arbitrary amount of optional spaces between two symbols if they are not part
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
169 * of an literal or identifier.
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
170 *
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
171 * <b>GET:</b>
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
172 * <pre>
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
173 * GetStatement = "get ", FieldExpressions,
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
174 * " 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
175 * [" 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
176 * [" 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
177 * [" 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
178 * </pre>
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
179 *
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
180 * <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
181 * <pre>
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
182 * "set ",SetExpressions,
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
183 * " 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
184 * [" 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
185 * (" 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
186 * </pre>
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
187 *
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
188 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
189 typedef struct {
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
190 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
191 * The original query text.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
192 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
193 sstr_t srctext;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
194 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
195 * The statement type.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
196 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
197 davqltype_t type;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
198 /**
86
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
199 * 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
200 */
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
201 int errorcode;
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
202 /**
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
203 * Error message, if any error occurred.
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
204 */
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
205 char* errormessage;
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
206 /**
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
207 * The list of field expressions.
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
208 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
209 UcxList* fields;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
210 /**
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
211 * The list of DavQLExpressions for the new DAV property values.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
212 * This is <code>NULL</code> for GET queries.
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
213 */
78
ca7f024dd0f9 described DavQLStatement grammar + added more features + renamed PUT to SET (for now)
Mike Becker <universe@uap-core.de>
parents: 77
diff changeset
214 UcxList* setvalues;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
215 /**
87
ed21d95984bb removed DavQLExpression type for path (since it always is an identifier)
Mike Becker <universe@uap-core.de>
parents: 86
diff changeset
216 * 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
217 */
87
ed21d95984bb removed DavQLExpression type for path (since it always is an identifier)
Mike Becker <universe@uap-core.de>
parents: 86
diff changeset
218 sstr_t path;
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
219 /**
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
220 * Logical expression for selection.
77
c80bde9c5390 added missing stuff to davql types
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
221 * <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
222 */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
223 DavQLExpression* where;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
224 /**
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
225 * 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
226 * 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
227 * 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
228 */
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
229 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
230 /**
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
231 * 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
232 * 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
233 * 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
234 * DAV_DEPTH_PLACEHOLDER for a placeholder.
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
235 */
85
0ab1cf261a44 improved grammar + changed depth default, type and added infinity
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
236 int depth;
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
237 } DavQLStatement;
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
238
86
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
239 /** 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
240 #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
241
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
242 /** 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
243 #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
244
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
245 /** Invalid path. */
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
246 #define DAVQL_ERROR_INVALID_PATH 1
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
247
91
838b427267bb parser verifies that path is an identifier
Mike Becker <universe@uap-core.de>
parents: 90
diff changeset
248 /** Expected an identifier, but found something else. */
838b427267bb parser verifies that path is an identifier
Mike Becker <universe@uap-core.de>
parents: 90
diff changeset
249 #define DAVQL_ERROR_IDENTIFIER_EXPECTED 10
838b427267bb parser verifies that path is an identifier
Mike Becker <universe@uap-core.de>
parents: 90
diff changeset
250
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
251 /** Expected an identifier or literal, but found something else. */
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
252 #define DAVQL_ERROR_IDORLIT_EXPECTED 11
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
253
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
254 /** Expected an identifier or number, but found something else. */
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
255 #define DAVQL_ERROR_IDORNUM_EXPECTED 12
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
256
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
257 /** Expected an identifier or string, but found something else. */
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
258 #define DAVQL_ERROR_IDORSTR_EXPECTED 13
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
259
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
260 /** Expected an identifier or timestamp, but found something else. */
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
261 #define DAVQL_ERROR_IDORTS_EXPECTED 14
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
262
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
263 /** The with-clause contains an unknown attribute. */
785f6007a0c1 parser for with clause + unexpected token message, if something is beyond the with clause
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
264 #define DAVQL_ERROR_UNKNOWN_ATTRIBUTE 20
785f6007a0c1 parser for with clause + unexpected token message, if something is beyond the with clause
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
265
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
266 /** Depth must be greater than zero or infinity. */
785f6007a0c1 parser for with clause + unexpected token message, if something is beyond the with clause
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
267 #define DAVQL_ERROR_INVALID_DEPTH 21
785f6007a0c1 parser for with clause + unexpected token message, if something is beyond the with clause
Mike Becker <universe@uap-core.de>
parents: 88
diff changeset
268
90
46971430650b parser for with-clause ready to parse more attributes, but marks duplicated attributes as error
Mike Becker <universe@uap-core.de>
parents: 89
diff changeset
269 /** The with-clause contains an attribute more than once. */
46971430650b parser for with-clause ready to parse more attributes, but marks duplicated attributes as error
Mike Becker <universe@uap-core.de>
parents: 89
diff changeset
270 #define DAVQL_ERROR_DUPLICATED_ATTRIBUTE 29
46971430650b parser for with-clause ready to parse more attributes, but marks duplicated attributes as error
Mike Becker <universe@uap-core.de>
parents: 89
diff changeset
271
96
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
272 /** The format specifier is missing. */
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
273 #define DAVQL_ERROR_MISSING_FMTSPEC 30
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
274
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
275 /** The format specifier is unknown. */
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
276 #define DAVQL_ERROR_UNKNOWN_FMTSPEC 31
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
277
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
278 /** The format specifier is invalid. */
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
279 #define DAVQL_ERROR_INVALID_FMTSPEC 39
896022673e0e special path parser + typed literals + order by parser + grammar changes
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
280
88
4d6b03bd7034 tokenizer now correctly handles quoted tokens
Mike Becker <universe@uap-core.de>
parents: 87
diff changeset
281 /** A quote symbol (' or `) is missing. */
4d6b03bd7034 tokenizer now correctly handles quoted tokens
Mike Becker <universe@uap-core.de>
parents: 87
diff changeset
282 #define DAVQL_ERROR_MISSING_QUOTE 50
4d6b03bd7034 tokenizer now correctly handles quoted tokens
Mike Becker <universe@uap-core.de>
parents: 87
diff changeset
283
86
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
284 /** No more tokens to parse, but the parser expected more. */
88
4d6b03bd7034 tokenizer now correctly handles quoted tokens
Mike Becker <universe@uap-core.de>
parents: 87
diff changeset
285 #define DAVQL_ERROR_UNEXPECTED_END 100
86
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
286
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
287 /** A token was found, which has not been expected. */
88
4d6b03bd7034 tokenizer now correctly handles quoted tokens
Mike Becker <universe@uap-core.de>
parents: 87
diff changeset
288 #define DAVQL_ERROR_UNEXPECTED_TOKEN 101
86
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
289
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
290 /** Nothing about the statement seems legit. */
ecba8bdf9741 davql: error handling + minor grammar changes
Mike Becker <universe@uap-core.de>
parents: 85
diff changeset
291 #define DAVQL_ERROR_INVALID -1
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
292
79
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
293 /**
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
294 * 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
295 *
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
296 * @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
297 */
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
298 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
299
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
300 /**
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
301 * Parses a statement.
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
302 * @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
303 * @return a DavQLStatement object
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
304 */
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
305 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
306
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
307 /**
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
308 * 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
309 */
59c518ae0641 added parse function prototype + started writing a debugger
Mike Becker <universe@uap-core.de>
parents: 78
diff changeset
310 #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
311
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
312 /**
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
313 * 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
314 * @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
315 */
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
316 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
317
76
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
318 #ifdef __cplusplus
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
319 }
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
320 #endif
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
321
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
322 #endif /* DAVQLPARSER_H */
4c48ce3b9045 structure draft for DavQL statements
Mike Becker <universe@uap-core.de>
parents:
diff changeset
323

mercurial