line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# You may distribute under the terms of the GNU General Public License |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# (C) Paul Evans, 2008-2010 -- leonerd@leonerd.org.uk |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Circle::CommandInvocation; |
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
24
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
95
|
|
8
|
4
|
|
|
4
|
|
17
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
131
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.173320'; |
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
4
|
|
17
|
use Scalar::Util qw( weaken ); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
1571
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new |
15
|
|
|
|
|
|
|
{ |
16
|
5
|
|
|
5
|
0
|
49
|
my $class = shift; |
17
|
5
|
|
|
|
|
14
|
my ( $text, $connection, $invocant ) = @_; |
18
|
|
|
|
|
|
|
|
19
|
5
|
|
|
|
|
20
|
$text =~ s/^\s+//; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Weaken the connection to ensure that this object doesn't hold on to the |
22
|
|
|
|
|
|
|
# connection longer than required |
23
|
5
|
|
|
|
|
16
|
my $self = bless [ $text, $connection, $invocant ], $class; |
24
|
5
|
|
|
|
|
26
|
weaken( $self->[1] ); |
25
|
5
|
|
|
|
|
15
|
return $self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub nest |
29
|
|
|
|
|
|
|
{ |
30
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
31
|
0
|
|
|
|
|
0
|
my ( $text ) = @_; |
32
|
0
|
|
|
|
|
0
|
return (ref $self)->new( $text, $self->connection, $self->invocant ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub connection |
36
|
|
|
|
|
|
|
{ |
37
|
14
|
|
|
14
|
0
|
23
|
my $self = shift; |
38
|
14
|
|
|
|
|
53
|
return $self->[1]; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub invocant |
42
|
|
|
|
|
|
|
{ |
43
|
19
|
|
|
19
|
0
|
40
|
my $self = shift; |
44
|
19
|
|
|
|
|
157
|
return $self->[2]; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub peek_token |
48
|
|
|
|
|
|
|
{ |
49
|
8
|
|
|
8
|
0
|
14
|
my $self = shift; |
50
|
|
|
|
|
|
|
|
51
|
8
|
50
|
|
|
|
28
|
if( $self->[0] =~ m/^"/ ) { |
52
|
0
|
0
|
|
|
|
0
|
$self->[0] =~ m/^"(.*)"/ and return $1; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
else { |
55
|
8
|
50
|
|
|
|
62
|
$self->[0] =~ m/^(\S+)/ and return $1; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
0
|
return undef; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub pull_token |
62
|
|
|
|
|
|
|
{ |
63
|
15
|
|
|
15
|
0
|
20
|
my $self = shift; |
64
|
|
|
|
|
|
|
|
65
|
15
|
50
|
|
|
|
45
|
if( $self->[0] =~ m/^"/ ) { |
66
|
0
|
0
|
|
|
|
0
|
$self->[0] =~ s/^"(.*)"\s*// and return $1; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
else { |
69
|
15
|
50
|
|
|
|
104
|
$self->[0] =~ s/^(\S+)\s*// and return $1; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
0
|
return undef; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub peek_remaining |
76
|
|
|
|
|
|
|
{ |
77
|
21
|
|
|
21
|
0
|
31
|
my $self = shift; |
78
|
21
|
|
|
|
|
74
|
return $self->[0]; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# delegate these to invocant |
82
|
|
|
|
|
|
|
foreach my $method (qw( |
83
|
|
|
|
|
|
|
respond |
84
|
|
|
|
|
|
|
respondwarn |
85
|
|
|
|
|
|
|
responderr |
86
|
|
|
|
|
|
|
respond_table |
87
|
|
|
|
|
|
|
)) { |
88
|
4
|
|
|
4
|
|
26
|
no strict 'refs'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
266
|
|
89
|
5
|
|
|
5
|
|
21
|
*$method = sub { shift->invocant->$method( @_ ) }; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
0x55AA; |