| 706 | // |
| 707 | |
| 708 | gpre_rse* EXP_rse(gpre_req* request, gpre_sym* initial_symbol) |
| 709 | { |
| 710 | // parse FIRST n clause, if present |
| 711 | |
| 712 | gpre_nod* first = NULL; |
| 713 | if (MSC_match(KW_FIRST)) |
| 714 | { |
| 715 | if (!global_count_field) |
| 716 | global_count_field = MET_make_field("jrd_count", dtype_long, 4, false); |
| 717 | first = par_value(request, global_count_field); |
| 718 | } |
| 719 | |
| 720 | // parse first context clause |
| 721 | |
| 722 | if (initial_symbol && gpreGlob.sw_language == lang_ada && !check_relation()) |
| 723 | return NULL; |
| 724 | |
| 725 | gpre_ctx* context = EXP_context(request, initial_symbol); |
| 726 | SSHORT count = 1; |
| 727 | |
| 728 | // parse subsequent context clauses if this is a join |
| 729 | gpre_nod* boolean = NULL; |
| 730 | while (MSC_match(KW_CROSS)) |
| 731 | { |
| 732 | context = EXP_context(request, 0); |
| 733 | count++; |
| 734 | if (MSC_match(KW_OVER)) |
| 735 | boolean = make_and(boolean, par_over(context)); |
| 736 | } |
| 737 | |
| 738 | // bug_3380 - could have an "over" clause without a "cross" clause |
| 739 | if (MSC_match(KW_OVER)) |
| 740 | boolean = make_and(boolean, par_over(context)); |
| 741 | |
| 742 | // build rse node |
| 743 | |
| 744 | gpre_rse* rec_expr = (gpre_rse*) MSC_alloc(RSE_LEN(count)); |
| 745 | rec_expr->rse_count = count; |
| 746 | rec_expr->rse_first = first; |
| 747 | rec_expr->rse_boolean = boolean; |
| 748 | |
| 749 | while (count) |
| 750 | { |
| 751 | rec_expr->rse_context[--count] = context; |
| 752 | HSH_insert(context->ctx_symbol); |
| 753 | context = context->ctx_next; |
| 754 | } |
| 755 | |
| 756 | // parse boolean, if any. If there is an error, ignore the |
| 757 | // boolean, but keep the rse |
| 758 | |
| 759 | if (MSC_match(KW_WITH)) |
| 760 | boolean = make_and(boolean, par_boolean(request)); |
| 761 | |
| 762 | rec_expr->rse_boolean = boolean; |
| 763 | |
| 764 | // Parse SORT clause, if any. |
| 765 |
no test coverage detected