| 603 | |
| 604 | static struct grep_expr *compile_pattern_or(struct grep_pat **); |
| 605 | static struct grep_expr *compile_pattern_atom(struct grep_pat **list) |
| 606 | { |
| 607 | struct grep_pat *p; |
| 608 | struct grep_expr *x; |
| 609 | |
| 610 | p = *list; |
| 611 | if (!p) |
| 612 | return NULL; |
| 613 | switch (p->token) { |
| 614 | case GREP_PATTERN: /* atom */ |
| 615 | case GREP_PATTERN_HEAD: |
| 616 | case GREP_PATTERN_BODY: |
| 617 | CALLOC_ARRAY(x, 1); |
| 618 | x->node = GREP_NODE_ATOM; |
| 619 | x->u.atom = p; |
| 620 | *list = p->next; |
| 621 | return x; |
| 622 | case GREP_OPEN_PAREN: |
| 623 | *list = p->next; |
| 624 | x = compile_pattern_or(list); |
| 625 | if (!*list || (*list)->token != GREP_CLOSE_PAREN) |
| 626 | die("unmatched ( for expression group"); |
| 627 | *list = (*list)->next; |
| 628 | return x; |
| 629 | default: |
| 630 | return NULL; |
| 631 | } |
| 632 | } |
| 633 | |
| 634 | static struct grep_expr *compile_pattern_not(struct grep_pat **list) |
| 635 | { |
no test coverage detected