libidav/davqlparser.h

Tue, 28 Apr 2015 16:43:57 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 28 Apr 2015 16:43:57 +0200
changeset 99
579238097973
parent 98
237844f263b4
child 102
e9ae1318a559
permissions
-rw-r--r--

fieldlist parser can now parse fields with alias

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

mercurial