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