--- /dev/null
+?
+eq ?X {{ a 1 b 2 c 3 }}
+member_at X ?Y ?Z
+...
+qlist
+?
+eq ?X {{ a 1 b 2 c 3 }}
+member_at X ?Y ?Z
+eq Z 2
+...
+qlist
sub import {
strictures->import::into(1); # should pass version
DX::Types->import::into(1, ':types', ':assert');
+ DX::Utils->import::into(1, '*trace');
Try::Tiny->import::into(1);
Moo->import::into(1);
# This would not be safe with method modifiers, but since the role
action_policy => $ap,
);
+ trace 'step.recheck.hyp' => $hyp;
+
my $ss = DX::SearchState->new_for($hyp);
return undef unless my $sol_ss = $ss->find_solution;
$_, $sol_rps->dependencies_for($_)
) for @recheck;
+ trace 'step.recheck.done' => 'yay';
+
return $self->but(resolved_propositions => $rps);
}
my ($self) = @_;
my ($first_alt, @rest_alt) = @{$self->alternatives};
return undef unless $first_alt;
+ trace 'search.backtrack' => $first_alt->[0];
return ref($self)->new(
current_hypothesis => $first_alt->[0],
resume_step => $first_alt->[1],
$self->apply_predicate($pred => @args);
});
}
+ $tcl->CreateCommand(const => sub {
+ my (undef, undef, undef, $name, $value) = @_;
+ my $tqs = $self->shell_state->template_query_state;
+ my $new_tqs = $tqs->but(
+ globals => $tqs->globals->with_member_at(
+ $name => $self->expand_args($value),
+ ),
+ );
+ $self->_set_shell_state(
+ $self->shell_state->but(
+ template_query_state => $new_tqs
+ ),
+ );
+ });
return $tcl;
});
my ($self, $string) = @_;
local our @Result;
try {
+ no warnings 'redefine';
+ local *DX::Utils::trace = $self->shell_state->trace_sub;
$self->tcl->Eval($string);
} catch {
push @Result, [ output => $_ ];
my ($intro, $need) = ({}, {});
foreach my $arg (@args) {
next if ref($arg);
+ next if $arg =~ /^\??[a-z]/; # skip globals
# ?Foo is intro, Foo is need
($arg =~ s/^\?// ? $intro : $need)->{$arg} = 1;
}
package DX::ShellState;
+use DX::Utils qw(deparse);
use DX::Class;
has template_query_state => (
sub new_query_state { $_[0]->template_query_state }
+sub trace_sub {
+ sub {
+ my ($tag, $thing) = @_;
+ my $dp = deparse($thing);
+ $dp =~ s/\n$//;
+ warn "${tag}: ${dp}\n";
+ }
+}
+
sub with_new_query_state {
my ($self) = @_;
$self->but(
sub apply_to {
my ($self, $old_hyp) = @_;
- return ($self->_apply_to_hyp($old_hyp), $self->alternative_step);
+ trace 'step.apply.old_hyp '.$self => $old_hyp;
+ my $new_hyp = $self->_apply_to_hyp($old_hyp);
+ return (undef, $self->alternative_step) unless $new_hyp;
+ trace 'step.apply.new_hyp '.$self => $new_hyp;
+ return ($new_hyp, $self->alternative_step);
}
sub _apply_to_hyp {
our @EXPORT_OK = (
@const,
(my @builders = qw(step string number dict proposition)),
- 'deparse', 'trace',
+ 'deparse', '*trace',
);
our %EXPORT_TAGS = (
our @VALUE_EXISTS = (EXISTENCE_OF(), TYPE_OF(), INDICES_OF(), CONTENTS_OF());
our @VALUE_SET = (TYPE_OF(), INDICES_OF(), CONTENTS_OF());
-sub trace {
- my ($tag, $thing) = @_;
- my $dp = deparse($thing);
- $dp =~ s/\n//;
- warn "${tag}: ${dp}\n";
-}
+sub trace { }
sub step {
require DX::Step::Normal;