 
#         return 1, otherwise return 0

sub match_pair_operations {

  my($rule) = $_[0];
  my($ret, $key, $oper);
  my(%subst, @context2, @action2);

  $ret = 0;   # shows if matches were found

  foreach $key (keys %{$rule->{"Operations"}}) {

    # since operations might be cancelled by other operations in this loop,
    # check if operation with the given key still exists

    if (!exists($rule->{"Operations"}->{$key}))  { next; }
    $oper = $rule->{"Operations"}->{$key};

    # check if the rule context expression must be evaluated before
    # comparing input line(s) with the pattern

    if (exists($rule->{"ContPreEval2"}) &&
        !tval_context_expr($oper->{"Context2"}))  { next; }  

    # check if last N lines of input buffer match the pattern specified
    # by operation; if the pattern returned any values, assign them to %subst,
    # otherwise leave %subst empty

    if ($matchfunc[$rule->{"PatType2"}]->($rule->{"PatLines2"}, 
                                          $oper->{"Pattern2"},
                                          \%subst, $rule->{"VarMap2"})) {

      # evaluate the context expression of the rule

      if (scalar(@{$oper->{"Context2"}}) && 
          !exists($rule->{"ContPreEval2"})) {

        if (scalar(%subst) && exists($rule->{"ContVolat2"})) { 
          copy_context($oper->{"Context2"}, \@context2); 
          subst_context(\%subst, \@context2, '$'); 
          if (!tval_context_expr(\@context2))  { next; }  
        } else { 
          if (!tval_context_expr($oper->{"Context2"}))  { next; }  
        }
      }

      # if the op