From: Matt S Trout Date: Sun, 19 Jun 2016 19:56:07 +0000 (+0000) Subject: make search state operate on search states a bit more X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7506f4cafa4b851450ff9f9bf345cab8cfaa4c70;p=scpubgit%2FDX.git make search state operate on search states a bit more --- diff --git a/lib/DX/SearchState.pm b/lib/DX/SearchState.pm index d119d9b..b1b4038 100644 --- a/lib/DX/SearchState.pm +++ b/lib/DX/SearchState.pm @@ -36,26 +36,24 @@ sub with_one_step { my ($self) = @_; my $hyp = $self->current_hypothesis; return undef unless my $step = $self->next_step; - my ($first_alt, @rest_alt) = my @alt = @{$self->alternatives}; my ($new_ss, $alt_step) = $step->apply_to($self); - my $new_hyp = ($new_ss ? $new_ss->current_hypothesis : undef); - if ($new_hyp) { - return $self->but( - current_hypothesis => $new_hyp, + if ($new_ss) { + return $new_ss->but( alternatives => [ ($alt_step ? [ $hyp, $alt_step ] : ()), - @alt + @{$new_ss->alternatives} ], next_step => DX::Step::InvokeNextPredicate->new( - proposition => $self->next_proposition($new_hyp), + proposition => $new_ss->next_proposition, ), ); } if ($alt_step) { return $self->but(next_step => $alt_step); } + my ($first_alt, @rest_alt) = @{$self->alternatives}; return undef unless $first_alt; trace 'search.backtrack.rewind_to' => $first_alt->[1]; return $self->but(