Try to parse a comparison operator. Returns heap-allocated op string or NULL. */
| 981 | |
| 982 | /* Try to parse a comparison operator. Returns heap-allocated op string or NULL. */ |
| 983 | static char *parse_comparison_op(parser_t *p) { |
| 984 | if (match(p, TOK_EQ)) { |
| 985 | return heap_strdup("="); |
| 986 | } |
| 987 | if (match(p, TOK_NEQ)) { |
| 988 | return heap_strdup("<>"); |
| 989 | } |
| 990 | if (match(p, TOK_EQTILDE)) { |
| 991 | return heap_strdup("=~"); |
| 992 | } |
| 993 | if (match(p, TOK_GTE)) { |
| 994 | return heap_strdup(">="); |
| 995 | } |
| 996 | if (match(p, TOK_LTE)) { |
| 997 | return heap_strdup("<="); |
| 998 | } |
| 999 | if (match(p, TOK_GT)) { |
| 1000 | return heap_strdup(">"); |
| 1001 | } |
| 1002 | if (match(p, TOK_LT)) { |
| 1003 | return heap_strdup("<"); |
| 1004 | } |
| 1005 | if (check(p, TOK_CONTAINS)) { |
| 1006 | advance(p); |
| 1007 | return heap_strdup("CONTAINS"); |
| 1008 | } |
| 1009 | if (check(p, TOK_STARTS)) { |
| 1010 | advance(p); |
| 1011 | expect(p, TOK_WITH); |
| 1012 | return heap_strdup("STARTS WITH"); |
| 1013 | } |
| 1014 | if (check(p, TOK_ENDS)) { |
| 1015 | advance(p); |
| 1016 | expect(p, TOK_WITH); |
| 1017 | return heap_strdup("ENDS WITH"); |
| 1018 | } |
| 1019 | return NULL; |
| 1020 | } |
| 1021 | |
| 1022 | /* Parse a single condition: var.prop OP value | var.prop IS [NOT] NULL | var.prop IN [...] */ |
| 1023 | /* Free the heap fields of a standalone node pattern (not owned by a pattern). */ |
no test coverage detected