Commit | Line | Data |
88eac4d2 |
1 | use strictures 2; |
2 | use Module::Runtime qw(use_module); |
3 | use DX::Utils qw(dict deparse); |
4 | use Devel::Dwarn; |
03fafee9 |
5 | use Try::Tiny; |
88eac4d2 |
6 | BEGIN { *u = \&use_module } |
7 | |
8 | my $scope = u('DX::Scope')->new( |
9 | predicates => { |
10 | map +( |
11 | $_ => u('DX::Predicate::'.join('', map ucfirst, split '_', $_))->new |
12 | ), qw(eq member_at is_dict) |
13 | }, |
14 | globals => dict(), |
15 | locals => [], |
16 | ); |
17 | |
18 | my $exp = u('DX::Expander')->new; |
19 | |
20 | my $tcl = u('Tcl')->new; |
21 | |
22 | foreach my $pred (keys %{$scope->predicates}) { |
23 | $tcl->CreateCommand($pred => sub { |
24 | my (undef, undef, undef, @args) = @_; |
25 | Dwarn [ $pred, $exp->expand_args(@args) ]; |
26 | }); |
27 | } |
28 | |
29 | my $rl = u('Caroline')->new; |
30 | |
31 | while (my $line = $rl->readline('$ ')) { |
03fafee9 |
32 | try { |
33 | $tcl->Eval($line); |
34 | } catch { |
35 | warn "Eval error: $_"; |
36 | }; |
37 | $rl->history_add($line); |
88eac4d2 |
38 | } |