# HG changeset patch # User Mike Becker # Date 1427194967 -3600 # Node ID ca7f024dd0f95ed860799a95e80657c2cb271e2d # Parent c80bde9c539045cfc97f58eb797d1f74f805fd1b described DavQLStatement grammar + added more features + renamed PUT to SET (for now) diff -r c80bde9c5390 -r ca7f024dd0f9 libidav/davqlparser.h --- a/libidav/davqlparser.h Mon Mar 23 15:48:45 2015 +0100 +++ b/libidav/davqlparser.h Tue Mar 24 12:02:47 2015 +0100 @@ -39,7 +39,7 @@ /** * Enumeration of possible statement types. */ -typedef enum {GET, PUT} davqltype_t; +typedef enum {GET, SET} davqltype_t; /** * Enumeration of possible expression types. @@ -55,8 +55,9 @@ typedef enum { ADD, SUB, MUL, DIV, AND, OR, XOR, NEG, - NOT, LAND, LOR, - EQ, NEQ, LT, GT, LE, GE + NOT, LAND, LOR, LXOR, + EQ, NEQ, LT, GT, LE, GE, + LIKE, UNLIKE } davqloperator_t; /** @@ -101,11 +102,58 @@ * * The grammar for a DavQLStatement is: * - * GET: - * document it so + *
+ * Expression = Expression BinaryOperator Expression
+ *            | UnaryOperator Expression
+ *            | FunctionCall | Identifier | Literal
+ *            | "(", Expression, ")";
+ * 
+ * FunctionCall = Identifier, "(", Expression, ")";
+ * Identifier   = ?Character?, {?Character?};
+ * Literal      = ?Digit?, {?Digit?} | String;
+ * String       = "'", {?Character - "'"? | "'''"} , "'";
+ * 
+ * LogicalExpression = LogicalExpression, LogicalOperator, LogicalExpression
+ *                   | "not ", LogicalExpression
+ *                   | Expression, Comparison, Expression
+ *                   | Expression, (" like " | " unlike "), String
+ *                   | "(", LogicalExpression, ")";
+ * 
+ * UnaryOperator   = "-" | "~";
+ * BinaryOperator  = "+" | "-" | "*" | "/" | "&" | "|" | "^";
+ * LogicalOperator = " and " | " or " | " xor ";
+ * Comparison      = | "=" | "<" | ">" | "<=" | ">=" | "!=";
  * 
- * PUT:
- * make it so
+ * FieldExpressions = "*", {",", Expression, " as ", String}
+ *                  | FieldExpression, {",", FieldExpression};
+ * FieldExpression  = Identifier
+ *                  | Expression, " as ", String;
+ * SetExpressions   = SetExpression, {",", {SetExpressions};
+ * SetExpression    = Identifier, "=", Expression;
+ * 
+ * WithClause = "depth", "=", Expression;
+ * 
+ * 
+ * + * Note: mandatory spaces are part of the grammar. But you may also insert an + * arbitrary amount of optional spaces between two symbols if they are not part + * of an literal or identifier. + * + * GET: + *
+ * GetStatement = "get ", FieldExpressions,
+ * " from ", Identifier,
+ * [" where ", LogicalExpression],
+ * [" with ", WithClause];
+  * 
+ * + * SET: + *
+ * "set ",SetExpressions,
+ * " at ", Identifier,
+ * (" where ", LogicalExpression) | " anywhere",
+ * [" with ", WithClause];
+ * 
* */ typedef struct { @@ -124,7 +172,7 @@ * GET: the list of queried fields (may contain arbitrary expressions) * *
  • - * PUT: the list of DAV properties that shall receive new values + * SET: the list of DAV properties that shall receive new values * (must be a list of IDENTIFIER expressions) *
  • * @@ -135,7 +183,7 @@ * The list of DavQLExpressions for the new DAV property values. * This is NULL for GET queries. */ - UcxList* putvalues; + UcxList* setvalues; /** * A DavQLExpression that denotes the queried path. */