line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# This code can be redistributed and modified under the terms of the GNU |
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
|
|
82
|
use HTML::Blitz::pragma; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
67
|
|
7
|
11
|
50
|
|
11
|
|
5623
|
use overload fallback => 1, '""' => method (@) { $self->to_string }; |
|
11
|
|
|
56
|
|
25
|
|
|
11
|
|
|
|
|
143
|
|
|
56
|
|
|
|
|
13970
|
|
|
56
|
|
|
|
|
98
|
|
|
56
|
|
|
|
|
81
|
|
|
56
|
|
|
|
|
132
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
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
|
28
|
50
|
33
|
28
|
0
|
80
|
) { |
|
28
|
50
|
|
|
|
138
|
|
|
28
|
50
|
|
|
|
52
|
|
|
28
|
50
|
|
|
|
126
|
|
|
28
|
50
|
|
|
|
122
|
|
|
28
|
50
|
|
|
|
71
|
|
|
28
|
50
|
|
|
|
64
|
|
|
28
|
50
|
|
|
|
67
|
|
|
28
|
50
|
|
|
|
70
|
|
|
28
|
|
|
|
|
48
|
|
|
28
|
|
|
|
|
55
|
|
|
28
|
|
|
|
|
59
|
|
|
28
|
|
|
|
|
71
|
|
|
28
|
|
|
|
|
42
|
|
21
|
28
|
|
|
|
|
538
|
bless {@_}, $class |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
35
|
50
|
|
35
|
|
82
|
fun _context($src_ref, $pos) { |
|
35
|
50
|
|
|
|
69
|
|
|
35
|
|
|
|
|
68
|
|
|
35
|
|
|
|
|
43
|
|
25
|
35
|
|
|
|
|
126
|
my $n_line = substr($$src_ref, 0, $pos) =~ tr/\n// + 1; |
26
|
35
|
|
|
|
|
120
|
my $line_start = rindex($$src_ref, "\n", $pos - 1) + 1; |
27
|
35
|
|
|
|
|
97
|
my $line_end = index($$src_ref, "\n", $pos); |
28
|
35
|
100
|
|
|
|
79
|
$line_end = length $$src_ref if $line_end == -1; |
29
|
35
|
|
|
|
|
84
|
my $s_line = substr $$src_ref, $line_start, $line_end - $line_start; |
30
|
35
|
|
|
|
|
56
|
my $lpos = $pos - $line_start; |
31
|
|
|
|
|
|
|
+{ |
32
|
35
|
|
|
|
|
239
|
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
|
56
|
50
|
|
56
|
0
|
115
|
method location() { |
|
56
|
50
|
|
|
|
117
|
|
|
56
|
|
|
|
|
92
|
|
|
56
|
|
|
|
|
70
|
|
40
|
|
|
|
|
|
|
$self->{_location} //= _context $self->{src_ref}, $self->{pos} |
41
|
56
|
|
66
|
|
|
203
|
} |
42
|
|
|
|
|
|
|
|
43
|
56
|
50
|
|
56
|
0
|
112
|
method alt_location() { |
|
56
|
50
|
|
|
|
112
|
|
|
56
|
|
|
|
|
81
|
|
|
56
|
|
|
|
|
72
|
|
44
|
56
|
|
|
|
|
96
|
my $alt_pos = $self->{alt_pos}; |
45
|
56
|
100
|
|
|
|
149
|
return undef if !defined $alt_pos; |
46
|
14
|
|
66
|
|
|
46
|
$self->{_alt_location} //= _context $self->{src_ref}, $alt_pos |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
56
|
50
|
|
56
|
0
|
147
|
method to_string() { |
|
56
|
50
|
|
|
|
114
|
|
|
56
|
|
|
|
|
82
|
|
|
56
|
|
|
|
|
73
|
|
50
|
56
|
|
|
|
|
111
|
my $loc = $self->location; |
51
|
56
|
|
|
|
|
128
|
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
|
56
|
100
|
|
|
|
747
|
. " | $alt_loc->{m_prefix}" . '^' x $self->{alt_width} . "\n" |
61
|
|
|
|
|
|
|
) |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1 |