libidav/davqlparser.h

changeset 96
896022673e0e
parent 95
8ed7d8df6427
child 98
237844f263b4
--- a/libidav/davqlparser.h	Fri Apr 17 13:11:58 2015 +0200
+++ b/libidav/davqlparser.h	Fri Apr 17 16:09:43 2015 +0200
@@ -46,7 +46,7 @@
  * Enumeration of possible expression types.
  */
 typedef enum {
-    DAVQL_LITERAL, DAVQL_IDENTIFIER,
+    DAVQL_NUMBER, DAVQL_STRING, DAVQL_TIMESTAMP, DAVQL_IDENTIFIER,
     DAVQL_UNARY, DAVQL_BINARY, DAVQL_LOGICAL, DAVQL_FUNCCALL
 } davqlexprtype_t;
 
@@ -105,9 +105,10 @@
      */
     DavQLExpression *column;
     /**
-     * True, if the result shall be sorted ascending, false otherwise.
+     * True, if the result shall be sorted descending, false otherwise.
+     * Default is false (ascending).
      */
-    _Bool ascending;
+    _Bool descending;
 } DavQLOrderCriterion;
 
 
@@ -126,11 +127,12 @@
  * FunctionCall    = Identifier, "(", ArgumentList, ")";
  * ArgumentList    = Expression, {",", Expression};
  * Identifier      = IdentifierChar - ?Digit?, {IdentifierChar}
- *                 | "`", ?Character?, {?Character?}, "`";
- * IdentifierChar  = ?Character - (" "|",")?;
- * Literal         = Number | String;
+ *                 | "`", ?Character? - "`", {?Character? - "`"}, "`";
+ * IdentifierChar  = ?Character? - (" "|",");
+ * Literal         = Number | String | Timestamp;
  * Number          = ?Digit?, {?Digit?} | "%d";
- * String          = "'", {?Character - "'"? | "'''"} , "'";
+ * String          = "'", {?Character? - "'" | "'''"} , "'" | "%s";
+ * Timestamp       = "%t"; // TODO: maybe introduce a real literal 
  * 
  * LogicalExpression = LogicalExpression, LogicalOperator, LogicalExpression
  *                   | "not ", LogicalExpression
@@ -151,6 +153,10 @@
  * SetExpressions   = SetExpression, {",", SetExpressions};
  * SetExpression    = Identifier, "=", Expression;
  * 
+ * Path = "%s"
+ *      | "/", {?Character? - " "}
+ *      | "'/", {?Character?}, "'";
+ * 
  * WithClause = "depth", "=", (Number | "infinity");
  * 
  * OrderByClause    = OrderByCriterion, {",", OrderByCriterion};
@@ -165,7 +171,7 @@
  * <b>GET:</b>
  * <pre>
  * GetStatement = "get ", FieldExpressions,
- * " from ", Identifier,
+ * " from ", Path,
  * [" with ", WithClause],
  * [" where ", LogicalExpression],
  * [" order by ", OrderByClause];
@@ -174,7 +180,7 @@
  * <b>SET:</b>
  * <pre>
  * "set ",SetExpressions,
- * " at ", Identifier,
+ * " at ", Path,
  * [" with ", WithClause],
  * (" where ", LogicalExpression) | " anywhere";
  * </pre>
@@ -224,6 +230,8 @@
     /**
      * The recursion depth for the statement.
      * Defaults to 1.
+     * Magic numbers are DAV_DEPTH_INFINITY for infinity and
+     * DAV_DEPTH_PLACEHOLDER for a placeholder.
      */
     int depth;
 } DavQLStatement;
@@ -231,9 +239,27 @@
 /** Infinity recursion depth for a DavQLStatement. */
 #define DAV_DEPTH_INFINITY -1
 
+/** Depth needs to be specified at runtime. */
+#define DAV_DEPTH_PLACEHOLDER -2
+
+/** Invalid path. */
+#define DAVQL_ERROR_INVALID_PATH 1
+
 /** Expected an identifier, but found something else. */
 #define DAVQL_ERROR_IDENTIFIER_EXPECTED 10
 
+/** Expected an identifier or literal, but found something else. */
+#define DAVQL_ERROR_IDORLIT_EXPECTED 11
+
+/** Expected an identifier or number, but found something else. */
+#define DAVQL_ERROR_IDORNUM_EXPECTED 12
+
+/** Expected an identifier or string, but found something else. */
+#define DAVQL_ERROR_IDORSTR_EXPECTED 13
+
+/** Expected an identifier or timestamp, but found something else. */
+#define DAVQL_ERROR_IDORTS_EXPECTED 14
+
 /** The with-clause contains an unknown attribute. */
 #define DAVQL_ERROR_UNKNOWN_ATTRIBUTE 20
 
@@ -243,6 +269,15 @@
 /** The with-clause contains an attribute more than once. */
 #define DAVQL_ERROR_DUPLICATED_ATTRIBUTE 29
 
+/** The format specifier is missing. */
+#define DAVQL_ERROR_MISSING_FMTSPEC 30
+
+/** The format specifier is unknown. */
+#define DAVQL_ERROR_UNKNOWN_FMTSPEC 31
+
+/** The format specifier is invalid. */
+#define DAVQL_ERROR_INVALID_FMTSPEC 39
+
 /** A quote symbol (' or `) is missing. */
 #define DAVQL_ERROR_MISSING_QUOTE 50
 

mercurial