line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Repl::Core::Buffer;
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Pragma's.
|
4
|
1
|
|
|
1
|
|
6
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
395
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new
|
7
|
|
|
|
|
|
|
{
|
8
|
38
|
|
|
38
|
0
|
49
|
my $invocant = shift;
|
9
|
38
|
|
33
|
|
|
171
|
my $class = ref($invocant) || $invocant;
|
10
|
38
|
|
|
|
|
167
|
my %args = (SENTENCE=>"", LINENO=>0, COLNO=>0, @_);
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Initialize the instance.
|
13
|
38
|
|
|
|
|
58
|
my $self = {};
|
14
|
|
|
|
|
|
|
# Split the sentence into characters.
|
15
|
38
|
|
|
|
|
650
|
$self->{BUFFER} = [split(//, $args{SENTENCE})];
|
16
|
38
|
|
|
|
|
190
|
$self->{POS} = 0;
|
17
|
38
|
|
|
|
|
61
|
$self->{LINENO} = $args{LINENO};
|
18
|
38
|
|
|
|
|
57
|
$self->{COLNO} = $args{COLNO};
|
19
|
38
|
|
|
|
|
237
|
return bless($self, $class);
|
20
|
|
|
|
|
|
|
}
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub eof
|
23
|
|
|
|
|
|
|
{
|
24
|
3921
|
|
|
3921
|
0
|
4214
|
my $self = shift;
|
25
|
3921
|
|
|
|
|
4753
|
my $pos = $self->{POS};
|
26
|
3921
|
|
|
|
|
4287
|
my $buf = $self->{BUFFER};
|
27
|
3921
|
|
|
|
|
3972
|
return $pos >= scalar(@{$buf});
|
|
3921
|
|
|
|
|
13771
|
|
28
|
|
|
|
|
|
|
}
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub getLineNo
|
31
|
|
|
|
|
|
|
{
|
32
|
890
|
|
|
890
|
0
|
934
|
my $self = shift;
|
33
|
890
|
|
|
|
|
1947
|
return $self->{LINENO};
|
34
|
|
|
|
|
|
|
}
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub getColNo
|
37
|
|
|
|
|
|
|
{
|
38
|
890
|
|
|
890
|
0
|
911
|
my $self = shift;
|
39
|
890
|
|
|
|
|
1963
|
return $self->{COLNO};
|
40
|
|
|
|
|
|
|
}
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub peekChar
|
43
|
|
|
|
|
|
|
{
|
44
|
969
|
|
|
969
|
0
|
1091
|
my $self = shift;
|
45
|
969
|
50
|
|
|
|
1425
|
return if $self->eof();
|
46
|
|
|
|
|
|
|
|
47
|
969
|
|
|
|
|
1554
|
my $pos = $self->{POS};
|
48
|
969
|
|
|
|
|
1010
|
my $buf = $self->{BUFFER};
|
49
|
969
|
|
|
|
|
896
|
return @{$buf}[$pos];
|
|
969
|
|
|
|
|
4825
|
|
50
|
|
|
|
|
|
|
}
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub consumeChar
|
53
|
|
|
|
|
|
|
{
|
54
|
1205
|
|
|
1205
|
0
|
1216
|
my $self = shift;
|
55
|
1205
|
50
|
|
|
|
1833
|
return if $self->eof();
|
56
|
|
|
|
|
|
|
|
57
|
1205
|
|
|
|
|
1801
|
my $pos = $self->{POS};
|
58
|
1205
|
|
|
|
|
1264
|
my $buf = $self->{BUFFER};
|
59
|
1205
|
|
|
|
|
1233
|
my $char = @{$buf}[$pos];
|
|
1205
|
|
|
|
|
1815
|
|
60
|
|
|
|
|
|
|
|
61
|
1205
|
50
|
|
|
|
2244
|
if($char eq "\n")
|
62
|
|
|
|
|
|
|
{
|
63
|
0
|
|
|
|
|
0
|
$self->{LINENO} +=1;
|
64
|
0
|
|
|
|
|
0
|
$self->{COLNO} = 1;
|
65
|
|
|
|
|
|
|
}
|
66
|
|
|
|
|
|
|
else
|
67
|
|
|
|
|
|
|
{
|
68
|
1205
|
|
|
|
|
1668
|
$self->{COLNO} +=1;
|
69
|
|
|
|
|
|
|
}
|
70
|
|
|
|
|
|
|
|
71
|
1205
|
|
|
|
|
1291
|
$self->{POS} += 1;
|
72
|
1205
|
|
|
|
|
3314
|
return $char;
|
73
|
|
|
|
|
|
|
}
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |