fixed parsing of binary expressions did not yield the correct type

Wed, 13 May 2015 20:29:11 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 13 May 2015 20:29:11 +0200
changeset 108
0199f13c7fe2
parent 107
a0903d2d8e3e
child 109
020a5b5aa510

fixed parsing of binary expressions did not yield the correct type

libidav/davqlparser.c file | annotate | diff | comparison | revisions
libidav/davqlparser.h file | annotate | diff | comparison | revisions
--- a/libidav/davqlparser.c	Wed May 13 20:18:36 2015 +0200
+++ b/libidav/davqlparser.c	Wed May 13 20:29:11 2015 +0200
@@ -361,6 +361,7 @@
 #define _error_missing_by "expecting BY keyword " _error_context
 #define _error_invalid_depth "invalid depth " _error_context
 #define _error_missing_expr "missing expression " _error_context
+#define _error_invalid_expr "invalid expression " _error_context
 #define _error_invalid_unary_op "invalid unary operator "  _error_context
 #define _error_invalid_fmtspec "invalid format specifier " _error_context
 
@@ -563,6 +564,7 @@
     if (token_is(token, DAVQL_TOKEN_OPERATOR) &&
             (op = strchr(opc, token_sstr(token).ptr[0]))) {
         expr->op = opv[op-opc];
+        expr->type = DAVQL_BINARY;
         total_consumed++;
         token = token->next;
         memset(&right, 0, sizeof(DavQLExpression));
@@ -733,6 +735,9 @@
                 consumed = dav_parse_expression(stmt, token, expr);
                 if (expr->type == DAVQL_UNDEFINED_TYPE) {
                     dav_free_expression(expr);
+                    consumed = 0;
+                    dav_error_in_context(DAVQL_ERROR_INVALID_EXPR,
+                        _error_invalid_expr, stmt, token);
                 } else {
                     DavQLField *field = malloc(sizeof(DavQLField));
                     field->expr = expr;
@@ -831,6 +836,9 @@
 
     // Consume field list
     tokens = ucx_list_get(tokens, dav_parse_fieldlist(stmt, tokens));
+    if (stmt->errorcode) {
+        return;
+    }
     
     // Consume from keyword
     if (token_is(tokens, DAVQL_TOKEN_KEYWORD)
--- a/libidav/davqlparser.h	Wed May 13 20:18:36 2015 +0200
+++ b/libidav/davqlparser.h	Wed May 13 20:29:11 2015 +0200
@@ -295,11 +295,14 @@
 /** An expression has been expected, but was not found. */
 #define DAVQL_ERROR_MISSING_EXPR 12
 
+/** The type of the expression could not be determined. */
+#define DAVQL_ERROR_INVALID_EXPR 21
+
 /** An operator has been found for a unary expression, but it is invalid. */
-#define DAVQL_ERROR_INVALID_UNARY_OP 21
+#define DAVQL_ERROR_INVALID_UNARY_OP 22
 
 /** Invalid format specifier. */
-#define DAVQL_ERROR_INVALID_FMTSPEC 22
+#define DAVQL_ERROR_INVALID_FMTSPEC 23
 
 /** The depth is invalid. */
 #define DAVQL_ERROR_INVALID_DEPTH 101

mercurial