Try to parse a comparison operator. Returns heap-allocated op string or NULL. */
| 907 | |
| 908 | /* Try to parse a comparison operator. Returns heap-allocated op string or NULL. */ |
| 909 | static char *parse_comparison_op(parser_t *p) { |
| 910 | if (match(p, TOK_EQ)) { |
| 911 | return heap_strdup("="); |
| 912 | } |
| 913 | if (match(p, TOK_NEQ)) { |
| 914 | return heap_strdup("<>"); |
| 915 | } |
| 916 | if (match(p, TOK_EQTILDE)) { |
| 917 | return heap_strdup("=~"); |
| 918 | } |
| 919 | if (match(p, TOK_GTE)) { |
| 920 | return heap_strdup(">="); |
| 921 | } |
| 922 | if (match(p, TOK_LTE)) { |
| 923 | return heap_strdup("<="); |
| 924 | } |
| 925 | if (match(p, TOK_GT)) { |
| 926 | return heap_strdup(">"); |
| 927 | } |
| 928 | if (match(p, TOK_LT)) { |
| 929 | return heap_strdup("<"); |
| 930 | } |
| 931 | if (check(p, TOK_CONTAINS)) { |
| 932 | advance(p); |
| 933 | return heap_strdup("CONTAINS"); |
| 934 | } |
| 935 | if (check(p, TOK_STARTS)) { |
| 936 | advance(p); |
| 937 | expect(p, TOK_WITH); |
| 938 | return heap_strdup("STARTS WITH"); |
| 939 | } |
| 940 | if (check(p, TOK_ENDS)) { |
| 941 | advance(p); |
| 942 | expect(p, TOK_WITH); |
| 943 | return heap_strdup("ENDS WITH"); |
| 944 | } |
| 945 | return NULL; |
| 946 | } |
| 947 | |
| 948 | /* Parse a single condition: var.prop OP value | var.prop IS [NOT] NULL | var.prop IN [...] */ |
| 949 | /* Free the heap fields of a standalone node pattern (not owned by a pattern). */ |
no test coverage detected