line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# This code can be redistributed and modified under the terms of the GNU Affero |
2
|
|
|
|
|
|
|
# General Public License as published by the Free Software Foundation, either |
3
|
|
|
|
|
|
|
# version 3 of the License, or (at your option) any later version. |
4
|
|
|
|
|
|
|
# See the "COPYING" file for details. |
5
|
|
|
|
|
|
|
package HTML::Blitz::ParseError; |
6
|
11
|
|
|
11
|
|
85
|
use HTML::Blitz::pragma; |
|
11
|
|
|
|
|
31
|
|
|
11
|
|
|
|
|
68
|
|
7
|
11
|
50
|
|
11
|
|
5719
|
use overload fallback => 1, '""' => method (@) { $self->to_string }; |
|
11
|
|
|
54
|
|
24
|
|
|
11
|
|
|
|
|
171
|
|
|
54
|
|
|
|
|
14101
|
|
|
54
|
|
|
|
|
95
|
|
|
54
|
|
|
|
|
73
|
|
|
54
|
|
|
|
|
124
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.07'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
method new($class: |
12
|
|
|
|
|
|
|
:$src_name, |
13
|
|
|
|
|
|
|
:$src_ref, |
14
|
|
|
|
|
|
|
:$pos, |
15
|
|
|
|
|
|
|
:$msg, |
16
|
|
|
|
|
|
|
:$width = 1, |
17
|
|
|
|
|
|
|
:$alt_pos = undef, |
18
|
|
|
|
|
|
|
:$alt_msg = undef, |
19
|
|
|
|
|
|
|
:$alt_width = 1, |
20
|
27
|
50
|
33
|
27
|
0
|
69
|
) { |
|
27
|
50
|
|
|
|
141
|
|
|
27
|
50
|
|
|
|
44
|
|
|
27
|
50
|
|
|
|
120
|
|
|
27
|
50
|
|
|
|
75
|
|
|
27
|
50
|
|
|
|
74
|
|
|
27
|
50
|
|
|
|
71
|
|
|
27
|
50
|
|
|
|
56
|
|
|
27
|
50
|
|
|
|
60
|
|
|
27
|
|
|
|
|
40
|
|
|
27
|
|
|
|
|
46
|
|
|
27
|
|
|
|
|
58
|
|
|
27
|
|
|
|
|
69
|
|
|
27
|
|
|
|
|
33
|
|
21
|
27
|
|
|
|
|
481
|
bless {@_}, $class |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
34
|
50
|
|
34
|
|
103
|
fun _context($src_ref, $pos) { |
|
34
|
50
|
|
|
|
80
|
|
|
34
|
|
|
|
|
67
|
|
|
34
|
|
|
|
|
46
|
|
25
|
34
|
|
|
|
|
117
|
my $n_line = substr($$src_ref, 0, $pos) =~ tr/\n// + 1; |
26
|
34
|
|
|
|
|
119
|
my $line_start = rindex($$src_ref, "\n", $pos - 1) + 1; |
27
|
34
|
|
|
|
|
71
|
my $line_end = index($$src_ref, "\n", $pos); |
28
|
34
|
100
|
|
|
|
73
|
$line_end = length $$src_ref if $line_end == -1; |
29
|
34
|
|
|
|
|
85
|
my $s_line = substr $$src_ref, $line_start, $line_end - $line_start; |
30
|
34
|
|
|
|
|
62
|
my $lpos = $pos - $line_start; |
31
|
|
|
|
|
|
|
+{ |
32
|
34
|
|
|
|
|
255
|
line_num => $n_line, |
33
|
|
|
|
|
|
|
col_num => $lpos + 1, |
34
|
|
|
|
|
|
|
line => $s_line, |
35
|
|
|
|
|
|
|
m_prefix => substr($s_line, 0, $lpos) =~ tr/ \t/ /cr, |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
54
|
50
|
|
54
|
0
|
109
|
method location() { |
|
54
|
50
|
|
|
|
118
|
|
|
54
|
|
|
|
|
72
|
|
|
54
|
|
|
|
|
67
|
|
40
|
|
|
|
|
|
|
$self->{_location} //= _context $self->{src_ref}, $self->{pos} |
41
|
54
|
|
66
|
|
|
192
|
} |
42
|
|
|
|
|
|
|
|
43
|
54
|
50
|
|
54
|
0
|
135
|
method alt_location() { |
|
54
|
50
|
|
|
|
117
|
|
|
54
|
|
|
|
|
80
|
|
|
54
|
|
|
|
|
67
|
|
44
|
54
|
|
|
|
|
92
|
my $alt_pos = $self->{alt_pos}; |
45
|
54
|
100
|
|
|
|
128
|
return undef if !defined $alt_pos; |
46
|
14
|
|
66
|
|
|
57
|
$self->{_alt_location} //= _context $self->{src_ref}, $alt_pos |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
54
|
50
|
|
54
|
0
|
124
|
method to_string() { |
|
54
|
50
|
|
|
|
120
|
|
|
54
|
|
|
|
|
82
|
|
|
54
|
|
|
|
|
63
|
|
50
|
54
|
|
|
|
|
116
|
my $loc = $self->location; |
51
|
54
|
|
|
|
|
127
|
my $alt_loc = $self->alt_location; |
52
|
|
|
|
|
|
|
"$self->{src_name}:$loc->{line_num}:$loc->{col_num}: error: $self->{msg}\n" |
53
|
|
|
|
|
|
|
. " |\n" |
54
|
|
|
|
|
|
|
. " | $loc->{line}\n" |
55
|
|
|
|
|
|
|
. " | $loc->{m_prefix}" . '^' x $self->{width} . "\n" |
56
|
|
|
|
|
|
|
. (!defined $alt_loc ? "" : |
57
|
|
|
|
|
|
|
"$self->{src_name}:$alt_loc->{line_num}:$alt_loc->{col_num}: ... $self->{alt_msg}\n" |
58
|
|
|
|
|
|
|
. " |\n" |
59
|
|
|
|
|
|
|
. " | $alt_loc->{line}\n" |
60
|
54
|
100
|
|
|
|
721
|
. " | $alt_loc->{m_prefix}" . '^' x $self->{alt_width} . "\n" |
61
|
|
|
|
|
|
|
) |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1 |