433 // special symbols are single tokens - the % sign MUST NOT be a special symbol |
433 // special symbols are single tokens - the % sign MUST NOT be a special symbol |
434 static const char *special_token_symbols = ",()+-*/&|^~=!<>"; |
434 static const char *special_token_symbols = ",()+-*/&|^~=!<>"; |
435 |
435 |
436 static _Bool iskeyword(DavQLToken *token) { |
436 static _Bool iskeyword(DavQLToken *token) { |
437 sstr_t keywords[] ={ST("select"), ST("set"), ST("from"), ST("at"), ST("as"), |
437 sstr_t keywords[] ={ST("select"), ST("set"), ST("from"), ST("at"), ST("as"), |
438 ST("where"), ST("with"), ST("order"), ST("by"), ST("asc"), ST("desc") |
438 ST("where"), ST("anywhere"), ST("like"), ST("unlike"), ST("and"), |
|
439 ST("or"), ST("not"), ST("xor"), ST("with"), ST("infinity"), |
|
440 ST("order"), ST("by"), ST("asc"), ST("desc") |
439 }; |
441 }; |
440 for (int i = 0 ; i < sizeof(keywords)/sizeof(sstr_t) ; i++) { |
442 for (int i = 0 ; i < sizeof(keywords)/sizeof(sstr_t) ; i++) { |
441 if (!sstrcasecmp(token->value, keywords[i])) { |
443 if (!sstrcasecmp(token->value, keywords[i])) { |
442 return 1; |
444 return 1; |
443 } |
445 } |
1065 |
1067 |
1066 static int dav_parse_bool_prim(DavQLStatement *stmt, UcxList *token, |
1068 static int dav_parse_bool_prim(DavQLStatement *stmt, UcxList *token, |
1067 DavQLExpression *expr) { |
1069 DavQLExpression *expr) { |
1068 |
1070 |
1069 expr->type = DAVQL_LOGICAL; |
1071 expr->type = DAVQL_LOGICAL; |
|
1072 expr->srctext = token_sstr(token); |
1070 |
1073 |
1071 int total_consumed = 0; |
1074 int total_consumed = 0; |
1072 |
1075 |
1073 DavQLExpression bexpr; |
1076 DavQLExpression bexpr; |
1074 memset(&bexpr, 0, sizeof(DavQLExpression)); |
1077 memset(&bexpr, 0, sizeof(DavQLExpression)); |
1091 dqlsec_malloc(stmt, expr->left, DavQLExpression); |
1094 dqlsec_malloc(stmt, expr->left, DavQLExpression); |
1092 memcpy(expr->left, &bexpr, sizeof(DavQLExpression)); |
1095 memcpy(expr->left, &bexpr, sizeof(DavQLExpression)); |
1093 dqlsec_mallocz(stmt, expr->right, DavQLExpression); |
1096 dqlsec_mallocz(stmt, expr->right, DavQLExpression); |
1094 expr->right->type = DAVQL_STRING; |
1097 expr->right->type = DAVQL_STRING; |
1095 expr->right->srctext = token_sstr(token); |
1098 expr->right->srctext = token_sstr(token); |
|
1099 expr->srctext.length = expr->right->srctext.ptr - |
|
1100 expr->srctext.ptr + expr->right->srctext.length; |
1096 |
1101 |
1097 return total_consumed + 1; |
1102 return total_consumed + 1; |
1098 } else { |
1103 } else { |
1099 dav_error_in_context(DAVQL_ERROR_INVALID_STRING, |
1104 dav_error_in_context(DAVQL_ERROR_INVALID_STRING, |
1100 _error_invalid_string, stmt, token); |
1105 _error_invalid_string, stmt, token); |
1147 total_consumed += consumed; |
1152 total_consumed += consumed; |
1148 dqlsec_malloc(stmt, expr->left, DavQLExpression); |
1153 dqlsec_malloc(stmt, expr->left, DavQLExpression); |
1149 memcpy(expr->left, &bexpr, sizeof(DavQLExpression)); |
1154 memcpy(expr->left, &bexpr, sizeof(DavQLExpression)); |
1150 dqlsec_malloc(stmt, expr->right, DavQLExpression); |
1155 dqlsec_malloc(stmt, expr->right, DavQLExpression); |
1151 memcpy(expr->right, &rexpr, sizeof(DavQLExpression)); |
1156 memcpy(expr->right, &rexpr, sizeof(DavQLExpression)); |
|
1157 |
|
1158 expr->srctext.length = expr->right->srctext.ptr - |
|
1159 expr->srctext.ptr + expr->right->srctext.length; |
1152 |
1160 |
1153 return total_consumed; |
1161 return total_consumed; |
1154 } |
1162 } |
1155 // RULE: FunctionCall | Identifier; |
1163 // RULE: FunctionCall | Identifier; |
1156 else if (bexpr.type == DAVQL_FUNCCALL || bexpr.type == DAVQL_IDENTIFIER) { |
1164 else if (bexpr.type == DAVQL_FUNCCALL || bexpr.type == DAVQL_IDENTIFIER) { |