use DX::Solver;
use DX::Lib::FS;
use Term::ReadLine;
+use Devel::Dwarn;
my $solver = DX::Solver->new(observation_policy => sub { 1 });
} @res ]);
}
-$tcl->CreateCommand(query => sub {
- my (undef, undef, undef, $vars, $body) = @_;
+sub expand_def {
+ my ($vars, $body) = @_;
my @varnames = $split->($vars);
local our @Body_Parts;
$tcl->Eval($body);
- @last_q = (\@varnames, @Body_Parts);
+ return (\@varnames, @Body_Parts);
+}
+
+$tcl->CreateCommand(query => sub {
+ my (undef, undef, undef, $vars, $body) = @_;
+ @last_q = expand_def($vars, $body);
do_query();
return;
});
return;
};
+$tcl->CreateCommand(rule => sub {
+ my (undef, undef, undef, $rule, $vars, $body) = @_;
+ $solver->add_rule($rule => expand_def($vars, $body));
+ $tcl->CreateCommand($rule => $rule_sub);
+ return;
+});
+
foreach my $rule (keys %{$solver->rule_set->rules}) {
$rule =~ s/\/\d+$//;
$tcl->CreateCommand($rule => $rule_sub);
}
+
+$tcl->CreateCommand(exists => sub {
+ my (undef, undef, undef, $vars, $body) = @_;
+ push our @Body_Parts, [ exists => expand_def($vars, $body) ];
+ return;
+});
#$tcl->Eval(q{query D {directory_at D 't'; mode D '0755'; }});
+if ($ARGV[0]) {
+ $tcl->EvalFile($ARGV[0]);
+}
+
my $rl = Term::ReadLine->new;
my $cmd;