# HG changeset patch # User Mike Becker # Date 1433324858 -7200 # Node ID 80d273229f245b7d1c21ec42d235d179327a2813 # Parent 7532963bd15b3466a085943d0ab33d1cf23552ee fixed grammar for path + added missing string quote escaping (still not perfect: escape sequence is in syntax tree) diff -r 7532963bd15b -r 80d273229f24 libidav/davqlparser.c --- a/libidav/davqlparser.c Tue Jun 02 21:03:58 2015 +0200 +++ b/libidav/davqlparser.c Wed Jun 03 11:47:38 2015 +0200 @@ -515,11 +515,18 @@ // quoted strings / identifiers are a single token if (src.ptr[i] == '\'' || src.ptr[i] == '`') { if (src.ptr[i] == insequence) { - // add quoted token to list - token->value.length++; - tokens = dav_parse_add_token(tokens, token); - token = NULL; - insequence = '\0'; + // lookahead for escaped string quotes + if (src.ptr[i] == '\'' && i+2 < src.length && + src.ptr[i+1] == src.ptr[i] && src.ptr[i+2] == src.ptr[i]) { + token->value.length += 3; + i += 2; + } else { + // add quoted token to list + token->value.length++; + tokens = dav_parse_add_token(tokens, token); + token = NULL; + insequence = '\0'; + } } else if (insequence == '\0') { insequence = src.ptr[i]; // always create new token for quoted strings diff -r 7532963bd15b -r 80d273229f24 libidav/davqlparser.h --- a/libidav/davqlparser.h Tue Jun 02 21:03:58 2015 +0200 +++ b/libidav/davqlparser.h Wed Jun 03 11:47:38 2015 +0200 @@ -157,6 +157,9 @@ * The grammar for a DavQLStatement is: * *
+ * Keyword = "select" | "set" | "from" | "at" | "as" | "where" | "with"
+ *         | "order" | "by" | "asc" | "desc";
+ * 
  * Expression        = AddExpression;
  * AddExpression     = MultExpression, [AddOperator, AddExpression];
  * MultExpression    = BitwiseExpression, [MultOperator, MultExpression];
@@ -200,9 +203,9 @@
  * SetExpressions   = SetExpression, {",", SetExpression};
  * SetExpression    = Identifier, "=", Expression;
  * 
- * Path = "%s"
- *      | "/", {?Character? - " "}
- *      | "'/", {?Character?}, "'";
+ * Path     = String
+ *          | "/", [PathNode, {"/", PathNode}], ["/"];
+ * PathNode = {{?Character? - "/"} - Keyword};
  * 
  * WithClause = "depth", "=", (Number | "infinity");
  * 
@@ -213,7 +216,7 @@
  * 
  * 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.
+ * of an literal, identifier or the path.
  * 
  * SELECT:
  *