my $float_end = $pkg->operator('float_end');
my $float_end_re = qr/^\s*\Q$float_end\E/;
+ my $atom_re = qr/.+?(?=\Q$float_start\E|\Q$group_start\E|\Q$float_end\E|\Q$group_end\E|\s|"|$)/;
+
my $modifier_tag = $pkg->operator('modifier');
my $modifier_tag_re = qr/^\s*\Q$modifier_tag\E/;
}
if (/^\s*$/) { # end of an explicit group
- local $last_type = '';
+ $last_type = '';
last;
} elsif (/$float_end_re/) { # end of an explicit group
warn ' 'x$recursing."Encountered explicit float end, remainder: $'\n" if $self->debug;
$remainder = $';
$_ = '';
- local $last_type = '';
+ $last_type = '';
} elsif ($self->filter_count && /$filter_re/) { # found a filter
warn ' 'x$recursing."Encountered search filter: $1$2 set to $3\n" if $self->debug;
}
- local $last_type = '';
+ $last_type = '';
} elsif ($self->filter_count && /$filter_as_class_re/) { # found a filter
warn ' 'x$recursing."Encountered search filter: $1$2 set to $3\n" if $self->debug;
$struct->new_filter( $filter => $params, $negate );
}
- local $last_type = '';
+ $last_type = '';
} elsif ($self->modifier_count && /$modifier_re/) { # found a modifier
warn ' 'x$recursing."Encountered search modifier: $1\n" if $self->debug;
$struct->new_modifier($1);
}
- local $last_type = '';
+ $last_type = '';
} elsif ($self->modifier_count && /$modifier_as_class_re/) { # found a modifier
warn ' 'x$recursing."Encountered search modifier: $1\n" if $self->debug;
$struct->new_modifier($mod);
}
- local $last_type = '';
+ $last_type = '';
} elsif (/$float_start_re/) { # start of an explicit float
warn ' 'x$recursing."Encountered explicit float start\n" if $self->debug;
$floating = 1;
$_ = $subremainder;
warn ' 'x$recursing."Query remainder after bool group: $_\n" if $self->debug;
- local $last_type = '';
+ $last_type = '';
} elsif (/$and_re/) { # ANDed expression
$_ = $';
warn ' 'x$recursing."Encountered AND\n" if $self->debug;
do {warn ' 'x$recursing."!!! Already doing the bool dance for AND\n" if $self->debug; next} if ($last_type eq 'AND');
do {warn ' 'x$recursing."!!! Already doing the bool dance for OR\n" if $self->debug; next} if ($last_type eq 'OR');
- local $last_type = 'AND';
+ $last_type = 'AND';
warn ' 'x$recursing."Saving LHS, building RHS\n" if $self->debug;
my $LHS = $struct;
$self->parse_tree( $struct ) if ($self->parse_tree == $LHS);
- local $last_type = '';
+ $last_type = '';
} elsif (/$or_re/) { # ORed expression
$_ = $';
warn ' 'x$recursing."Encountered OR\n" if $self->debug;
do {warn ' 'x$recursing."!!! Already doing the bool dance for AND\n" if $self->debug; next} if ($last_type eq 'AND');
do {warn ' 'x$recursing."!!! Already doing the bool dance for OR\n" if $self->debug; next} if ($last_type eq 'OR');
- local $last_type = 'OR';
+ $last_type = 'OR';
warn ' 'x$recursing."Saving LHS, building RHS\n" if $self->debug;
my $LHS = $struct;
$self->parse_tree( $struct ) if ($self->parse_tree == $LHS);
- local $last_type = '';
+ $last_type = '';
} elsif ($self->facet_class_count && /$facet_re/) { # changing current class
warn ' 'x$recursing."Encountered facet: $1$2 => $3\n" if $self->debug;
$struct->new_facet( $facet => $facet_value, $negate );
$_ = $';
- local $last_type = '';
+ $last_type = '';
} elsif ($self->search_class_count && /$search_class_re/) { # changing current class
if ($last_type eq 'CLASS') {
$current_class = $struct->classed_node( $1 )->requested_class();
$_ = $';
- local $last_type = 'CLASS';
+ $last_type = 'CLASS';
} elsif (/^\s*($required_re|$disallowed_re|$negated_re)?"([^"]+)"/) { # phrase, always anded
warn ' 'x$recursing.'Encountered' . ($1 ? " ['$1' modified]" : '') . " phrase: $2\n" if $self->debug;
$struct->add_node( $substruct ) if ($substruct);
$_ = $after;
} else {
- warn ' 'x$recursing."Directly parsing the phrase subquery\n" if $self->debug;
+ warn ' 'x$recursing."Directly parsing the phrase [ $phrase ] subquery\n" if $self->debug;
$struct->joiner( '&' );
my $class_node = $struct->classed_node($current_class);
}
- local $last_type = '';
+ $last_type = '';
- } elsif (/^\s*($required_re|$disallowed_re)([^${group_end}${float_end}\s"]+)/) { # convert require/disallow word to {un}phrase
+ } elsif (/^\s*($required_re|$disallowed_re)($atom_re)/) { # convert require/disallow word to {un}phrase
warn ' 'x$recursing."Encountered required atom (mini phrase), transforming for phrase parse: $1\n" if $self->debug;
$_ = $1 . '"' . $2 . '"' . $';
- local $last_type = '';
- } elsif (/^\s*([^${group_end}${float_end}\s]+)/o) { # atom
+ $last_type = '';
+ } elsif (/^\s*($atom_re)/) { # atom
warn ' 'x$recursing."Encountered atom: $1\n" if $self->debug;
warn ' 'x$recursing."Remainder: $'\n" if $self->debug;
my $after = $';
$_ = $after;
- local $last_type = '';
+ $last_type = '';
my $class_node = $struct->classed_node($current_class);
$struct->joiner( '&' );
}
- local $last_type = '';
- }
+ $last_type = '';
+ } else {
+ warn ' 'x$recursing."Cannot parse: $_\n" if $self->debug;
+ $_ = '';
+ }
last unless ($_);