libidav/davqlparser.h

changeset 106
9cec78f23cbf
parent 102
e9ae1318a559
child 107
a0903d2d8e3e
equal deleted inserted replaced
105:ee0de2b1872e 106:9cec78f23cbf
41 * Enumeration of possible statement types. 41 * Enumeration of possible statement types.
42 */ 42 */
43 typedef enum {DAVQL_ERROR, DAVQL_GET, DAVQL_SET} davqltype_t; 43 typedef enum {DAVQL_ERROR, DAVQL_GET, DAVQL_SET} davqltype_t;
44 44
45 /** 45 /**
46 * Enumeration of possible token classes.
47 */
48 typedef enum {
49 DAVQL_TOKEN_INVALID, DAVQL_TOKEN_KEYWORD,
50 DAVQL_TOKEN_IDENTIFIER, DAVQL_TOKEN_FMTSPEC,
51 DAVQL_TOKEN_STRING, DAVQL_TOKEN_NUMBER, DAVQL_TOKEN_TIMESTAMP,
52 DAVQL_TOKEN_COMMA, DAVQL_TOKEN_OPENP, DAVQL_TOKEN_CLOSEP,
53 DAVQL_TOKEN_EQ, DAVQL_TOKEN_LT, DAVQL_TOKEN_GT, DAVQL_TOKEN_EXCLAIM,
54 DAVQL_TOKEN_OPERATOR
55 } davqltokenclass_t;
56
57 /**
46 * Enumeration of possible expression types. 58 * Enumeration of possible expression types.
47 */ 59 */
48 typedef enum { 60 typedef enum {
49 DAVQL_UNDEFINED_TYP, 61 DAVQL_UNDEFINED_TYPE,
50 DAVQL_NUMBER, DAVQL_STRING, DAVQL_TIMESTAMP, DAVQL_IDENTIFIER, 62 DAVQL_NUMBER, DAVQL_STRING, DAVQL_TIMESTAMP, DAVQL_IDENTIFIER,
51 DAVQL_UNARY, DAVQL_BINARY, DAVQL_LOGICAL, DAVQL_FUNCCALL 63 DAVQL_UNARY, DAVQL_BINARY, DAVQL_LOGICAL, DAVQL_FUNCCALL
52 } davqlexprtype_t; 64 } davqlexprtype_t;
53 65
54 /** 66 /**
61 DAVQL_NOT, DAVQL_LAND, DAVQL_LOR, DAVQL_LXOR, // logical 73 DAVQL_NOT, DAVQL_LAND, DAVQL_LOR, DAVQL_LXOR, // logical
62 DAVQL_EQ, DAVQL_NEQ, DAVQL_LT, DAVQL_GT, DAVQL_LE, DAVQL_GE, 74 DAVQL_EQ, DAVQL_NEQ, DAVQL_LT, DAVQL_GT, DAVQL_LE, DAVQL_GE,
63 DAVQL_LIKE, DAVQL_UNLIKE // comparisons 75 DAVQL_LIKE, DAVQL_UNLIKE // comparisons
64 } davqloperator_t; 76 } davqloperator_t;
65 77
78 typedef struct {
79 davqltokenclass_t tokenclass;
80 sstr_t value;
81 } DavQLToken;
82
66 /** 83 /**
67 * An expression within a DAVQL query. 84 * An expression within a DAVQL query.
68 */ 85 */
69 typedef struct _davqlexpr DavQLExpression; 86 typedef struct _davqlexpr DavQLExpression;
70 87
143 * <pre> 160 * <pre>
144 * Expression = AddExpression; 161 * Expression = AddExpression;
145 * AddExpression = MultExpression, [AddOperator, AddExpression]; 162 * AddExpression = MultExpression, [AddOperator, AddExpression];
146 * MultExpression = BitwiseExpression, [MultOperator, MultExpression]; 163 * MultExpression = BitwiseExpression, [MultOperator, MultExpression];
147 * BitwiseExpression = UnaryExpression, [BitwiseOperator, BitwiseExpression]; 164 * BitwiseExpression = UnaryExpression, [BitwiseOperator, BitwiseExpression];
148 * UnaryExpression = [UnaryOperator], (AtomicExpression | ParExpression); 165 * UnaryExpression = [UnaryOperator], (ParExpression | AtomicExpression);
149 * AtomicExpression = FunctionCall | Identifier | Literal; 166 * AtomicExpression = FunctionCall | Identifier | Literal;
150 * ParExpression = "(", Expression, ")"; 167 * ParExpression = "(", Expression, ")";
151 * 168 *
152 * BitwiseOperator = "&" | "|" | "^"; 169 * BitwiseOperator = "&" | "|" | "^";
153 * MultOperator = "*" | "/"; 170 * MultOperator = "*" | "/";
172 * | FunctionCall | Identifier; 189 * | FunctionCall | Identifier;
173 * 190 *
174 * LogicalOperator = " and " | " or " | " xor "; 191 * LogicalOperator = " and " | " or " | " xor ";
175 * Comparison = | "=" | "<" | ">" | "<=" | ">=" | "!="; 192 * Comparison = | "=" | "<" | ">" | "<=" | ">=" | "!=";
176 * 193 *
177 * FieldExpressions = "*", {",", Expression, " as ", Identifier} 194 * FieldExpressions = "-"
178 * | FieldExpression, {",", FieldExpression} 195 * | "*", {",", Expression, " as ", Identifier}
179 * | "-"; 196 * | FieldExpression, {",", FieldExpression};
180 * FieldExpression = Identifier 197 * FieldExpression = Identifier
181 * | Expression, " as ", Identifier; 198 * | Expression, " as ", Identifier;
182 * SetExpressions = SetExpression, {",", SetExpression}; 199 * SetExpressions = SetExpression, {",", SetExpression};
183 * SetExpression = Identifier, "=", Expression; 200 * SetExpression = Identifier, "=", Expression;
184 * 201 *
264 #define DAV_DEPTH_INFINITY -1 281 #define DAV_DEPTH_INFINITY -1
265 282
266 /** Depth needs to be specified at runtime. */ 283 /** Depth needs to be specified at runtime. */
267 #define DAV_DEPTH_PLACEHOLDER -2 284 #define DAV_DEPTH_PLACEHOLDER -2
268 285
269 /** Invalid path. */ 286 /** Unexpected token. */
270 #define DAVQL_ERROR_INVALID_PATH 1 287 #define DAVQL_ERROR_UNEXPECTED_TOKEN 1
271 288
272 /** Expected an identifier, but found something else. */ 289 /** A token has been found, for which no token class is applicable. */
273 #define DAVQL_ERROR_IDENTIFIER_EXPECTED 10 290 #define DAVQL_ERROR_INVALID_TOKEN 2
274 291
275 /** Expected an identifier or literal, but found something else. */ 292 /** A token that has been expected was not found. */
276 #define DAVQL_ERROR_IDORLIT_EXPECTED 11 293 #define DAVQL_ERROR_MISSING_TOKEN 11
277 294
278 /** Expected an identifier or number, but found something else. */ 295 /** An expression has been expected, but was not found. */
279 #define DAVQL_ERROR_IDORNUM_EXPECTED 12 296 #define DAVQL_ERROR_MISSING_EXPR 12
280 297
281 /** Expected an identifier or string, but found something else. */ 298 /** An operator has been found for a unary expression, but it is invalid. */
282 #define DAVQL_ERROR_IDORSTR_EXPECTED 13 299 #define DAVQL_ERROR_INVALID_UNARY_OP 21
283 300
284 /** Expected an identifier or timestamp, but found something else. */ 301 /** The depth is invalid. */
285 #define DAVQL_ERROR_IDORTS_EXPECTED 14 302 #define DAVQL_ERROR_INVALID_DEPTH 101
286
287 /** The with-clause contains an unknown attribute. */
288 #define DAVQL_ERROR_UNKNOWN_ATTRIBUTE 20
289
290 /** Depth must be greater than zero or infinity. */
291 #define DAVQL_ERROR_INVALID_DEPTH 21
292
293 /** The with-clause contains an attribute more than once. */
294 #define DAVQL_ERROR_DUPLICATED_ATTRIBUTE 29
295
296 /** The format specifier is missing. */
297 #define DAVQL_ERROR_MISSING_FMTSPEC 30
298
299 /** The format specifier is unknown. */
300 #define DAVQL_ERROR_UNKNOWN_FMTSPEC 31
301
302 /** The format specifier is invalid. */
303 #define DAVQL_ERROR_INVALID_FMTSPEC 39
304
305 /** A quote symbol (' or `) is missing. */
306 #define DAVQL_ERROR_MISSING_QUOTE 50
307
308 /** No more tokens to parse, but the parser expected more. */
309 #define DAVQL_ERROR_UNEXPECTED_END 100
310
311 /** A token was found, which has not been expected. */
312 #define DAVQL_ERROR_UNEXPECTED_TOKEN 101
313 303
314 /** Nothing about the statement seems legit. */ 304 /** Nothing about the statement seems legit. */
315 #define DAVQL_ERROR_INVALID -1 305 #define DAVQL_ERROR_INVALID -1
306
307 /** Unhandled error */
308 #define DAVQL_ERROR_UNHANDLED -2
316 309
317 /** 310 /**
318 * Starts an interactive debugger for a DavQLStatement. 311 * Starts an interactive debugger for a DavQLStatement.
319 * 312 *
320 * @param stmt the statement to debug 313 * @param stmt the statement to debug

mercurial