libidav/davqlparser.h

changeset 96
896022673e0e
parent 95
8ed7d8df6427
child 98
237844f263b4
equal deleted inserted replaced
95:8ed7d8df6427 96:896022673e0e
44 44
45 /** 45 /**
46 * Enumeration of possible expression types. 46 * Enumeration of possible expression types.
47 */ 47 */
48 typedef enum { 48 typedef enum {
49 DAVQL_LITERAL, DAVQL_IDENTIFIER, 49 DAVQL_NUMBER, DAVQL_STRING, DAVQL_TIMESTAMP, DAVQL_IDENTIFIER,
50 DAVQL_UNARY, DAVQL_BINARY, DAVQL_LOGICAL, DAVQL_FUNCCALL 50 DAVQL_UNARY, DAVQL_BINARY, DAVQL_LOGICAL, DAVQL_FUNCCALL
51 } davqlexprtype_t; 51 } davqlexprtype_t;
52 52
53 /** 53 /**
54 * Enumeration of possible expression operators. 54 * Enumeration of possible expression operators.
103 /** 103 /**
104 * The column. 104 * The column.
105 */ 105 */
106 DavQLExpression *column; 106 DavQLExpression *column;
107 /** 107 /**
108 * True, if the result shall be sorted ascending, false otherwise. 108 * True, if the result shall be sorted descending, false otherwise.
109 */ 109 * Default is false (ascending).
110 _Bool ascending; 110 */
111 _Bool descending;
111 } DavQLOrderCriterion; 112 } DavQLOrderCriterion;
112 113
113 114
114 /** 115 /**
115 * Query statement object. 116 * Query statement object.
124 * | "(", Expression, ")"; 125 * | "(", Expression, ")";
125 * 126 *
126 * FunctionCall = Identifier, "(", ArgumentList, ")"; 127 * FunctionCall = Identifier, "(", ArgumentList, ")";
127 * ArgumentList = Expression, {",", Expression}; 128 * ArgumentList = Expression, {",", Expression};
128 * Identifier = IdentifierChar - ?Digit?, {IdentifierChar} 129 * Identifier = IdentifierChar - ?Digit?, {IdentifierChar}
129 * | "`", ?Character?, {?Character?}, "`"; 130 * | "`", ?Character? - "`", {?Character? - "`"}, "`";
130 * IdentifierChar = ?Character - (" "|",")?; 131 * IdentifierChar = ?Character? - (" "|",");
131 * Literal = Number | String; 132 * Literal = Number | String | Timestamp;
132 * Number = ?Digit?, {?Digit?} | "%d"; 133 * Number = ?Digit?, {?Digit?} | "%d";
133 * String = "'", {?Character - "'"? | "'''"} , "'"; 134 * String = "'", {?Character? - "'" | "'''"} , "'" | "%s";
135 * Timestamp = "%t"; // TODO: maybe introduce a real literal
134 * 136 *
135 * LogicalExpression = LogicalExpression, LogicalOperator, LogicalExpression 137 * LogicalExpression = LogicalExpression, LogicalOperator, LogicalExpression
136 * | "not ", LogicalExpression 138 * | "not ", LogicalExpression
137 * | Expression, Comparison, Expression 139 * | Expression, Comparison, Expression
138 * | Expression, (" like " | " unlike "), String 140 * | Expression, (" like " | " unlike "), String
149 * FieldExpression = Identifier 151 * FieldExpression = Identifier
150 * | Expression, " as ", String; 152 * | Expression, " as ", String;
151 * SetExpressions = SetExpression, {",", SetExpressions}; 153 * SetExpressions = SetExpression, {",", SetExpressions};
152 * SetExpression = Identifier, "=", Expression; 154 * SetExpression = Identifier, "=", Expression;
153 * 155 *
156 * Path = "%s"
157 * | "/", {?Character? - " "}
158 * | "'/", {?Character?}, "'";
159 *
154 * WithClause = "depth", "=", (Number | "infinity"); 160 * WithClause = "depth", "=", (Number | "infinity");
155 * 161 *
156 * OrderByClause = OrderByCriterion, {",", OrderByCriterion}; 162 * OrderByClause = OrderByCriterion, {",", OrderByCriterion};
157 * OrderByCriterion = (Identifier | Number), [" asc"|" desc"]; 163 * OrderByCriterion = (Identifier | Number), [" asc"|" desc"];
158 * 164 *
163 * of an literal or identifier. 169 * of an literal or identifier.
164 * 170 *
165 * <b>GET:</b> 171 * <b>GET:</b>
166 * <pre> 172 * <pre>
167 * GetStatement = "get ", FieldExpressions, 173 * GetStatement = "get ", FieldExpressions,
168 * " from ", Identifier, 174 * " from ", Path,
169 * [" with ", WithClause], 175 * [" with ", WithClause],
170 * [" where ", LogicalExpression], 176 * [" where ", LogicalExpression],
171 * [" order by ", OrderByClause]; 177 * [" order by ", OrderByClause];
172 * </pre> 178 * </pre>
173 * 179 *
174 * <b>SET:</b> 180 * <b>SET:</b>
175 * <pre> 181 * <pre>
176 * "set ",SetExpressions, 182 * "set ",SetExpressions,
177 * " at ", Identifier, 183 * " at ", Path,
178 * [" with ", WithClause], 184 * [" with ", WithClause],
179 * (" where ", LogicalExpression) | " anywhere"; 185 * (" where ", LogicalExpression) | " anywhere";
180 * </pre> 186 * </pre>
181 * 187 *
182 */ 188 */
222 */ 228 */
223 UcxList* orderby; 229 UcxList* orderby;
224 /** 230 /**
225 * The recursion depth for the statement. 231 * The recursion depth for the statement.
226 * Defaults to 1. 232 * Defaults to 1.
233 * Magic numbers are DAV_DEPTH_INFINITY for infinity and
234 * DAV_DEPTH_PLACEHOLDER for a placeholder.
227 */ 235 */
228 int depth; 236 int depth;
229 } DavQLStatement; 237 } DavQLStatement;
230 238
231 /** Infinity recursion depth for a DavQLStatement. */ 239 /** Infinity recursion depth for a DavQLStatement. */
232 #define DAV_DEPTH_INFINITY -1 240 #define DAV_DEPTH_INFINITY -1
233 241
242 /** Depth needs to be specified at runtime. */
243 #define DAV_DEPTH_PLACEHOLDER -2
244
245 /** Invalid path. */
246 #define DAVQL_ERROR_INVALID_PATH 1
247
234 /** Expected an identifier, but found something else. */ 248 /** Expected an identifier, but found something else. */
235 #define DAVQL_ERROR_IDENTIFIER_EXPECTED 10 249 #define DAVQL_ERROR_IDENTIFIER_EXPECTED 10
236 250
251 /** Expected an identifier or literal, but found something else. */
252 #define DAVQL_ERROR_IDORLIT_EXPECTED 11
253
254 /** Expected an identifier or number, but found something else. */
255 #define DAVQL_ERROR_IDORNUM_EXPECTED 12
256
257 /** Expected an identifier or string, but found something else. */
258 #define DAVQL_ERROR_IDORSTR_EXPECTED 13
259
260 /** Expected an identifier or timestamp, but found something else. */
261 #define DAVQL_ERROR_IDORTS_EXPECTED 14
262
237 /** The with-clause contains an unknown attribute. */ 263 /** The with-clause contains an unknown attribute. */
238 #define DAVQL_ERROR_UNKNOWN_ATTRIBUTE 20 264 #define DAVQL_ERROR_UNKNOWN_ATTRIBUTE 20
239 265
240 /** Depth must be greater than zero or infinity. */ 266 /** Depth must be greater than zero or infinity. */
241 #define DAVQL_ERROR_INVALID_DEPTH 21 267 #define DAVQL_ERROR_INVALID_DEPTH 21
242 268
243 /** The with-clause contains an attribute more than once. */ 269 /** The with-clause contains an attribute more than once. */
244 #define DAVQL_ERROR_DUPLICATED_ATTRIBUTE 29 270 #define DAVQL_ERROR_DUPLICATED_ATTRIBUTE 29
271
272 /** The format specifier is missing. */
273 #define DAVQL_ERROR_MISSING_FMTSPEC 30
274
275 /** The format specifier is unknown. */
276 #define DAVQL_ERROR_UNKNOWN_FMTSPEC 31
277
278 /** The format specifier is invalid. */
279 #define DAVQL_ERROR_INVALID_FMTSPEC 39
245 280
246 /** A quote symbol (' or `) is missing. */ 281 /** A quote symbol (' or `) is missing. */
247 #define DAVQL_ERROR_MISSING_QUOTE 50 282 #define DAVQL_ERROR_MISSING_QUOTE 50
248 283
249 /** No more tokens to parse, but the parser expected more. */ 284 /** No more tokens to parse, but the parser expected more. */

mercurial