* xmlXPathCompPredicate: * @ctxt: the XPath Parser context * @filter: act as a filter * * [8] Predicate ::= '[' PredicateExpr ']' * [9] PredicateExpr ::= Expr * * Compile a predicate expression */
| 9959 | * Compile a predicate expression |
| 9960 | */ |
| 9961 | static void |
| 9962 | xmlXPathCompPredicate(xmlXPathParserContextPtr ctxt, int filter) { |
| 9963 | int op1 = ctxt->comp->last; |
| 9964 | |
| 9965 | SKIP_BLANKS; |
| 9966 | if (CUR != '[') { |
| 9967 | XP_ERROR(XPATH_INVALID_PREDICATE_ERROR); |
| 9968 | } |
| 9969 | NEXT; |
| 9970 | SKIP_BLANKS; |
| 9971 | |
| 9972 | ctxt->comp->last = -1; |
| 9973 | /* |
| 9974 | * This call to xmlXPathCompileExpr() will deactivate sorting |
| 9975 | * of the predicate result. |
| 9976 | * TODO: Sorting is still activated for filters, since I'm not |
| 9977 | * sure if needed. Normally sorting should not be needed, since |
| 9978 | * a filter can only diminish the number of items in a sequence, |
| 9979 | * but won't change its order; so if the initial sequence is sorted, |
| 9980 | * subsequent sorting is not needed. |
| 9981 | */ |
| 9982 | if (! filter) |
| 9983 | xmlXPathCompileExpr(ctxt, 0); |
| 9984 | else |
| 9985 | xmlXPathCompileExpr(ctxt, 1); |
| 9986 | CHECK_ERROR; |
| 9987 | |
| 9988 | if (CUR != ']') { |
| 9989 | XP_ERROR(XPATH_INVALID_PREDICATE_ERROR); |
| 9990 | } |
| 9991 | |
| 9992 | if (filter) |
| 9993 | PUSH_BINARY_EXPR(XPATH_OP_FILTER, op1, ctxt->comp->last, 0, 0); |
| 9994 | else |
| 9995 | PUSH_BINARY_EXPR(XPATH_OP_PREDICATE, op1, ctxt->comp->last, 0, 0); |
| 9996 | |
| 9997 | NEXT; |
| 9998 | SKIP_BLANKS; |
| 9999 | } |
| 10000 | |
| 10001 | /** |
| 10002 | * xmlXPathCompNodeTest: |
no test coverage detected