Wed, 03 Jun 2015 11:47:38 +0200
fixed grammar for path + added missing string quote escaping (still not perfect: escape sequence is in syntax tree)
libidav/davqlparser.c | file | annotate | diff | comparison | revisions | |
libidav/davqlparser.h | file | annotate | diff | comparison | revisions |
--- 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
--- 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: * * <pre> + * 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. * * <b>SELECT:</b> * <pre>