home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gnurx.zip / rx / rxspencer.c < prev    next >
C/C++ Source or Header  |  1995-12-31  |  19KB  |  837 lines

  1. /***********************************************************
  2.  
  3. Copyright 1995 by Tom Lord
  4.  
  5.                         All Rights Reserved
  6.  
  7. Permission to use, copy, modify, and distribute this software and its 
  8. documentation for any purpose and without fee is hereby granted, 
  9. provided that the above copyright notice appear in all copies and that
  10. both that copyright notice and this permission notice appear in 
  11. supporting documentation, and that the name of the copyright holder not be
  12. used in advertising or publicity pertaining to distribution of the
  13. software without specific, written prior permission.  
  14.  
  15. Tom Lord DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  16. INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  17. EVENT SHALL TOM LORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  18. CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  19. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  20. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  21. PERFORMANCE OF THIS SOFTWARE.
  22.  
  23. ******************************************************************/
  24.  
  25.  
  26.  
  27. #include "rxall.h"
  28. #include "rxspencer.h"
  29.  
  30.  
  31.  
  32. static int rx_ms = 0;
  33. static int rx_fs = 0;
  34.  
  35. static char * silly_hack_2 = 0;
  36.  
  37. #ifdef __STDC__
  38. struct rx_solutions *
  39. rx_make_solutions (struct rx_registers * regs,
  40.            struct rx_unfaniverse * verse,
  41.            struct rexp_node * expression,
  42.            struct rexp_node ** subexps,
  43.            int cset_size,
  44.            int start, int end,
  45.            rx_vmfn vmfn, rx_contextfn contextfn,
  46.            void * closure)
  47. #else
  48. struct rx_solutions *
  49. rx_make_solutions (regs, verse, expression, subexps, cset_size, 
  50.            start, end, vmfn, contextfn, closure)
  51.      struct rx_registers * regs;
  52.      struct rx_unfaniverse * verse;
  53.      struct rexp_node * expression;
  54.      struct rexp_node ** subexps;
  55.      int cset_size;
  56.      int start;
  57.      int end;
  58.      rx_vmfn vmfn;
  59.      rx_contextfn contextfn;
  60.      void * closure;
  61. #endif
  62. {
  63.   struct rx_solutions * solns;
  64.   unsigned char * burst;
  65.   int len;
  66.   int offset;
  67.  
  68.   ++rx_ms;
  69.   if (silly_hack_2)
  70.     {
  71.       solns = (struct rx_solutions *)silly_hack_2;
  72.       silly_hack_2 = 0;
  73.     }
  74.   else
  75.     solns = (struct rx_solutions *)malloc (sizeof (*solns));
  76.   if (!solns)
  77.     return 0;
  78.   bzero (solns, sizeof (*solns));
  79.  
  80.   solns->step = 0;
  81.   solns->cset_size = cset_size;
  82.   solns->subexps = subexps;
  83.   solns->exp = expression;
  84.   rx_save_rexp (expression);
  85.   solns->verse = verse;
  86.   solns->regs = regs;
  87.   solns->start = start;
  88.   solns->end = end;
  89.   solns->vmfn = vmfn;
  90.   solns->contextfn = contextfn;
  91.   solns->closure = closure;
  92.   solns->current_pos = start;
  93.   solns->interval_x = 0;
  94.  
  95.   if (!solns->exp->observed)
  96.     {
  97.       solns->dfa = rx_unfa (verse, expression, cset_size);
  98.       if (!solns->dfa)
  99.     goto err_return;
  100.       rx_init_system (&solns->match_engine, solns->dfa->nfa);
  101.  
  102.       {
  103.     struct rx * rx;
  104.     rx = solns->match_engine.rx;
  105. #if 0
  106.     if (   rx->start_set
  107.         && (rx->start_set->starts_for == rx)
  108.         && (rx->start_set->id == rx->rx_id)
  109.         && rx->start_set->superstate
  110.         && (rx->start_set->superstate->rx_id == rx->rx_id))
  111.       {
  112.         solns->match_engine.state = solns->match_engine.rx->start_set->superstate;
  113.         rx_lock_superstate (solns->match_engine.rx, solns->match_engine.state);
  114.       }
  115.     else
  116.       ;
  117. #endif
  118.     if (rx_yes != rx_start_superstate (&solns->match_engine))
  119.       goto err_return;
  120.       }
  121.     }
  122.   else
  123.     {
  124.       struct rexp_node * simplified;
  125.       int status;
  126.       status = rx_simple_rexp (&simplified, cset_size, solns->exp, subexps);
  127.       if (status)
  128.     goto err_return;
  129.       solns->dfa = rx_unfa (verse, simplified, cset_size);
  130.       if (!solns->dfa)
  131.     {
  132.       rx_free_rexp (simplified);
  133.       goto err_return;
  134.     }
  135.       rx_init_system (&solns->match_engine, solns->dfa->nfa);
  136.       if (rx_yes != rx_start_superstate (&solns->match_engine))
  137.     goto err_return;
  138.       rx_free_rexp (simplified);
  139.     }
  140.   return solns;
  141.  
  142.  err_return:
  143.   rx_free_rexp (solns->exp);
  144.   free (solns);
  145.   return 0;
  146. }
  147.  
  148.  
  149.  
  150. #ifdef __STDC__
  151. void
  152. rx_free_solutions (struct rx_solutions * solns)
  153. #else
  154. void
  155. rx_free_solutions (solns)
  156.      struct rx_solutions * solns;
  157. #endif
  158. {
  159.   if (!solns)
  160.     return;
  161.  
  162.   ++rx_fs;
  163.   if (solns->left)
  164.     {
  165.       rx_free_solutions (solns->left);
  166.       solns->left = 0;
  167.     }
  168.  
  169.   if (solns->right)
  170.     {
  171.       rx_free_solutions (solns->right);
  172.       solns->right = 0;
  173.     }
  174.  
  175.   if (solns->dfa)
  176.     {
  177.       rx_free_unfa (solns->dfa);
  178.       solns->dfa = 0;
  179.     }
  180.  
  181.   rx_terminate_system (&solns->match_engine);
  182.  
  183.   if (solns->exp)
  184.     {
  185.       rx_free_rexp (solns->exp);
  186.       solns->exp = 0;
  187.     }
  188.  
  189.   if (!silly_hack_2)
  190.     silly_hack_2 = (char *)solns;
  191.   else
  192.     free (solns);
  193. }
  194.  
  195.  
  196. /* This doesn't deal with resumable rx_maybe right. */
  197. enum rx_answers
  198. rx_soluntion_fit_p (solns)
  199.      struct rx_solutions * solns;
  200. {
  201.   unsigned char * burst;
  202.   int burst_addr;
  203.   int burst_len;
  204.   int burst_end_addr;
  205.   int rel_pos_in_burst;
  206.   enum rx_answers vmstat;
  207.       
  208.   
  209.  next_burst:
  210.   vmstat = solns->vmfn (solns->closure,
  211.             &burst, &burst_len, &burst_addr,
  212.             solns->current_pos, solns->end,
  213.             solns->current_pos);
  214.  
  215.   if (vmstat != rx_yes)
  216.     return vmstat;
  217.  
  218.   rel_pos_in_burst = solns->current_pos - burst_addr;
  219.   burst_end_addr = burst_addr + burst_len;
  220.  
  221.   if (burst_end_addr >= solns->end)
  222.     {
  223.       enum rx_answers fit_status;
  224.       fit_status = rx_fit_p (&solns->match_engine,
  225.                  burst + rel_pos_in_burst,
  226.                  solns->end - solns->current_pos);
  227.       return fit_status;
  228.     }
  229.   else
  230.     {
  231.       enum rx_answers fit_status;
  232.       fit_status = rx_advance (&solns->match_engine,
  233.                    burst + rel_pos_in_burst,
  234.                    burst_len - rel_pos_in_burst);
  235.       if (fit_status != rx_yes)
  236.     {
  237.       return fit_status;
  238.     }
  239.       else
  240.     {
  241.       solns->current_pos += burst_len - rel_pos_in_burst;
  242.       goto next_burst;
  243.     }
  244.     }
  245. }
  246.  
  247. #ifdef __STDC__
  248. enum rx_answers
  249. rx_next_solution (struct rx_solutions * solns)
  250. #else
  251. enum rx_answers
  252. rx_next_solution (solns)
  253.      struct rx_solutions * solns;
  254. #endif
  255. {
  256.   if (!solns)
  257.     return rx_bogus;
  258.  
  259.   if (!solns->exp)
  260.     {
  261.       if (solns->step != 0)
  262.     return rx_no;
  263.       else
  264.     {
  265.       solns->step = 1;
  266.       return (solns->start == solns->end
  267.           ? rx_yes
  268.           : rx_no);
  269.     }
  270.     }
  271.   else if (   (solns->exp->len >= 0)
  272.        && (solns->exp->len != (solns->end - solns->start)))
  273.     {
  274.       return rx_no;
  275.     }
  276.   else if (!solns->exp->observed)
  277.     {
  278.       if (solns->step != 0)
  279.     return rx_no;
  280.       else
  281.     {
  282.       enum rx_answers ans;
  283.       ans = rx_soluntion_fit_p (solns);
  284.       solns->step = -1;
  285.       return ans;
  286.     }
  287.     }
  288.   else if (solns->exp->observed)
  289.     {
  290.       enum rx_answers fit_p;
  291.       switch (solns->step)
  292.     {
  293.     case -1:
  294.       return rx_no;
  295.     case 0:
  296.       fit_p = rx_soluntion_fit_p (solns);
  297.       switch (fit_p)
  298.         {
  299.         case rx_no:
  300.         case rx_maybe:
  301.           solns->step = -1;
  302.           return rx_no;
  303.         case rx_yes:
  304.           solns->step = 1;
  305.           goto resolve_fit;
  306.         case rx_bogus:
  307.         default:
  308.           solns->step = -1;
  309.           return fit_p;
  310.         }
  311.  
  312.     default:
  313.     resolve_fit:
  314.       switch (solns->exp->type)
  315.         {
  316.         case r_cset:
  317.           solns->step = -1;
  318.           return rx_bogus;
  319.           
  320.         case r_parens:
  321.           {
  322.         enum rx_answers paren_stat;
  323.         switch (solns->step)
  324.           {
  325.           case 1:
  326.  
  327.             if (   !solns->exp->params.pair.left
  328.             || !solns->exp->params.pair.left->observed)
  329.               {
  330.             solns->regs[solns->exp->params.intval].rm_so = solns->start;
  331.             solns->regs[solns->exp->params.intval].rm_eo = solns->end;
  332.             solns->step = -1;
  333.             return rx_yes;
  334.               }
  335.             else
  336.               {
  337.             solns->left = rx_make_solutions (solns->regs,
  338.                              solns->verse,
  339.                              solns->exp->params.pair.left,
  340.                              solns->subexps,
  341.                              solns->cset_size,
  342.                              solns->start,
  343.                              solns->end,
  344.                              solns->vmfn,
  345.                              solns->contextfn,
  346.                              solns->closure);
  347.             if (!solns->left)
  348.               {
  349.                 solns->step = -1;
  350.                 return rx_bogus;
  351.               }
  352.               }
  353.             solns->step = 2;
  354.             /* fall through */
  355.  
  356.           case 2:
  357.             solns->regs[solns->exp->params.intval].rm_so = -1;
  358.             solns->regs[solns->exp->params.intval].rm_eo = -1;
  359.  
  360.             paren_stat = rx_next_solution (solns->left);
  361.  
  362.             if (paren_stat == rx_yes)
  363.               {
  364.             solns->regs[solns->exp->params.intval].rm_so = solns->start;
  365.             solns->regs[solns->exp->params.intval].rm_eo = solns->end;
  366.             return rx_yes;
  367.               }
  368.             else if (paren_stat != rx_maybe)
  369.               {
  370.             solns->step = -1;
  371.             rx_free_solutions (solns->left);
  372.             solns->left = 0;
  373.             return paren_stat;
  374.               }
  375.             else /* paren_stat == rx_maybe */
  376.               return paren_stat;
  377.           }
  378.           }
  379.  
  380.  
  381.         case r_opt:
  382.           {
  383.         enum rx_answers opt_stat;
  384.         switch (solns->step)
  385.           {
  386.           case 1:
  387.             solns->left = rx_make_solutions (solns->regs,
  388.                              solns->verse,
  389.                              solns->exp->params.pair.left,
  390.                              solns->subexps,
  391.                              solns->cset_size,
  392.                              solns->start,
  393.                              solns->end,
  394.                              solns->vmfn,
  395.                              solns->contextfn,    
  396.                              solns->closure);
  397.             if (!solns->left)
  398.               {
  399.             solns->step = -1;
  400.             return rx_bogus;
  401.               }
  402.             solns->step = 2;
  403.             /* fall through */
  404.             
  405.           case 2:
  406.             opt_stat = rx_next_solution (solns->left);
  407.  
  408.             if (opt_stat == rx_yes)
  409.               return rx_yes;
  410.             else if (opt_stat != rx_maybe)
  411.               {
  412.             solns->step = -1;
  413.             rx_free_solutions (solns->left);
  414.             solns->left = 0;
  415.             return ((solns->start == solns->end)
  416.                 ? rx_yes
  417.                 : rx_no);
  418.               }
  419.             else /* opt_stat == rx_maybe */
  420.               return opt_stat;
  421.  
  422.           }
  423.          }
  424.  
  425.         case r_alternate:
  426.           {
  427.         enum rx_answers alt_stat;
  428.         switch (solns->step)
  429.           {
  430.           case 1:
  431.             solns->left = rx_make_solutions (solns->regs,
  432.                              solns->verse,
  433.                              solns->exp->params.pair.left,
  434.                              solns->subexps,
  435.                              solns->cset_size,
  436.                              solns->start,
  437.                              solns->end,
  438.                              solns->vmfn,
  439.                              solns->contextfn,
  440.                              solns->closure);
  441.             if (!solns->left)
  442.               {
  443.             solns->step = -1;
  444.             return rx_bogus;
  445.               }
  446.             solns->step = 2;
  447.             /* fall through */
  448.             
  449.           case 2:
  450.             alt_stat = rx_next_solution (solns->left);
  451.  
  452.             if (   (alt_stat == rx_yes)
  453.             || (alt_stat == rx_maybe))
  454.               return alt_stat;
  455.             else 
  456.               {
  457.             solns->step = 3;
  458.             rx_free_solutions (solns->left);
  459.             solns->left = 0;
  460.             /* fall through */
  461.               }
  462.  
  463.           case 3:
  464.             solns->right = rx_make_solutions (solns->regs,
  465.                               solns->verse,
  466.                               solns->exp->params.pair.right,
  467.                               solns->subexps,
  468.                               solns->cset_size,
  469.                               solns->start,
  470.                               solns->end,
  471.                               solns->vmfn,
  472.                               solns->contextfn,
  473.                               solns->closure);
  474.             if (!solns->right)
  475.               {
  476.             solns->step = -1;
  477.             return rx_bogus;
  478.               }
  479.             solns->step = 4;
  480.             /* fall through */
  481.             
  482.           case 4:
  483.             alt_stat = rx_next_solution (solns->right);
  484.  
  485.             if (   (alt_stat == rx_yes)
  486.             || (alt_stat == rx_maybe))
  487.               return alt_stat;
  488.             else 
  489.               {
  490.             solns->step = -1;
  491.             rx_free_solutions (solns->right);
  492.             solns->right = 0;
  493.             return alt_stat;
  494.               }
  495.           }
  496.          }
  497.  
  498.         case r_concat:
  499.           {
  500.         switch (solns->step)
  501.           {
  502.             enum rx_answers concat_stat;
  503.           case 1:
  504.             solns->split_guess = solns->end;
  505.  
  506.           concat_split_guess_loop:
  507.             solns->left = rx_make_solutions (solns->regs,
  508.                              solns->verse,
  509.                              solns->exp->params.pair.left,
  510.                              solns->subexps,
  511.                              solns->cset_size,
  512.                              solns->start,
  513.                              solns->split_guess,
  514.                              solns->vmfn,
  515.                              solns->contextfn,
  516.                              solns->closure);
  517.             if (!solns->left)
  518.               {
  519.             solns->step = -1;
  520.             return rx_bogus;
  521.               }
  522.             solns->step = 2;
  523.  
  524.           case 2:
  525.           concat_try_next_left_match:
  526.  
  527.             concat_stat = rx_next_solution (solns->left);
  528.             if (concat_stat == rx_maybe)
  529.               return concat_stat;
  530.             else if (concat_stat != rx_yes)
  531.               {
  532.             rx_free_solutions (solns->left);
  533.             rx_free_solutions (solns->right);
  534.             solns->left = solns->right = 0;
  535.             solns->split_guess -= 1;
  536.             if (solns->split_guess >= solns->start)
  537.               goto concat_split_guess_loop;
  538.             else
  539.               {
  540.                 solns->step = -1;
  541.                 return concat_stat;
  542.               }
  543.               }
  544.             else
  545.               {
  546.             solns->step = 3;
  547.             /* fall through */
  548.               }
  549.  
  550.           case 3:
  551.             solns->right = rx_make_solutions (solns->regs,
  552.                               solns->verse,
  553.                               solns->exp->params.pair.right,
  554.                               solns->subexps,
  555.                               solns->cset_size,
  556.                               solns->split_guess,
  557.                               solns->end,
  558.                               solns->vmfn,
  559.                               solns->contextfn,
  560.                               solns->closure);
  561.             if (!solns->right)
  562.               {
  563.             rx_free_solutions (solns->left);
  564.             solns->left = 0;
  565.             solns->step = -1;
  566.             return rx_bogus;
  567.               }
  568.  
  569.             solns->step = 4;
  570.             /* fall through */
  571.  
  572.           case 4:
  573.           concat_try_next_right_match:
  574.  
  575.             concat_stat = rx_next_solution (solns->right);
  576.             if ((concat_stat == rx_maybe) || (concat_stat == rx_yes))
  577.               return concat_stat;
  578.             else if (concat_stat == rx_no)
  579.               {
  580.             rx_free_solutions (solns->right);
  581.             solns->right = 0;
  582.             solns->step = 2;
  583.             goto concat_try_next_left_match;
  584.               }
  585.             else /*  concat_stat == rx_bogus */
  586.               {
  587.             rx_free_solutions (solns->left);
  588.             solns->left = 0;
  589.             rx_free_solutions (solns->right);
  590.             solns->right = 0;
  591.             solns->step = -1;
  592.             return concat_stat;
  593.               }
  594.           }
  595.           }
  596.  
  597.  
  598.         case r_plus:
  599.         case r_star:
  600.           {
  601.         switch (solns->step)
  602.           {
  603.             enum rx_answers star_stat;
  604.           case 1:
  605.             solns->split_guess = solns->end;
  606.  
  607.           star_split_guess_loop:
  608.             solns->left = rx_make_solutions (solns->regs,
  609.                              solns->verse,
  610.                              solns->exp->params.pair.left,
  611.                              solns->subexps,
  612.                              solns->cset_size,
  613.                              solns->start,
  614.                              solns->split_guess,
  615.                              solns->vmfn,
  616.                              solns->contextfn,
  617.                              solns->closure);
  618.             if (!solns->left)
  619.               {
  620.             solns->step = -1;
  621.             return rx_bogus;
  622.               }
  623.             solns->step = 2;
  624.  
  625.           case 2:
  626.           star_try_next_left_match:
  627.  
  628.             star_stat = rx_next_solution (solns->left);
  629.             if (star_stat == rx_maybe)
  630.               return star_stat;
  631.             else if (star_stat != rx_yes)
  632.               {
  633.             rx_free_solutions (solns->left);
  634.             rx_free_solutions (solns->right);
  635.             solns->left = solns->right = 0;
  636.             solns->split_guess -= 1;
  637.             if (solns->split_guess >= solns->start)
  638.               goto star_split_guess_loop;
  639.             else
  640.               {
  641.                 solns->step = -1;
  642.  
  643.                 if (   (solns->exp->type == r_star)
  644.                 && (solns->split_guess == solns->end))
  645.                   return rx_yes;
  646.                 else
  647.                   return star_stat;
  648.               }
  649.               }
  650.             else
  651.               {
  652.             solns->step = 3;
  653.             /* fall through */
  654.               }
  655.  
  656.  
  657.             if (solns->split_guess == solns->end)
  658.               return rx_yes;
  659.             
  660.           case 3:
  661.             solns->right = rx_make_solutions (solns->regs,
  662.                               solns->verse,
  663.                               solns->exp,
  664.                               solns->subexps,
  665.                               solns->cset_size,
  666.                               solns->split_guess,
  667.                               solns->end,
  668.                               solns->vmfn,
  669.                               solns->contextfn,
  670.                               solns->closure);
  671.             if (!solns->right)
  672.               {
  673.             rx_free_solutions (solns->left);
  674.             solns->left = 0;
  675.             solns->step = -1;
  676.             return rx_bogus;
  677.               }
  678.  
  679.             solns->step = 4;
  680.             /* fall through */
  681.  
  682.           case 4:
  683.           star_try_next_right_match:
  684.             
  685.             star_stat = rx_next_solution (solns->right);
  686.             if ((star_stat == rx_maybe) || (star_stat == rx_yes))
  687.               return star_stat;
  688.             else if (star_stat == rx_no)
  689.               {
  690.             rx_free_solutions (solns->right);
  691.             solns->right = 0;
  692.             solns->step = 2;
  693.             goto star_try_next_left_match;
  694.               }
  695.             else /*  star_stat == rx_bogus */
  696.               {
  697.             rx_free_solutions (solns->left);
  698.             solns->left = 0;
  699.             rx_free_solutions (solns->right);
  700.             solns->right = 0;
  701.             solns->step = -1;
  702.             return star_stat;
  703.               }
  704.           }
  705.           }
  706.  
  707.  
  708.         case r_context:
  709.           {
  710.         solns->step = -1;
  711.         return solns->contextfn (solns->closure,
  712.                      solns->exp->params.intval,
  713.                      solns->start, solns->end,
  714.                      solns->regs);
  715.           }
  716.  
  717.         case r_interval:
  718.           {
  719.         switch (solns->step)
  720.           {
  721.             enum rx_answers interval_stat;
  722.  
  723.           case 1:
  724.             if (solns->interval_x >= solns->exp->params.intval2)
  725.               {
  726.             solns->step = -1;
  727.             return rx_no;
  728.               }
  729.             
  730.             solns->split_guess = solns->end;
  731.             
  732.           interval_split_guess_loop:
  733.             solns->left = rx_make_solutions (solns->regs,
  734.                              solns->verse,
  735.                              solns->exp->params.pair.left,
  736.                              solns->subexps,
  737.                              solns->cset_size,
  738.                              solns->start,
  739.                              solns->split_guess,
  740.                              solns->vmfn,
  741.                              solns->contextfn,
  742.                              solns->closure);
  743.             if (!solns->left)
  744.               {
  745.             solns->step = -1;
  746.             return rx_bogus;
  747.               }
  748.             solns->step = 2;
  749.  
  750.           case 2:
  751.           interval_try_next_left_match:
  752.  
  753.             interval_stat = rx_next_solution (solns->left);
  754.             if (interval_stat == rx_maybe)
  755.               return interval_stat;
  756.             else if (interval_stat != rx_yes)
  757.               {
  758.             rx_free_solutions (solns->left);
  759.             rx_free_solutions (solns->right);
  760.             solns->left = solns->right = 0;
  761.             solns->split_guess -= 1;
  762.             if (solns->split_guess >= solns->start)
  763.               goto interval_split_guess_loop;
  764.             else
  765.               {
  766.                 solns->step = -1;
  767.                 return ((   (interval_stat == rx_no)
  768.                      && (   solns->interval_x
  769.                      == (solns->exp->params.intval2)))
  770.                     ? rx_yes
  771.                     : rx_no);
  772.               }
  773.               }
  774.             else
  775.               {
  776.             solns->step = 3;
  777.             /* fall through */
  778.               }
  779.  
  780.  
  781.             if (   (solns->split_guess == solns->end)
  782.             && (solns->interval_x >= (solns->exp->params.intval - 1)))
  783.               return rx_yes;
  784.             
  785.           case 3:
  786.             solns->right = rx_make_solutions (solns->regs,
  787.                               solns->verse,
  788.                               solns->exp,
  789.                               solns->subexps,
  790.                               solns->cset_size,
  791.                               solns->split_guess,
  792.                               solns->end,
  793.                               solns->vmfn,
  794.                               solns->contextfn,
  795.                               solns->closure);
  796.             solns->right->interval_x = solns->interval_x + 1;
  797.             if (!solns->right)
  798.               {
  799.             rx_free_solutions (solns->left);
  800.             solns->left = 0;
  801.             solns->step = -1;
  802.             return rx_bogus;
  803.               }
  804.  
  805.             solns->step = 4;
  806.             /* fall through */
  807.  
  808.           case 4:
  809.           interval_try_next_right_match:
  810.             
  811.             interval_stat = rx_next_solution (solns->right);
  812.             if ((interval_stat == rx_maybe) || (interval_stat == rx_yes))
  813.               return interval_stat;
  814.             else if (interval_stat == rx_no)
  815.               {
  816.             rx_free_solutions (solns->right);
  817.             solns->right = 0;
  818.             solns->step = 2;
  819.             goto interval_try_next_left_match;
  820.               }
  821.             else /*  interval_stat == rx_bogus */
  822.               {
  823.             rx_free_solutions (solns->left);
  824.             solns->left = 0;
  825.             rx_free_solutions (solns->right);
  826.             solns->right = 0;
  827.             solns->step = -1;
  828.             return interval_stat;
  829.               }
  830.           }
  831.           }
  832.         }
  833.     }
  834.       return rx_bogus;
  835.     }
  836. }
  837.